ActiveMQ 线程机制.doc

上传人:文库蛋蛋多 文档编号:2396977 上传时间:2023-02-17 格式:DOC 页数:4 大小:221.50KB
返回 下载 相关 举报
ActiveMQ 线程机制.doc_第1页
第1页 / 共4页
ActiveMQ 线程机制.doc_第2页
第2页 / 共4页
ActiveMQ 线程机制.doc_第3页
第3页 / 共4页
ActiveMQ 线程机制.doc_第4页
第4页 / 共4页
亲,该文档总共4页,全部预览完了,如果喜欢就下载吧!
资源描述

《ActiveMQ 线程机制.doc》由会员分享,可在线阅读,更多相关《ActiveMQ 线程机制.doc(4页珍藏版)》请在三一办公上搜索。

1、Understanding the Threads Allocated in ActiveMQ Attachments:6 Added by Hiram Chirino, last edited by Rich Petersen on Dec 18, 2007 (view change) One of the easiest ways to tune an ActiveMQ deployment to increase scaleability is reduce the number of threads used to get the work done. The default Acti

2、veMQ configuration makes use of several threads to isolate producers from consumers. This prevents a producer from blocking when a consumer is misbehaving. The following diagram shows the threads involved in the typical process of sending a message from a producer application to a consumer applicati

3、on.ActiveMQ has several options that change the way threads are used and allocated. Understanding these options and knowing how they can impact the system will help you know if they are safe to enable on your system to reduce the number of threads used and thereby increase scaleability.For example,

4、the default configuration of the VM transport allocates a Transport Thread which polls for messages from the transport and delivers them to the connection. The VM transport considers this async delivery of messages. Since the VM transport connects to its transport peer within the same JVM, its possi

5、ble to use the calling transports thread to deliver the message to connection instead of using the polling thread. When the aysnc=false option is used, the threads in the system look like the following diagram.The broker uses a Dispatch Thread when sending messages to another connection. This isolat

6、es the producers Application Thread from any problems that may occur with the consumers connection. The dispatching of a message over Transport can be a blocking operation if there are problems with the network connection or if the client is misbehaving. The broker avoids blocking the producers thre

7、ad even when the consumers connection is blocked by using this Dispatch Thread.The broker supports an option to avoid using the Dispatch Thread and instead have the producers Transport Thread directly send the message over the consumers transport. This option should only be used when either you dont

8、 mind blocking the producer when a consumer problem occurs or you know you wont have consumer problems. This option can be enabled per consumer by setting dispatchAsync=false. The thread usage diagram for this option is shown below:If you look at the consumer JVM, you see at least 2 threads when you

9、 create a consumer that uses a MessageListener. The first thread is the Transport Thread which polls and delivers messages from the underlying network. The second thread is the Session Thread which delivers the message to the MessageListener and processed the message. By using a Session Thread, Acti

10、veMQ frees up the Transport Thread to continue to receive more messages from the network.ActiveMQ has an option that can disable the creation and use of the Session Thread. When the optimizedDispatch=true option is enabled, the Transport Thread deliver the message directly to the MessageListener for

11、 processing. I would only recommend that this be used for simple MessageListeners that do not send messages back into the JMS system and which execute quickly. Please note that if you have multiple sessions, the consumers in each session will be serviced by a single Transport Thread, which makes the system less concurrent. The thread usage diagram for this option is shown below: If you combine all the options listed above it is possible to achieve Straight Through Processing (STP), which can be a VERY performant way to process messages.Labels parameters

展开阅读全文
相关资源
猜你喜欢
相关搜索

当前位置:首页 > 建筑/施工/环境 > 项目建议


备案号:宁ICP备20000045号-2

经营许可证:宁B2-20210002

宁公网安备 64010402000987号