I have implemented the spring batch remote partitioning with Kafka where 3 workers are running on separate JVMs , on the each worker before initialization of job repository I need to set the tenant.
I am passing a tenant code value in executionContext during partitioning from manager jvm. in worker jvm i am able to read this param from stepExecution but during jobRepository initialization I need to read this value.
I an using below inboundFlow
@Bean // request coming from manager
public IntegrationFlow inboundFlow(ConsumerFactory consumerFactory) {
return IntegrationFlows
.from(Kafka.inboundChannelAdapter(consumerFactory, new ConsumerProperties("requestForWorkers")))
.channel(requestForWorkers())
.get();
}
My understanding that when worker consumer read message from Kafka that time I can read this value ?
I need to set the tenant.
: why do you need to do that? Is that a business requirement or a technical one? Technical details about the distributed nature of your deployment should be transparent to the job IMO.