仅将第一条消息传递到服务器

时间:2010-06-25 12:02:47

标签: java spring-integration

我正在尝试在客户端轮询数据库,并通过HTTP将结果发送到收集数据的服务器。不幸的是,只传递了第一条消息。我是spring-integration(1.0.3)

的新手

我的配置有什么问题?

客户端配置:

<si:channel id="msgChannel">
    <si:queue capacity="1" />
</si:channel>

<si:inbound-channel-adapter ref="jdbcInputAdapter" method="fetchData" channel="msgChannel">
    <si:poller max-messages-per-poll="1"> 
        <si:interval-trigger interval="5000" />
    </si:poller>
</si:inbound-channel-adapter>

<http:outbound-gateway id="httpChannelAdapter" request-channel="msgChannel" default-url="http://localhost:8080/company/gateway"/>

<si:poller default="true">
    <si:interval-trigger interval="5000" />
</si:poller>

服务器配置:

<si:channel  id="requestChannel">
        <si:queue capacity="4" />
</si:channel>

<si:channel id="replyChannel" />

<http:inbound-gateway id="InboundGateway" request-channel="requestChannel" reply-channel="replyChannel"/>

<bean id="shouter" class="com.company.Shouter"/>
<si:outbound-channel-adapter ref="shouter"  method="shout" channel="replyChannel"/>

<si:service-activator input-channel="requestChannel"
    ref="StorageService" method="store"
    output-channel="replyChannel" />

<bean id="StorageService" class="com.company.StorageService" />

<si:poller default="true">
        <si:interval-trigger interval="1000" />
</si:poller>

编辑:每次重新启动客户端时,服务器都会收到一条消息。

已解决:我必须从

更改StorageService的签名
public void store(Message msg)

public Message store(Message msg)

2 个答案:

答案 0 :(得分:3)

如果您想使用void签名,请使用http:inbound-channel-adapter而不是http:inbound-gateway。

通常,所有网关都是双向的,所有通道适配器都是单向的,因此网关将等待或生成响应,而通道适配器则不会。

服务激活器可以执行这两种角色,具体取决于它所包含的方法的返回类型。这也是导致问题的原因。

顺便说一下:您还可以让您的方法接受消息的有效负载,这样可以更容易地进行测试和重用。

public StorageResult store(Storable s, Map headers);

答案 1 :(得分:-1)

尝试删除队列容量。为什么你还有他们呢?

相关问题