JMS QueueSender线程安全吗? [英] Is the JMS QueueSender thread safe?

查看:347
本文介绍了JMS QueueSender线程安全吗?的处理方法,对大家解决问题具有一定的参考价值,需要的朋友们下面随着小编来一起学习吧!

问题描述

我想在多线程环境中使用QueueSender。

I want to use a QueueSender in a multi-threaded environment.

QueueSender.send()线程安全?

推荐答案

不, MessageProducer / QueueSender 不是线程安全的。

No, a MessageProducer/QueueSender is not thread safe.

或者更具体地说: Session 不是线程安全的。 Session 的JavaDoc在第一句中明确提到:

Or more specifically: The Session is not thread safe. The JavaDoc for Session explicitly mentions this in its first sentence:


一个Session对象是用于生成和使用消息的单线程上下文。

A Session object is a single-threaded context for producing and consuming messages.

并且因为 MessageProducer / QueueSender 绑定到会话您不能同时在多个线程中使用它。实际上你不能在不同的时间从两个不同的线程中使用它!

And since a MessageProducer/QueueSender is bound to a Session you must not use it from more than one thread at the same time. In fact you must not use it from two different threads at different times either!

这篇关于JMS QueueSender线程安全吗?的文章就介绍到这了,希望我们推荐的答案对大家有所帮助,也希望大家多多支持IT屋!

查看全文
登录 关闭
扫码关注1秒登录
发送“验证码”获取 | 15天全站免登陆