Single queue: concurrent message processing with multiple consumers

后端 未结 3 1579
庸人自扰
庸人自扰 2021-01-22 01:12

I am new to jms. The goal is to process messages concurrently from a queue in an asynchronous listener\'s onMessage method by attaching a listener instance to multiple consume

3条回答
  •  星月不相逢
    2021-01-22 01:41

    1. Yes absolutely
    2. I only took a brief look and I noticed that you pass the wrong consumer to your second thread:

      Thread newThread2 = new Thread(consumer1); // has to pass consumer2
      

      beside of this, some variables such as ConnectionFactory are static and initialized multiple times/overriden. You only need one connection that could create multiple sessions and/or consumers.

提交回复
热议问题