我有一个简单的“Hello World”示例工作流程,在这里我想公开一个以纯文本响应的inbound-gateway
Web服务。我相信我将回应路由到myReplyChannel
的方式不正确。春季集成入站网关回复通道没有用户通道
<int:channel id="myRequestChannel"/>
<int:channel id="myReplyChannel"/>
<int-http:inbound-gateway id="myGateway"
path="/hi"
supported-methods="GET"
request-channel="myRequestChannel"
reply-channel="myReplyChannel"/>
<int:transformer input-channel="myRequestChannel"
output-channel="myReplyChannel"
expression="'Hello World!'"/>
这工作部署时,但是当我第一次叫我看这个服务记录:
Adding {bridge:null} as a subscriber to the 'myReplyChannel' channel
Channel 'org.springframework.web.context.WebApplicationContext:myReplyChannel' has 1 subscriber(s).
started [email protected]f7503
看起来像春天在用户在最后一刻加入了myReplyChannel
。我宁愿自己正确地做。
单元测试
我写了一个简单的单元测试调试这个..
@RunWith(SpringJUnit4ClassRunner.class)
@ContextConfiguration(locations = { "classpath:hello.xml" })
public class HelloWorldTest {
@Autowired
private MessageChannel myRequestChannel;
@Test
public void test() {
myRequestChannel.send(MessageBuilder.withPayload("").build());
}
}
这个错误出具有:
org.springframework.messaging.MessageDeliveryException:
Dispatcher has no subscribers for channel
'[email protected]485a47.myReplyChannel'.
这读对我来说,我的配置是错了,这里春天不牵着我的手。
备用配置:
我试过只是删除myReplyChannel
一起,它的工作没有在日志中任何东西。
<int:channel id="myRequestChannel"/>
<int-http:inbound-gateway id="myGateway"
path="/ok"
supported-methods="GET"
request-channel="myRequestChannel"/>
<int:transformer input-channel="myRequestChannel" expression="'OK'"/>
这是正确的设置?如果是这样,参数reply-channel
是什么?
有了这个配置,我得到了我的单元测试以下错误:
org.springframework.messaging.MessagingException:
org.springframework.messaging.core.DestinationResolutionException:
no output-channel or replyChannel header available