1
votes

I'm trying to create a Request/Reply flow with Spring Integration Java DSL that's described as such:

IntegrationFlows.from(directChannel)
                .handle(Jms.outboundGateway(connectionFactory)
                        .requestDestination(requestDestination)
                        .replyDestination(replyDestination))
                .handle(replyHandler)
                .get();

If I kill my application that supposed to handle the reply, then the reply gets left on the queue and isn't consumed the next time the application starts up. When I send follow up requests with this flow, the previous message is received and not the latest reply.

The message flow I'm testing looks like

App A sends message -> Stop A -> App B receives message and sends reply R1

A starts up -> A sends another message -> B receives message and sends reply R2 -> A receives R1

R2 is left on the queue

Am I doing something wrong?

Thanks!

1

1 Answers

1
votes

It shouldn't happen that way at all, I would expect R1 to stay on the queue for ever because the gateway uses a message selector to receive the reply, based on the outbound message id. So the new instance should never select the old message.

In this mode, it expects the receiving application to copy the inbound message id to the JMSCorrelationID header. This is a common JMS Pattern when the inbound message has no JMSCorrelationID.

Try setting the correlationKey to JMSCorrelationID. In that mode, the requesting gateway uses a unique id per instance and it expects the receiving side to simply echo the inbound JMSCorrelationID header.

If you can get debug logs on both sides, it might help tracking it down.