I need help how build with spring integration DSL and amqp this model of behavior. I have three types of messages and I need consume from queue one type of message by consumer and only if consumer have not this type task in queue for longer time cca 30 second, then look for second type of task or third type of task.
2 Answers
You can't select messages by content from a single queue in amqp. You need to route the messages to different queues.
You could configure a message-driven adapter for the first type.
Then, start a timer and if the 30 seconds elapses then use a RabbitTemplate
receive operation on the other queue(s).

- 166,535
- 14
- 146
- 179
-
Ok. I solved it very similar way. Just I use SimpleMessageListenerContainer and manage what queue consume with add or remove queue. Messages are routed by route key. – lubo08 Jul 07 '15 at 16:38
Your logic looks like the .filter()
just after .from(Amqp.inboundAdapter()
.
That filter
must take a look to some shared component (yes, Queue
is OK) and decide what to do with that message in both true
and false
cases.
For this purpose you can take a look to the Idempotent Receiver
as well.
It has metadata-store
option which can be used as that shared component. Of course, some other component in the end must remove an entry from the store to allow to accept the next message for the same type.

- 113,505
- 11
- 91
- 118