1

Here is my requirement, which have more than 50 inbound consumer to listen different queues needs to be configured.

Is there any option in spring integration, where I can pass my queue details from configuration and the corresponding consumer bean should be created and added to my application context.

Between, I'm using java 8 with spring 4.3.4

Any help is appreciated!!

Nandha0903
  • 35
  • 5
  • 1
    Use the Java DSL and it's dynamic integration flow feature - see [this question and its first answer](https://stackoverflow.com/questions/38493071/dynamically-instantiating-spring-integration-flows). – Gary Russell May 24 '18 at 12:56
  • Oops! I have answered this way already here. – Artem Bilan May 24 '18 at 12:58

1 Answers1

0

For this purpose we have implemented Dynamic Flows Registration.

I understand that you might not use Spring Integration Java DSL, but there is no an easy way to register beans at runtime.

An IntegrationFlowContext is available for Spring Integration 4.3.x as well: you need to include an extension for the Spring Integration Java DSL: https://github.com/spring-projects/spring-integration-java-dsl/

This way you can do something like this in the code:

 IntegrationFlow flow = f -> 
          IntegrationFlows.from(
               Jms.messageDriverChannelAdapter(this.connectionFactory)
                    .destination(aDestinationName))
                 .channel(channelToSend)
                 get();

    IntegrationFlowRegistration theFlow = this.flowContext.registration(flow).register();
Artem Bilan
  • 113,505
  • 11
  • 91
  • 118
  • Hello Artem, could you please suggest us how header enricher also adds upon to above flow and I hope each message driven adaptor channel needs individual outbound channel to put the jms message. Do we dynamically need to create message channel aswell ? If so, how can dynamically add message channel to my context . – Nandha0903 May 28 '18 at 16:29
  • Why did you take accept from the answer off! That’s not how StackOverflow works. I believe that I answered to your original question. The header enricher deserves its own SO thread. More over that was a holiday here, so I was out off the Internet. Please, study SO policies how to handle questions – Artem Bilan May 29 '18 at 11:58
  • Okay.. have accepted the answer. Got the header enricher part working to my requirement. Thanks for your reply. – Nandha0903 May 29 '18 at 12:02