2

I am using multiple <si:service-activator>'s and <jms:message-driven-channel-adapter>'s to subscribe to multiple queues and topics. Messages from each destination are received in a separate thread, which means that my receiving code is full of locks to guard the mutable internal state.

I would like my receiving code to be lock free. Is it possible to configure spring-integration/activemq to receive from multiple destinations on the same thread?

If this is not possible, I can think of two alternatives:

  1. Start my own processing thread which reads from a blocking queue, put all received messages on this queue.

  2. Dispatch all received messages onto a single destination and consume from this.

Anyone have any better ideas?

Artem Bilan
  • 113,505
  • 11
  • 91
  • 118
zool
  • 23
  • 2

1 Answers1

1

Use the wildcard pattern on a single queue.

That is, instead of reading from two queues, use one queue and specify all queues you want to read from in the name.

that is: "QUEUE.NR1,QUEUE.NR2" or "SOME.PREFIX.>" to read all queues with that prefix. Your client code handle this as a single queue.

Glorfindel
  • 21,988
  • 13
  • 81
  • 109
Petter Nordlander
  • 22,053
  • 5
  • 50
  • 84
  • Yes this does work. Note: queues subscribed to via wildcards (even 2 comma seperated) are not shown in the web console until the first message is received. The next problem is how to mix queues and topics with wildcards? – zool May 21 '15 at 09:54
  • Use VirtualTopics to use queues to subscribe to topics. You cannot really mix otherwise. http://activemq.apache.org/virtual-destinations.html – Petter Nordlander May 21 '15 at 11:38