Change job interview and raise salary? Remember to rise 3k after reading! 2020 latest Java collection of common interview questions + detailed answers (12)

2020 latest Java collection of common interview questions + detailed answers (12)

Continue to update Java related materials. Recently, I have spent a few days consulting the latest interview news of the big bosses, trying to collect more comprehensive interview information. If you want to see the first few collections, you can go to my homepage to find them.

Some of the answers are summarized by myself, and some are collected on the Internet. Don't panic after watching these interviews! If you have more experience, you can share it in the comments. If you have any mistakes, you are welcome to point it out. Please let me know, thank you~

RabbitMQ

 

113. What are the usage scenarios of rabbitmq?

 

①. For cross-system asynchronous communication, message queues can be used wherever asynchronous interaction is required. Just like we need to send text messages and emails (asynchronous) in addition to calling (synchronous).

 

②. Coupling between multiple applications, because the message is platform-independent and language-independent, and semantically it is no longer a function call, so it is more suitable as a loosely coupled interface between multiple applications. Based on the coupling of message queues, the sender and receiver do not need to be online at the same time. In Enterprise Application Integration (EAI), file transfers, shared databases, message queues, and remote procedure calls can all be used as integration methods.

 

③. Synchronous to asynchronous in the application, such as order processing, the front-end application can put the order information in the queue, and the back-end application can obtain the message processing from the queue in turn. A large number of orders at peak times can be slowly processed in the queue. . Because synchronization usually means blocking, and the blocking of a large number of threads will reduce the performance of the computer.

 

④. Message-driven architecture (EDA), the system is decomposed into message queues, message producers and message consumers, a processing process can be divided into multiple stages (Stage) as needed, and the stages are connected by queues, the previous one The result of the stage processing is put into the queue, and the latter stage gets the message from the queue to continue processing.

 

⑤. Applications need more flexible coupling methods, such as publish and subscribe, for example, routing rules can be specified.

 

⑥. Cross-LAN, even cross-city communication (CDN industry), such as the communication between Beijing computer room and Guangzhou computer room.

 

114. What are the important roles of rabbitmq?

 

The important roles in RabbitMQ are: producer, consumer and agent:

 

  • Producer: The creator of the message, responsible for creating and pushing data to the message server;

  • Consumer: The recipient of the message, used to process data and confirm the message;

  • Agent: It is RabbitMQ itself, used to play the role of "express", it does not produce messages, but only plays the role of "express".

 

115. What are the important components of rabbitmq?

 

  • ConnectionFactory (connection manager): The manager that establishes the connection between the application and Rabbit, used in the program code.

  • Channel: The channel used for message push.

  • Exchange: used to receive and distribute messages.

  • Queue: Used to store messages from producers.

  • RoutingKey (routing key): used to distribute the generator's data to the switch.

  • BindingKey (binding key): used to bind the exchange's message to the queue.

 

116. What is the role of vhost in rabbitmq?

 

vhost can be understood as a virtual broker, namely mini-RabbitMQ server. All of them contain independent queues, exchanges, bindings, etc., but the most important thing is that they have an independent permission system that can be controlled by users within the vhost range. Of course, from the overall perspective of RabbitMQ, vhost can be used as a means of isolating different permissions (a typical example is that different applications can run in different vhosts). 

 

117. How are rabbitmq's messages sent?

 

First, the client must connect to the RabbitMQ server to publish and consume messages. A tcp connection will be created between the client and the rabbit server. Once tcp is opened and authenticated (authentication is the username and password you send to the rabbit server), your The client and RabbitMQ create an amqp channel (channel), which is a virtual connection created on the "real" tcp, amqp commands are sent out through the channel, and each channel will have a unique id, whether it is released Messages and subscription queues are all completed through this channel.

 

118. How does rabbitmq ensure the stability of the message?

 

  • Provides transaction functions.

  • By setting the channel to confirm (confirm) mode.

 

