These are chat archives for spring-cloud/spring-cloud

11th
Oct 2015
Marcin Grzejszczak
@marcingrzejszczak
Oct 11 2015 10:59 UTC
@turick - can you put a breakpoint https://github.com/spring-cloud/spring-cloud-sleuth/blob/master/spring-cloud-sleuth-core/src/main/java/org/springframework/cloud/sleuth/instrument/web/TraceWebAutoConfiguration.java#L65 and ensure that the filter is operational? When I was playing around with M1 there was an issue with this particular filter - spring-cloud/spring-cloud-sleuth#42 . Maybe you have the same issue?
if you're using 1.0.0.M1
Petar Tahchiev
@ptahchiev
Oct 11 2015 12:21 UTC
Here's a more generic question -I have a monolyth that runs some jobs using spring-batch. I can't scale it because then each node would run the same job at the same time so they would rewrite their results, plus it's a really bad in terms of performance. I was thinking to extract the jobs in a separate microservice, but again the same problem appearrs - my microservice will be scalable to 1 instance only.. perhaps i'm missing something here
Dave Syer
@dsyer
Oct 11 2015 14:13 UTC
If you set the JobParameters up right you can a cake up the job worker processes. Only one can execute the same job execution at a time.
Petar Tahchiev
@ptahchiev
Oct 11 2015 14:15 UTC
you mean only one instance? do you have a link to an example maybe?
Dave Syer
@dsyer
Oct 11 2015 14:15 UTC
All batch apps behave the same way
Petar Tahchiev
@ptahchiev
Oct 11 2015 14:16 UTC
hmm.. I thought every instance of my app in cloudfoundry doesnt know anything about how many other instances there are .. how can i find out what is the current node number?
Dave Syer
@dsyer
Oct 11 2015 14:18 UTC
They share a job repository
Petar Tahchiev
@ptahchiev
Oct 11 2015 14:19 UTC
ok i guess i'm missing a lot of stuff :)
Dave Syer
@dsyer
Oct 11 2015 14:19 UTC
Maybe not
You have a job repository
Make sure it's shared
In CF all you would need to do is bind to the same database service
Petar Tahchiev
@ptahchiev
Oct 11 2015 14:21 UTC
yes, i have a jobRepository and it has a bunch of DAOs that all connect to the same db

    @Bean(name = "jobRepository")
    public SimpleJobRepository defaultJobRepository() {
        return new SimpleJobRepository(context.getBean("jobInstanceDao", JobInstanceDao.class), context.getBean("jobExecutionDao", JobExecutionDao.class),
                                       context.getBean("stepExecutionDao", StepExecutionDao.class),
                                       context.getBean("executionContextDao", ExecutionContextDao.class));
    }
how can I share it?
Dave Syer
@dsyer
Oct 11 2015 14:26 UTC
Bind all your apps to the same database
Petar Tahchiev
@ptahchiev
Oct 11 2015 14:28 UTC
yeah they are already bound.. but I guess I also need to add a JobExecutionListener:beforeJob to check if the job is being executed on node 0 then stop it or smth like this
*is not executed on node 0
how to check what is the current node :worried:
Dave Syer
@dsyer
Oct 11 2015 14:35 UTC
Use the JobOperator maybe?
Spring XD does a lot of this for you
Sprn Batch Admin used to, but I'm not sure it works any more (you'd have to check)
But seriously, if you have a decent relational database you can't be running the same job execution more than once at a time.
Petar Tahchiev
@ptahchiev
Oct 11 2015 14:38 UTC
why not - my trigger is defined in every instance's java config:
    @Bean(name = { "defaultExportUpdateCatalogsTrigger", "exportUpdateCatalogsTrigger" })
    public Trigger defaultExportUpdateCatalogsTrigger() {
        return new CronTrigger("0 0/1 * * * ?"); //every minute
    }
so from what i understand every instance will start it
Dave Syer
@dsyer
Oct 11 2015 14:48 UTC
Only one will succeed
They take a lock in the database before they start
Petar Tahchiev
@ptahchiev
Oct 11 2015 14:49 UTC
ok, nice :+1:
Dave Syer
@dsyer
Oct 11 2015 14:49 UTC
The lock is keyed on the job parameters though
that's why I said, you need to get the parameters right