Find centralized, trusted content and collaborate around the technologies you use most.
Teams
Q&A for work
Connect and share knowledge within a single location that is structured and easy to search.
JMSの単一セッションに複数MessageProducerを設定して各MessageProducer並列を使用できますか?
MessageProducer
例えば:
p1= Session.createProducer(Queue1); p2= Session.createProducer(Queue2); thread1() { p1.send(); } thread2() { p2.send(); }
Session、MessageProducer、MessageConsumer はスレッドセーフではありません。スレッドごとに個別のセッションを用意することをお勧めします。
さまざまなスレッドで同じ Session オブジェクトを使用しようとしています。回避できない場合 (そのようなユースケースが思いつかない場合) は、(標準の Java 同期メカニズムを介して) 自分でスレッドの安全性を確保する必要があります。
Connection と ConnectionFactory はスレッドセーフです。