Network Security Internet Technology Development Database Servers Mobile Phone Android Software Apple Software Computer Software News IT Information

In addition to Weibo, there is also WeChat

Please pay attention

WeChat public account

Shulou

What are the ActiveMQ interview questions and answers?

2025-04-06 Update From: SLTechnology News&Howtos shulou NAV: SLTechnology News&Howtos > Internet Technology >

Share

Shulou(Shulou.com)05/31 Report--

This article mainly introduces the relevant knowledge of "ActiveMQ interview questions and answers". The editor shows you the operation process through actual cases. The operation method is simple, fast and practical. I hope this article "what are the ActiveMQ interview questions and answers" can help you solve the problem.

1. What is ActiveMQ?

ActiveMQ is an open source, message-oriented middleware that implements the JMS1.1 specification and provides efficient, scalable, stable and secure enterprise message communication for applications.

2. The bottleneck value of Activemq

According to the general online evaluation documents, the throughput of messages per second is more than 2000, and acticemq can also be deployed in clusters, which is also built using zookeeper.

3. What if the ActiveMQ server goes down?

It starts with the storage mechanism of ActiveMQ. In general, non-persistent messages are stored in memory, persistent messages are stored in files, and their maximum limits are configured in the nodes of the configuration file.

However, when non-persistent messages pile up to a certain extent and memory runs out, ActiveMQ writes non-persistent messages in memory to temporary files to free up memory. Although it is saved to a file, the difference between it and persistent messages is that persistent messages will be restored from the file after restart, and non-persistent temporary files will be deleted directly.

So what happens when the file size reaches the maximum limit in the configuration? I did the following experiments:

Set a persistent file limit of about 2G and mass produce persistent messages until the file reaches the maximum limit, when the producer blocks, but the consumer can connect and consume the message normally. After some of the message is consumed and the file is deleted, the producer can continue to send the message, and the service automatically returns to normal.

Set a temporary file limit of about 2G, mass produce non-persistent messages and write temporary files. When the maximum limit is reached, producers block, consumers can connect normally but cannot consume messages, or consumers who used to consume slowly, consumption stops suddenly. The whole system can be connected, but it can't provide service, so it just hung up.

The specific reason is unknown, the solution: try not to use non-persistent messages, if necessary, increase the temporary file limit as much as possible.

4. The function and principle of AcitveMQ? (producers, consumers. P2P, subscription implementation process)

The function of Activemq is to communicate between systems. Of course, we can use other ways to communicate between systems. if we use Activemq, we can decouple the calls between systems and realize the asynchronous communication between systems. The principle is that the producer produces the message and sends it to the activemq. Activemq receives the message, then looks at how many consumers there are, and then forwards the message to the consumer without the involvement of the producer. It has nothing to do with the producer to deal with the consumer after receiving the message.

5. How to apply activemq in the project

The main purpose of Activemq in the project is to complete the communication between systems and decouple the calls between systems. For example, after adding and modifying commodity information, it is necessary to synchronize the commodity information to the index database, synchronize the data in the cache and generate static pages.

You can use activemq in this scenario. Once the commodity information is modified in the background, a message is sent to activemq, and then the message is sent to the consumer side of the message through activemq, and the consumer side receives the message for corresponding business processing.

7. How does rabbitmq achieve high availability of clusters?

Clustering is a way to ensure the reliability of services, and it can also scale horizontally to improve message throughput. RabbitMQ is developed in the distributed programming language erlang, so it naturally supports clustering. Next, we will introduce the RabbitMQ distributed message processing method, cluster mode, node type, and build a high-availability cluster environment. Finally, we will verify the high availability of the cluster through java programs.

There are three ways of RabbitMQ distributed message processing:

(1) Clustering: cross-network segment is not supported. Each node needs to run the same version of Erlang and RabbitMQ, which is applied to the local area network of the same network segment.

(2) Federation: allows Exchange or Queue on a single server to receive messages posted to Exchange or Queue on another server and apply them to the WAN.

(3) Shovel: similar to Federation but working at a lower level.

RabbitMQ is sensitive to network latency, and clustering is recommended in LAN environments; in WAN environments, Federation or Shovel is used. When we talk about RabbitMQ cluster, we are talking about clustering mode, which is a message processing method embedded in RabbitMQ, while Federation or Shovel exists in the form of plugin.

8. What should I do if I lose the news?

This starts with the java.net.SocketException exception in java. To put it simply, when the network sender sends a pile of data and then calls close to close the connection. The data sent is in the receiver's cache, and the receiver can still read the data from the cache if the receiver calls the read method, even though the other party has closed the connection.

But when the receiver tries to send data, it is understandable that an exception occurs because the connection is closed. However, it should be noted that when SocketException occurs, the data in the original cache is also invalidated, and when the receiver calls the read method again to read the data in the cache, it will report a Software caused connection abort: recv failed error.

By grabbing the packet, ActiveMQ will send a heartbeat every 10 seconds, which is sent by the server to the client to determine whether the client is dead or not. If you look at the first above, you will know that non-persistent messages will be written to the file to a certain extent, and this writing process will block all actions, last 20 to 30 seconds, and increase as the memory increases.

When the client calls connection.close () after sending a message, it expects the server's answer to close the connection. If it doesn't answer for more than 15 seconds, it directly calls close in the socket layer to close the tcp connection. At this time, the messages sent by the client are still waiting to be processed in the server's cache, but due to the setting of the server's heartbeat packet, a java.net.SocketException exception occurs, invalidating the data in the cache and losing all unprocessed messages.

Solution: use persistent messages, or non-persistent messages to deal with timely do not pile up, or start a transaction, after starting the transaction, the commit () method will responsibly wait for the return of the server, and will not close the connection and cause the message to be lost.

This is the end of the content about "ActiveMQ interview questions and answers". Thank you for your reading. If you want to know more about the industry, you can follow the industry information channel. The editor will update different knowledge points for you every day.

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.

Share To

Internet Technology

Wechat

© 2024 shulou.com SLNews company. All rights reserved.

12
Report