In addition to Weibo, there is also WeChat
Please pay attention
WeChat public account
Shulou
2025-04-07 Update From: SLTechnology News&Howtos shulou NAV: SLTechnology News&Howtos > Internet Technology >
Share
Shulou(Shulou.com)06/02 Report--
This article introduces the relevant knowledge of "MQ underlying class MQClientInstance and ProcessQueue analysis". In the operation of actual cases, many people will encounter such a dilemma, so let the editor lead you to learn how to deal with these situations. I hope you can read it carefully and be able to achieve something!
Cornerstone MQClientInstance
The member variables of the DefaultMQProducerImpl, DefaultMQPullConsumerImpl, and DefaultMQPushConsumerImpl objects all contain the same member object:
Private MQClientInstance mQClientFactory;this.mQClientFactory = MQClientManager.getInstance () .getAndCreateMQClientInstance (this.defaultMQPushConsumer, this.rpcHook)
The MQClientInstance functions are as follows:
MQClientInstance is responsible for maintaining heartbeat by communicating with NameServer and obtaining Broker address according to Topic
MQClientInstance is responsible for communicating with Broker to send and receive messages and ReBalance.
In general, a production side or consumer side of RocketMQ, or a JVM process with only one MQClientInstance instance is sufficient. If you do not manually set it through setInstanceName, one or more Consumer or Producer layers created at this time all use the same MQClientInstance instance (the default name is "DEFAULT").
However, in some cases, only one MQClientInstance object is not enough. For example, a Java program needs to connect two MQ clusters, consume from one cluster and send it to another cluster, while a MQClientInstance object cannot support this scenario. In this case, you must manually specify a different InstanceName, and two MQClientInstance objects will be created at the bottom.
Public class MQClientManager {private static MQClientManager instance = new MQClientManager (); private AtomicInteger factoryIndexGenerator = new AtomicInteger (); private ConcurrentMap factoryTable = new ConcurrentHashMap ()
Generation rules for ClientId:
If there are multiple services integrated with MQ clients on the same machine, the process ID
MessageQueue's snapshot class ProcessQueue on the client side
Path: org.apache.rocketmq.client.impl.consumer
This is the end of the content of "MQ underlying class MQClientInstance and ProcessQueue analysis". Thank you for reading. If you want to know more about the industry, you can follow the website, the editor will output more high-quality practical articles for you!
Welcome to subscribe "Shulou Technology Information " to get latest news, interesting things and hot topics in the IT industry, and controls the hottest and latest Internet news, technology news and IT industry trends.
Views: 0
*The comments in the above article only represent the author's personal views and do not represent the views and positions of this website. If you have more insights, please feel free to contribute and share.
Continue with the installation of the previous hadoop.First, install zookooper1. Decompress zookoope
"Every 5-10 years, there's a rare product, a really special, very unusual product that's the most un
© 2024 shulou.com SLNews company. All rights reserved.