I'm consuming messages from a rabbit queue with a bean configured like so:
IntegrationFlows.from(Amqp.inboundGateway(listenerContainer()).errorChannel(FailedFlow.CHANNEL_NAME))
.transform(Transformers.fromJson())
.channel(TestFlow.CHANNEL_NAME)
.get();
The message goes through some routers and header enrichers to end up in an outbound flow with a bean configured like so:
IntegrationFlows.from(CHANNEL_NAME)
.transform(Transformers.toJson())
.handle(Http.outboundChannelAdapter("http://localhost:8080/api/test")
.httpMethod(HttpMethod.POST)
.requestFactory(getRequestFactory()))
.get();
This works fine while testing, but for actual use i need to send the request to different servers using a base url stored in a header that has been added earlier.
IntegrationFlows.from(CHANNEL_NAME)
.transform(Transformers.toJson())
.handle(e -> Http.outboundChannelAdapter(String.format("%s/test",
e.getHeaders().get(IntegrationConstants.NOTIFY_BASE_URL_HEADER_NAME)))
.httpMethod(HttpMethod.POST)
.requestFactory(getRequestFactory()))
.get();
It seems that in the test config i'm passing a MessageHandlerSpec to the handle method and in the actual config i'm passing a MessageHandler to the handle method. I'm not sure what does the difference, all i know is that the endpoint is not called when passing the MessageHandler.
How do i access the headers while maintaining the direct use of the MessageHandlerSpec?