Spring integration 消息模板接收使Dispatcher没有通道的订户
这是我的SpringIntegrationInboundandOutbound,它从一个端点获取一个列表Spring integration 消息模板接收使Dispatcher没有通道的订户,spring-integration,Spring Integration,这是我的SpringIntegrationInboundandOutbound,它从一个端点获取一个列表 <http:inbound-gateway id="webListGateway" request-channel="fromWeb_List" reply-channel="toWeb_List" path="/api/profile/V1/get" supported-methods="GET">
<http:inbound-gateway id="webListGateway"
request-channel="fromWeb_List"
reply-channel="toWeb_List"
path="/api/profile/V1/get"
supported-methods="GET">
<http:header name="container" expression="#pathVariables.container"/>
<http:header name="groupName" expression="#pathVariables.groupName"/>
<http:header name="userId" expression="#pathVariables.userId"/>
</http:inbound-gateway>
<int:header-enricher input-channel="fromWeb_List" output-channel="toCloud_List">
<int:header name="apikey" value=“1234”/>
</int:header-enricher>
<http:outbound-gateway id="profileListGateway"
request-channel="toCloud_List"
reply-channel="sync_preferences"
url=“localhost:8081/containers/{container}/groups/{groupName}/values/hierarchy/{userId}"
http-method="GET"
expected-response-type="java.lang.String"
charset="UTF-8"
extract-request-payload="false"
header-mapper="headerMapper"
encode-uri="true" >
<http:uri-variable name="container" expression="headers.container"/>
<http:uri-variable name="groupName" expression="headers.groupName"/>
<http:uri-variable name="userId" expression="headers.userId"/>
</http:outbound-gateway>
<int:recipient-list-router id="syncRouter" input-channel="sync_preferences">
<int:recipient channel="toWeb_List"/>
<int:recipient channel="toCloud_Save"/>
</int:recipient-list-router>
知道我做错了什么吗。您不能将
DirectChannel
用于MessagingGateway.receive()
:
桥接器
是将信息从输入通道转移到输出通道(如果存在)的组件。否则,它将参考MessageHeaders
以获取replyChannel
值。当您直接从Java调用时,这是通过入站请求-应答组件(如
或普通
)来填充的
请参阅。中的详细信息。当我向入站发出http请求时,它工作正常,因为它有订阅者。当我使用java从系统中调用时,我并没有经过入站,而是直接从标头enricher到出站。是否有任何方法可以将响应发送回java调用者,而无需通过入站请求。请参阅我回答中的更新。集成非常棒,使用了桥接器,然后使用template.sendAndReceive,它可以工作。非常感谢您的快速回复。
MessagingTemplate template = new MessagingTemplate();
Message<String> message1 = MessageBuilder.withPayload("")
.setHeader("container", “fwd”)
.setHeader("groupName", “foo”)
.setHeader("userId", “user”)
.build();
template.send((MessageChannel) CONTEXT.getBean("fromWeb_List"),message1);
PreList pre = (PreList) template.receive((MessageChannel)CONTEXT.getBean("toWeb_List"));
Dispatcher has no subscribers for channel 'application:springboot.toWeb_List'
protected final Message<?> doReceive(MessageChannel channel, long timeout) {
Assert.notNull(channel, "MessageChannel is required");
Assert.state(channel instanceof PollableChannel, "A PollableChannel is required to receive messages");
<int:recipient-list-router id="syncRouter" input-channel="sync_preferences">
<int:recipient channel="toWeb_List"/>
<int:recipient channel="toCloud_Save"/>
</int:recipient-list-router>
<int:bridge input-channel="toWeb_List"/>