views:

39

answers:

2

I'm trying to poll a DB on client side and send the result over HTTP to a server which collects data. Unfortunatly only the first message is delivered. I'm new to spring-integration (1.0.3)

What is wrong with my configuration?

Clients config:

<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"/&gt;

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

Servers config:

<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>

EDIT: Everytime I restart the client a single message will be received by the server.

SOLVED: I had to change the signature of StorageService from

public void store(Message msg)

to

public Message store(Message msg)
A: 

Try removing the queue capacities. Why do you have them there anyway?

Paul McKenzie
@Paul, thanks I removed queue capacities which had no effect.
stacker
why the downvote? seems gratuitous
Paul McKenzie
the answer is misleading, but I agree the -1 is redundant
iwein
+2  A: 

If you like to use a void signature, use a http:inbound-channel-adapter instead of http:inbound-gateway.

In general, all gateways are two-way and all channel adapters are one way, so a gateway will wait for or generate a response, a channel-adapter will not.

A service-activator can perform both roles, depending on the return type of the method it is wrapped around. This also turned out to be the cause of your problem.

By the way: you can also have your method accept the payload of the message, which will make it easier to test and reuse.

public StorageResult store(Storable s, Map headers);
iwein