2010-06-25 55 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

相關問題