Reputation: 4511
I like the way SI allows for making transparent proxies to channels using @Gateway
and @ServiceActivator
.
I was looking at http://docs.spring.io/spring-integration/reference/html/messaging-channels-section.html#channel-interfaces-subscribablechannel. There are two types of channels:
Looking at these, it looks to me that all of these are made so that one of the below is true:
Is there a way to configure / use SI in a way that:
Pretty much like put
/ take
from BlockingQueue from Java itself.
Am I overlooking some constraint here? Also, if there are other alternatives in Spring for what I'm trying to do (basically asynchronous event bus) with a similar interface (i.e. not having to manually send messages, but having it in a transparent way using interfaces), I'd be glad to hear about them.
Upvotes: 1
Views: 171
Reputation: 174729
If you use a QueueChannel
and set the Poller's receiveTimeout
to -1, the framework will do what you want - the poller thread will block on the receive()
waiting for a message (with a negative timeout, it uses take()
under the covers).
By default (for a polling consumer) the max-messages-per-poll
is also -1 (infinity) which means there will be no "polling" at all (after the first trigger), just blocking.
If the queue has a limit, the sender will block until there's space (it uses put()
when a send timeout of -1 is used - the default).
Upvotes: 1