119. How does rabbitmq avoid message loss?

 

  1. Information endurance

  2. ACK confirmation mechanism

  3. Set cluster mirroring mode

  4. Message compensation mechanism

 

120. What are the conditions to ensure the success of message persistence?

 

  1. Declare that the queue must be set persistent and durable to true.

  2. The message push delivery mode must be set to persistence, and deliveryMode is set to 2 (persistent).

  3. The message has arrived at the persistent exchange.

  4. The message has reached the persistent queue.

 

The above four conditions are met to ensure the success of message persistence.

 

121. What are the disadvantages of rabbitmq persistence?

 

The shortcoming of persistence is to reduce the throughput of the server, because the use of disk instead of memory storage, thereby reducing throughput. You can try to use ssd hard drives to alleviate throughput problems.

 

122. How many broadcast types does rabbitmq have?

 

Three broadcast modes:

 

  1. fanout: All queues bound to this exchange can receive messages (pure broadcast, recipients bound to RabbitMQ can receive messages);

  2. direct: The only queue determined by routingKey and exchange can receive messages;

  3. topic: All queues bound by the routingKey that conform to the routingKey (which can be an expression at this time) can receive messages;

123. How does rabbitmq implement delayed message queue?

 

  1. After the message expires, it enters the dead letter exchange, and then is forwarded to the delayed consumption queue by the exchange to realize the delay function;

  2. Use RabbitMQ-delayed-message-exchange plug-in to realize the delay function.

 

124. What is the use of rabbitmq cluster?

 

The cluster has the following two main purposes:

 

  • High availability: If a server fails, the entire RabbitMQ can still be used;

  • High capacity: The cluster can carry more messages.

 

125. What are the types of rabbitmq nodes?

 

  • Disk node: The message will be stored on disk.

  • Memory node: Messages are stored in memory, and messages are lost when restarting the server, and the performance is higher than that of disk types.

 

126. What issues should be paid attention to when building rabbitmq cluster?

 

  • Use "--link" connection between nodes, this attribute cannot be ignored.

  • The value of the erlang cookie used by each node must be the same. This value is equivalent to the function of a "secret key" and is used for authentication of each node.

  • The entire cluster must contain one disk node.

 

127. Is each node of rabbitmq a complete copy of other nodes? why?

 

No, there are two reasons:

 

  1. Storage space considerations: If each node has a complete copy of all queues, the newly added nodes will not add storage space, but will increase more redundant data;

  2. Performance considerations: If each message needs to be copied to each cluster node in its entirety, the newly added node does not improve the ability to process messages. At most, it maintains the same performance as a single node or even worse.

 

128. What happens if the only disk node in the rabbitmq cluster crashes?

 

If the disk node of the only disk crashes, the following operations cannot be performed:

 

  • Cannot create queue

  • Can't create switch

  • Could not create binding

  • Cannot add user

  • Cannot change permissions

  • Cannot add and delete cluster nodes

 

The only disk node crashed, the cluster can keep running, but you can't change anything.

 

129. Does rabbitmq have any requirements for the stopping order of cluster nodes?

 

RabbitMQ has requirements on the sequence of stopping the cluster. You should shut down the memory node first, and then shut down the disk node. If the order is exactly the opposite, the message may be lost.

At last

The content of the interview questions is over here, there will be more updates in the follow-up, I hope it will be helpful to everyone.

Finally, I want to say something to you. I have worked for so many years and have interviewed some people for others. Whether it is from the perspective of the interviewer or the leader, in addition to interview skills and experience, great technology and project experience are also their trump cards and confidence. Core technology sharing of first-tier manufacturers

 It took me a long time to sort out some learning materials. What I posted above is the tip of the iceberg in the materials. I hope I can help you! Click to learn the secret code together: csdn

                         

  I will share more pure dry goods articles in the follow-up, and hope to really help you. Your support is my biggest motivation! Welcome to follow and like!

                                                       

Guess you like

Origin blog.csdn.net/weixin_50333534/article/details/108968237