开发者

Why QueueSession can create only one receiver in JMS?

开发者 https://www.devze.com 2023-02-25 05:41 出处:网络
I can make some senders to send some messages, but when I create two receivers in one Session, the first one works and the second one blocked. In debug, I see the queue list size which the second rece

I can make some senders to send some messages, but when I create two receivers in one Session, the first one works and the second one blocked. In debug, I see the queue list size which the second receiver received is zero. I 开发者_StackOverflow中文版found that session is made for one thread, I don't know whether this problem involves in the unsafe thread?

I use ActiveMQ implementation.


A JMS Session is absolutely single threaded. As such, it can only have one active receiver. You have 2 options:

  1. Use one connection with multiple sessions, each session having a receiver. Connections are thread safe and you can create many sessions from that single connections.
  2. ActiveMQ gives you a number of options regarding multiplexing multiple destinations, so rather than having multiple receivers, you might want to focus on one, but use ActiveMQ's facilities to create virtual destinations that will funnel all the messages you want through the one receiver.

See this question.

0

精彩评论

暂无评论...
验证码 换一张
取 消