Java the most common interview questions: Module fourteen

Fourteen, RabbitMQ

 

135. rabbitmq usage scenarios What?

 

①. Asynchronous communication across systems, all require asynchronous interaction where you can use the message queue. In addition, as we call (synchronous), we also need to send text messages, e-mail (asynchronous) communication.

 

②. Coupling between the plurality of applications, since the message is language-independent and platform-independent, but is no longer semantically function calls, and therefore more suitable as an interface between a plurality of loosely coupled applications. Coupling based message queue, the sender and the recipient need not online at the same time. In the Enterprise Application Integration (EAI), a file transfer, shared databases, message queues, remote procedure calls can be used as an integrated approach.

 

③. Synchronous variation in the application step, such as order processing, can be applied to the front end of order information in a queue, the rear end of message processing application obtains from the queue sequentially, when the large number of orders in the queue backlog peak can be disposed slowly . Since the synchronization usually means blocking and the blocked large number of threads will reduce the performance of your computer.

 

④. Message Driven Architecture (EDA), the system is decomposed into message queue, and message producers and message consumers, the process flow can be split into a plurality of stages (the Stage) if necessary, connected between the phase with the queue, a front stage of processing in the queue result, the stage acquires a message from the queue, processing continues.

 

⑤. Coupling applications require a more flexible way, such as publish and subscribe, for example you can specify the routing rules.

 

⑥. Across the LAN, even across the city communications (CDN industry), such as communication Beijing room with the application of Guangzhou room.

 

What are the important role 136. rabbitmq there?

 

RabbitMQ have an important role: producers, consumers and agents:

 

  • Manufacturer: creator of the message, is responsible for creating and push data to the message server;

  • Consumer: a message receiver for processing data and an acknowledgment message;

  • Agent: RabbitMQ is itself, for playing the role of "express" itself does not produce a message, just play the role of "Express" is.

 

What are the important components 137. rabbitmq there?

 

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

  • Channel (Channel): used in the feed channel message.

  • The Exchange (switch): for receiving, allocation message.

  • Queue (queue): storing a message producer.

  • RoutingKey (routing key): the data generator for assigning to the switch.

  • BindingKey (binding key): message for the exchanger bound to the queue.

 

What is the role 138. rabbitmq in vhost is?

 

vhost can be understood as a virtual broker, namely mini-RabbitMQ server. Inside it contains a separate queue, exchange and binding, etc., but the most important thing is that an independent authority system, the user can do to control vhost range. Of course, from a global perspective of RabbitMQ, vhost as a means of isolating different permissions (a typical example is different applications can run in different vhost). 

 

139. rabbitmq how news is sent?

 

First, the client must connect to RabbitMQ server to publish and consume messages, will create a tcp connection between the client and rabbit server, once tcp open and certified (certification that you sent to the user name and password rabbit server), you the client and RabbitMQ created a amqp channel (channel), the channel is to create a virtual connection in the "real" tcp, and amqp commands are through channel sent out, each channel will have a unique id, whether it is released message, the subscription queue are completed through this channel.

 

140. rabbitmq how to ensure the stability of the message?

 

  • It provides functionality affairs.

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

 

141. rabbitmq how to avoid message loss?

 

  1. News endurance of

  2. ACK acknowledgment mechanism

  3. Setting up a cluster mirror mode

  4. Message compensation mechanism

 

142. To ensure that the message persistence conditions for success are there?

 

  1. Statement queue must be set to persist durable set to true.

  2. Push message delivery persistent mode must be set, deliveryMode set to 2 (persistent).

  3. Message has arrived persistent switch.

  4. Message has arrived persistent queue.

 

These four conditions are met in order to ensure the message persistence to succeed.

 

143. rabbitmq persistence What are the disadvantages?

 

Persistent lack of land is to reduce the throughput of the server because of a disk instead of using memory storage, thereby reducing throughput. Ssd hard drive can make use of to alleviate the problem of throughput.

 

144. rabbitmq There are several types of broadcast?

 

Three kinds of broadcast mode:

 

  1. fanout: All bind to this exchange of queue can receive messages (pure broadcast, bind to RabbitMQ recipients can receive messages);

  2. direct: routingKey and can receive messages via the determined unique queue exchange;

  3. topic: All eligible routingKey (this case may be an expression) that bind to the routingKey may receive a message queue;

 

145. rabbitmq how to achieve delayed message queue?

 

  1. By entering the dead letter message expires switch, and then forwarded by the switch to the consumer queue delay, to achieve a delay function;

  2. Use RabbitMQ-delayed-message-exchange plug-in implementation delay function.

 

146. rabbitmq cluster what's the use?

 

Clustered mainly in the following two purposes:

 

  • Availability: a server problem, the entire RabbitMQ can continue to use;

  • High capacity: clusters can carry more information amount.

 

Type of node 147. rabbitmq What?

 

  • Disk node: the message will be stored to disk.

  • Memory Node: Messages are stored in memory, restart the server message loss, higher performance than disk type.

 

148. rabbitmq Cluster Setup what issues need attention?

 

  • Used between nodes "--link" connection, this attribute can not be ignored.

  • erlang cookie value of each node must use the same, this value corresponds to the "keys" function for authenticating each node.

  • The entire cluster must contain a disk node.

 

149. rabbitmq each node is a complete copy of the other nodes it? why?

 

No, for two reasons:

 

  1. Consider storage space: If each node has a complete copy of all the queues, so not only does not add nodes to add storage space, but adds more redundant data;

  2. Performance considerations: If you need a complete copy of each message to each cluster node, the new node that does not improve the ability to handle messages up to maintain the same performance of a single node or even worse.

 

150. rabbitmq cluster node only one disk crashes What happens?

 

If the only disk disk node crashes, you can not do the following:

 

  • You can not create a queue

  • You can not create exchanger

  • You can not create a binding

  • You can not add users

  • You can not change the permissions

  • You can not add and remove cluster nodes

 

The only disk node crashes, the cluster can be kept running, but you can not change anything.

 

151. rabbitmq cluster nodes stop order has requirements?

 

RabbitMQ cluster stop order is required, you should turn off the memory node, and finally close the disk nodes. If the order is just the opposite, it may cause loss of messages.

 

(Finish)

Guess you like

Origin www.cnblogs.com/xiaofengwang/p/11258155.html