I'm having trouble getting the follow design to work:
- Client receives a work request via a HTTP inbound gateway.
- A job is built from the HTTP request and sent to a job orcherstrator over a AMQP gateway (I want to use request/reply for this interface)
- The job is processed by the orchestrator by sending it onto workers over AMQP queues (using AMQP outbound adapters).
- The work unit process the job and update it. It is then returned asynchronously to the orchestrator on a separate queue (AMQP inbound adapter).
- Once all of the responses are gathered by the orchestrator it updates the job to say it is finished and returns it to client over the AMQP gateway
- Client receives the reply and returns the response back to the sender of the HTTP request
It all works up to step 5 where the orchestrator returns the reply back to the client (over the AMQP gateway). The orchestrator throws the following exception
What appears to be happening is the message amqp headers from the HTTP client request are being overridden when the orchestrator sends the job on the AMQP adapters to the workers downstream. This means when the AMQP gateway tries to send the job back to the HTTP client it cannot find the headers it needs from the request.
Caused by: org.springframework.integration.support.channel.ChannelResolutionException: no output-channel or replyChannel header available
at org.springframework.integration.handler.AbstractReplyProducingMessageHandler.sendReplyMessage(AbstractReplyProducingMessageHandler.java:165) ~[spring-integration-core-2.1.0.RELEASE.jar:na]
at org.springframework.integration.handler.AbstractReplyProducingMessageHandler.produceReply(AbstractReplyProducingMessageHandler.java:124) ~[spring-integration-core-2.1.0.RELEASE.jar:na]
at org.springframework.integration.handler.AbstractReplyProducingMessageHandler.handleResult(AbstractReplyProducingMessageHandler.java:118) ~[spring-integration-core-2.1.0.RELEASE.jar:na]
I've tried saving the message headers from the client request and restoring them before sending a response. However this doesn't work either - the work orchestrator appears to send the reply successfully but HTTP client's AMQP gateway doesn't receive it (or ignores it). I have noticed that even though I build the reply with request headers the header 'id' field of the sent reply is different.
Is there way to resolve this issue or is my mixing of AMQP gateways and adapters flawed?