30 Rocket Mq Learning Methods My Perspective

30 RocketMQ Learning Methods - My Perspective #

Dear readers, the content of the RocketMQ practical album is about to be updated. The previous chapters mainly introduced the RocketMQ technology itself. In this article, I would like to talk about how I learned RocketMQ and try to provide some guidance.

I believe we all have a consensus: theory alone is not enough, practical experience is crucial. This is true to some extent, but it should not become a reason for us to give up learning. When it comes to learning new knowledge, it is indeed advisable to prioritize learning technologies commonly used in our work. For example, if we take microservices as an example, Spring Cloud is currently very popular in the market. But if your company mainly uses Dubbo, I would suggest prioritizing learning Dubbo when you want to delve into microservices. Because you have practical experience, in-depth study of Dubbo can better guide your practice, achieving a combination of theory and practice. Moreover, Dubbo is widely used in the market.

However, sometimes we are limited by the platform we are on and cannot access mainstream technologies in our daily work. For example, we may lack exposure to high concurrency and have never used message queues. In such cases, what should we do?

Here is my personal advice: when you are unable to use a technology in practice, you should study the principles of mainstream technologies, prepare yourself for future use, and not give up on learning just because you haven’t had the opportunity to use them yet. Opportunities come to those who are prepared. When you have a certain depth of understanding in a particular technology, you can immediately apply your talents when the project requires it, making it easier to stand out.

Before I started learning RocketMQ, I had never come across any message queues in my actual work, let alone used them. The reason why I started learning RocketMQ was that I learned it had been donated to the Apache Software Foundation, and I also heard that RocketMQ supported the huge traffic of Alibaba’s Double 11 event. This made me curious and eager to witness the performance of a high-performance distributed message queue. From then on, I embarked on the journey of learning RocketMQ.

Once you have set your goals, how should you go about learning RocketMQ?

1. Read the RocketMQ official design specifications

When starting to learn an open-source framework or product, I suggest you first visit its official website and read its user manual and design specifications. This will provide you with an understanding of what problems the framework solves, its basic principles, and the knowledge points it covers (which you can subsequently break through one by one). This will help you grasp the middleware framework on a global level. I still remember vividly that when I was reading the RocketMQ design specifications, not only did I gain a thorough understanding of some of its concepts, but some “advanced” terms related to performance also deeply attracted me, such as:

  • Ability to handle billions of messages
  • Memory mapping and page cache
  • Zero-copy
  • Sync flushing and async flushing
  • Sync replication and async replication
  • Hash indexing

After reading the design specifications, I became greatly interested and determined to study RocketMQ in-depth from the source code perspective. I set a goal to not only understand the working principles and implementation details of RocketMQ, but also to understand the design philosophy of file-based programming and how to use memory mapping in practice.

2. Download the source code and run the demos

Every open-source framework provides comprehensive test cases, and RocketMQ is no exception. Within the RocketMQ source code, there is a separate module called “example,” containing many usage demos. Running some test cases as needed will help you grasp the basic usage of RocketMQ and be considered as taking a step inside.

3. Dig into the RocketMQ source code

By following the previous two steps, you will have a comprehensive understanding of its design principles and have mastered the basic usage of RocketMQ. The next step is to delve deeper into RocketMQ, especially if you have carefully read all the practical articles in this column. It is time to study the source code.

I believe there are several benefits to studying the principles of RocketMQ:

  • Deeply studying its implementation principles helps you have a more systematic understanding of RocketMQ, allowing you to have better control over it. Usually, when using a message queue, if a failure occurs, it can cause significant damage to a company’s business. While quickly fixing the problem is important, it is even more valuable to be able to anticipate risks and prevent production failures. To be able to anticipate risks, it is essential to have a systematic study of RocketMQ.
  • Learning from the excellent RocketMQ framework can enhance your programming skills. For example, we can gain insights into techniques related to high concurrency and file-based programming.

Now, how should you read the RocketMQ source code?

Before diving into the source code, it is necessary to have some basic knowledge. I suggest that before reading RocketMQ’s source code, you should first try to read the source code of Java data structures, such as HashMap and ArrayList. The main purpose of this is to develop your own method of reading source code. Usually, my approach to reading source code is to first understand the main process, and then explore the branching processes.

Let me give you a simple example to illustrate the process of understanding the main process first and then exploring the branching processes.

For example, when I was learning about the message sending process, I only focused on the client-side process of message sending. As for the operations performed by the server when receiving a message sending request, such as storage, replication, and flushing, I did not pay attention to them for the time being. For now, I focused on the design of message sending on the client-side. Once I understand this part, I move on to understanding the operations performed by the server when receiving a message sending request, such as message storage, flushing, and replication. This systematic approach helps me unravel the core design principles of RocketMQ in an organized manner.