0

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 ?

2
  • 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. Commented Feb 3, 2023 at 8:57
  • @MahmoudBenHassine I need to run remote partitioning with each microservice which is performing for multitenant db, The manager JVM where the request to trigger Job know the tenant and switch to tenant db , workers are running in separate JVM so the workers need to communication to corresponding tenant db . Yes this is business requirement . I am able to solve this issue let me add to answer
    – ashok
    Commented Feb 3, 2023 at 12:43

1 Answer 1

0

I am able to solve this multi tenant on remote partitioning with kafka by dynamically creating steps, Job Repository, Inbound , outbound flow bean for each tenant.

Not the answer you're looking for? Browse other questions tagged or ask your own question.