in Education by
I have 2 JMS queues and my application subscribes to both of them with Jms.messageDrivenChannelAdapter(...) component. First queue receives messages of type Paid. Second queue receives messages of type Reversal. Business scenario defines correlation between messages of type Paid and type Reversal. Reversal should wait for Paid in order to be processed. How can I achieve such "wait" pattern with Spring Integration? Is it possible to correlate messages between 2 JMS queues? JavaScript questions and answers, JavaScript questions pdf, JavaScript question bank, JavaScript questions and answers pdf, mcq on JavaScript pdf, JavaScript questions and solutions, JavaScript mcq Test , Interview JavaScript questions, JavaScript Questions for Interview, JavaScript MCQ (Multiple Choice Questions)

1 Answer

0 votes
by
See the documentation about the Aggregator. The aggregator correlates messages using some correlation strategy and releases the group based on some release strategy. The Aggregator combines a group of related messages, by correlating and storing them, until the group is deemed to be complete. At that point, the aggregator creates a single message by processing the whole group and sends the aggregated message as output. The output payload is a list of the grouped message payloads by default, but you can provide a custom output processor. EDIT @SpringBootApplication public class So55299268Application { public static void main(String[] args) { SpringApplication.run(So55299268Application.class, args); } @Bean public IntegrationFlow in1(ConnectionFactory connectionFactory) { return IntegrationFlows.from(Jms.messageDrivenChannelAdapter(connectionFactory) .destination("queue1")) .channel("aggregator.input") .get(); } @Bean public IntegrationFlow in2(ConnectionFactory connectionFactory) { return IntegrationFlows.from(Jms.messageDrivenChannelAdapter(connectionFactory) .destination("queue2")) .channel("aggregator.input") .get(); } @Bean public IntegrationFlow aggregator() { return f -> f .aggregate(a -> a .correlationExpression("headers.jms_correlationId") .releaseExpression("size() == 2") .expireGroupsUponCompletion(true) .expireGroupsUponTimeout(true) .groupTimeout(5_000L) .discardChannel("discards.input")) .handle(System.out::println); } @Bean public IntegrationFlow discards() { return f -> f.handle((p, h) -> { System.out.println("Aggregation timed out for " + p); return null; }); } @Bean public ApplicationRunner runner(JmsTemplate template) { return args -> { send(template, "one", "two"); send(template, "three", null); }; } private void send(JmsTemplate template, String one, String two) { template.convertAndSend("queue1", one, m -> { m.setJMSCorrelationID(one); return m; }); if (two != null) { template.convertAndSend("queue2", two, m -> { m.setJMSCorrelationID(one); return m; }); } } } and GenericMessage [payload=[two, one], headers={jms_redelivered=false, jms_destination=queue://queue1, jms_correlationId=one, id=784535fe-8861-1b22-2cfa-cc2e67763674, priority=4, jms_timestamp=1553290921442, jms_messageId=ID:Gollum2.local-55540-1553290921241-4:1:3:1:1, timestamp=1553290921457}] 2019-03-22 17:42:06.460 INFO 55396 --- [ask-scheduler-1] o.s.i.a.AggregatingMessageHandler : Expiring MessageGroup with correlationKey[three] Aggregation timed out for three

Related questions

0 votes
    I have followed the link Spring integration: handle http error with oubound gateway But I don't have full ... Questions for Interview, JavaScript MCQ (Multiple Choice Questions)...
asked May 3, 2022 in Education by JackTerrance
0 votes
    I'm using Spring.net with NHiberante (HibernateTemplate) to implement my DAO's. I also have some ... Questions for Interview, JavaScript MCQ (Multiple Choice Questions)...
asked Mar 16, 2022 in Education by JackTerrance
0 votes
    I'm using Spring.net with NHiberante (HibernateTemplate) to implement my DAO's. I also have some ... Questions for Interview, JavaScript MCQ (Multiple Choice Questions)...
asked Mar 16, 2022 in Education by JackTerrance
+1 vote
    Which are the modules of Data Access/ integration layer in Spring? A - JDBC, ORM, OXM, JMS, Transactions B - JDBC, ORM, OXM, JMS C - JDBC, ORM, Web, Beans D - JDBC, ORM, OXM, JMS...
asked Oct 14, 2020 in Technology by JackTerrance
0 votes
    Differentiate between the Windows Azure bus queues and Windows Azure queues?...
asked Dec 27, 2020 in Technology by JackTerrance
0 votes
    I want to try and get an understanding of how JMS works. I am going through a tutorial and have ... JavaScript Questions for Interview, JavaScript MCQ (Multiple Choice Questions)...
asked Feb 18, 2022 in Education by JackTerrance
0 votes
    I want to try and get an understanding of how JMS works. I am going through a tutorial and have ... JavaScript Questions for Interview, JavaScript MCQ (Multiple Choice Questions)...
asked Feb 18, 2022 in Education by JackTerrance
0 votes
    What are the Spring Boot key components?...
asked Jul 5, 2021 in Education by JackTerrance
0 votes
    If only one 'Consumer Group' subscribed for a topic and there are lots of consumers in this Consumer Group, messages ... group. This is (1)Queuing model (2)Publish-Subscribe model...
asked Jun 17, 2021 in Technology by JackTerrance
0 votes
    Difference between: 1. Biotic components and Abiotic component 2. Producers and Herbivores 3. Carnivores ... proposed by,electromagnetic theory engineering physics,Science nptel...
asked Nov 7, 2021 in Education by JackTerrance
0 votes
    How is continuous integration achieved using Jenkins?...
asked Sep 14, 2021 in Technology by JackTerrance
0 votes
    How can we differentiate between continuous integration, continuous delivery and DevOps? How are they related to ... deployments? Select the correct answer from above options...
asked Jan 25, 2022 in Education by JackTerrance
0 votes
    Differentiate between TOS for Data Integration and TOS for Big Data?...
asked Mar 23, 2021 in Technology by JackTerrance
0 votes
    Differentiate between TOS for Data Integration and TOS for Big Data....
asked Mar 23, 2021 in Technology by JackTerrance
0 votes
    I am trying to use celery to manage tasks. The problem i am into now, that i have many minor ... JavaScript Questions for Interview, JavaScript MCQ (Multiple Choice Questions)...
asked Feb 19, 2022 in Education by JackTerrance
...