Search code examples
springspring-integrationbridge

spring integration bridge direct channel to queue Channel


At unit test time, I try to bridge the Spring Integration default channel to a queued channel, since I want to check the correctness of the amount of message flow into this channel.

<int:filter input-channel="prevChannel" output-channel="myChannel">
<int:bridge input-channel="myChannel" output-channel="aggregateChannel">
// the reason I have above bridge is I want to check the amount of message after filter.
// I cannot check prevChannel since it is before filtering, and I cannot check aggregateChannel 
// because it has other processing branch

// in test xml I import above normal workflow xml and added below configuration to 
// redirect message from myChannel to checkMyChannel to checking.


<int:bridge input-channel="myChannel"
            output-channel="checkMyChannel"/>

<int:channel id="checkMyChannel">    
    <int:queue/> 
</int:channel>

I autowired checkMyChannel in my unit test but checkMyChannel.getqueuesize() always return 0.

Is there sth I did wrong?


Solution

  • got this fixed, I have to declare myChannel to be a publish-subscribe-channel

    How to test Spring Integration This one helps, for my case there is a race condition since. "A regular channel with multiple subscribers will round-robin ..."