2010-06-25 108 views
1

我想要在客户端轮询一个数据库并通过HTTP发送结果到一个服务器收集数据。不幸的是,只有第一条消息被传送。我是弹簧整合新手(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) 

回答

3

如果您想使用无效签名,请使用http:入站通道适配器而不是http:入站网关。

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

服务激活器可以执行这两种角色,具体取决于它所缠绕的方法的返回类型。这也成了你问题的原因。顺便说一下:你也可以让你的方法接受消息的有效载荷,这将使测试和重用变得更加容易。

public StorageResult store(Storable s, Map headers); 
-1

尝试删除队列能力。无论如何,你为什么还有他们?

+0

谢谢我删除了无效的队列容量。 – stacker 2010-06-25 12:54:53

+0

答案是误导性的,但我同意-1是多余的 – iwein 2010-07-20 09:26:26

相关问题