1
我消耗来自兔队列中的消息与被配置像这样一个bean:使用报头建立在HTTP出站通道适配器URL
IntegrationFlows.from(Amqp.inboundGateway(listenerContainer()).errorChannel(FailedFlow.CHANNEL_NAME))
.transform(Transformers.fromJson())
.channel(TestFlow.CHANNEL_NAME)
.get();
该消息经过一些路由器和头浓缩商在结束了出站流量配置有像这样一个bean:
IntegrationFlows.from(CHANNEL_NAME)
.transform(Transformers.toJson())
.handle(Http.outboundChannelAdapter("http://localhost:8080/api/test")
.httpMethod(HttpMethod.POST)
.requestFactory(getRequestFactory()))
.get();
同时测试,但实际使用中,我需要把请求发送到使用存储在已被前面添加一个标题基本URL不同的服务器能正常工作。
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();
看来,在测试的配置我传递一个MessageHandlerSpec到手柄方法和实际的配置我传递一个的MessageHandler到手柄的方法。我不确定有什么区别,我所知道的是在传递MessageHandler时不会调用端点。
如何在保持直接使用MessageHandlerSpec的同时访问标题?