Catalog

  • One 、RabbitMQ Entry procedure
  • Two 、Work queues Working mode
  • 3、 ... and 、Publish / Subscribe Release / A subscription model
  • Four 、Routing Routing mode
  • 5、 ... and 、Topics
  • 6、 ... and 、Header
  • 7、 ... and 、RPC
  • 8、 ... and 、Spring Data Elasticsearch

One 、RabbitMQ Entry procedure

<dependencies>
<dependency>
<groupId>org.springframework.boot</groupId>
<artifactId>spring-boot-starter-amqp</artifactId>
</dependency>
<dependency>
<groupId>org.springframework.boot</groupId>
<artifactId>spring-boot-starter-test</artifactId>
</dependency> <dependency>
<groupId>org.springframework.boot</groupId>
<artifactId>spring-boot-starter-logging</artifactId>
</dependency>
</dependencies>

application.yml

server:
port: 44000
spring:
application:
name: test-rabbitmq-producer
rabbitmq:
username: guest
password: guest
host: 127.0.0.1
port: 5672
virtual-host: /

Message sender

/**
* Description: rabbitmq Entry procedure
*
* @author zygui
* @date Created on 2020/5/13 15:34
*/
public class Producer01 { // Declare a message queue name
private static final String QUEUE_NAME = "helloworld"; public static void main(String[] args) {
// Create new connections with the connection factory mq Establishing a connection
ConnectionFactory connectionFactory = new ConnectionFactory();
connectionFactory.setHost("127.0.0.1");
connectionFactory.setPort(5672);
connectionFactory.setUsername("guest");
connectionFactory.setPassword("guest");
// Set up virtual machine , One mq Services can set up multiple virtual machines , Each virtual machine is equivalent to an independent mq
connectionFactory.setVirtualHost("/"); // The default is / that will do // Establishing a connection
Connection connection = null;
// Set up a channel ( The purpose is to reuse the connection )
Channel channel = null;
try { // Build new connections
connection = connectionFactory.newConnection();
// Create a session channel , Producers and mq Service all communications are in channel Done in the channel
channel = connection.createChannel(); // Declaration queue , If the queue is in mq If not, create
// Parameters :String queue, boolean durable, boolean exclusive, boolean autoDelete, Map<String, Object> arguments
/**
* Parameter details
* 1、queue Queue name
* 2、durable Persistent or not , If you persist ,mq After the restart, the queue is still
* 3、exclusive Whether the connection is exclusive , The queue is only allowed access in this connection , If connection When the connection is closed, the queue will be deleted automatically , If you set this parameter true Can be used to create temporary queues
* 4、autoDelete Automatically delete , Whether to automatically delete the queue when it is no longer in use , If you add this parameter to exclusive Parameter set to true The temporary queue can be implemented ( The queue is automatically deleted when it is not in use )
* 5、arguments Parameters , You can set the extension parameters of a queue , such as : The survival time can be set
*/
channel.queueDeclare(QUEUE_NAME,true,false,false,null); // Send a message
// Parameters :String exchange, String routingKey, BasicProperties props, byte[] body
/**
* Parameter details :
* 1、exchange, Switch , If not specified mq The default switch for ( Set to "")
* 2、routingKey, route key, Switch according to route key To forward the message to the specified queue , If you use the default switch ,routingKey Set to the name of the queue
* 3、props, The properties of the message
* 4、body, The message content
*/
// The message content
String message = "hello world GUI Chaoyang ";
channel.basicPublish("",QUEUE_NAME,null,message.getBytes());
System.out.println("send to mq "+message); } catch (Exception e) {
e.printStackTrace();
} finally { try {
// Turn off the channel
channel.close();
// Close the connection
connection.close(); } catch (Exception e) {
e.printStackTrace();
}
}
}
}

Message Receiver

/**
* Description: rabbitmq Entry procedure
*
* @author zygui
* @date Created on 2020/5/13 15:45
*/
public class Consumer01 { private static final String QUEUE_NAME = "helloworld"; public static void main(String[] args) throws IOException, TimeoutException { // Create new connections and mq Establishing a connection
ConnectionFactory connectionFactory = new ConnectionFactory();
connectionFactory.setHost("127.0.0.1");
connectionFactory.setPort(5672);// port
connectionFactory.setUsername("guest");
connectionFactory.setPassword("guest");
// Set up virtual machine , One mq Services can set up multiple virtual machines , Each virtual machine is equivalent to an independent mq
connectionFactory.setVirtualHost("/"); // Build new connections
Connection connection = connectionFactory.newConnection();
// Create a session channel , Producers and mq Service all communications are in channel Done in the channel
Channel channel = connection.createChannel(); // Listening to the queue
// Declaration queue , If the queue is in mq If not, create
// Parameters :String queue, boolean durable, boolean exclusive, boolean autoDelete, Map<String, Object> arguments
/**
* Parameter details
* 1、queue Queue name
* 2、durable Persistent or not , If you persist ,mq After the restart, the queue is still
* 3、exclusive Whether the connection is exclusive , The queue is only allowed access in this connection , If connection When the connection is closed, the queue will be deleted automatically , If you set this parameter true Can be used to create temporary queues
* 4、autoDelete Automatically delete , Whether to automatically delete the queue when it is no longer in use , If you add this parameter to exclusive Parameter set to true The temporary queue can be implemented ( The queue is automatically deleted when it is not in use )
* 5、arguments Parameters , You can set the extension parameters of a queue , such as : The survival time can be set
*/
channel.queueDeclare(QUEUE_NAME,true,false,false,null); // Realize the consumption method
DefaultConsumer defaultConsumer = new DefaultConsumer(channel) { /**
* When the message is received, this method will be called
* @param consumerTag Consumer labels , Used to identify consumers , Set when listening to the queue channel.basicConsume
* @param envelope The envelope , adopt envelope
* @param properties Message properties
* @param body The message content
* @throws IOException
*/
@Override
public void handleDelivery(String consumerTag, Envelope envelope, AMQP.BasicProperties properties, byte[] body) throws IOException {
// Switch
String exchange = envelope.getExchange();
// news id,mq stay channel Used to identify messages in id, Can be used to confirm that a message has been received
long deliveryTag = envelope.getDeliveryTag();
// The message content
String message= new String(body,"utf-8");
System.out.println("receive message:"+message);
}
}; // Listening to the queue
// Parameters :String queue, boolean autoAck, Consumer callback
/**
* Parameter details :
* 1、queue Queue name
* 2、autoAck Automatic recovery , When the consumer receives the message, he should tell mq Message received , If this parameter is set to tru It means that you will reply automatically mq, If set to false Reply by programming
* 3、callback, Consumption method , When the consumer receives the message, the method to be executed
*/
channel.basicConsume(QUEUE_NAME,true,defaultConsumer);
}
}

The steps to getting started

Two 、Work queues Working mode


3、 ... and 、Publish / Subscribe Release / A subscription model


Message producer

public class Producer02_publish {
// Queue name
private static final String QUEUE_INFORM_EMAIL = "queue_inform_email";
private static final String QUEUE_INFORM_SMS = "queue_inform_sms";
// Switch name
private static final String EXCHANGE_FANOUT_INFORM="exchange_fanout_inform"; public static void main(String[] args) {
// Create new connections and mq Establishing a connection
ConnectionFactory connectionFactory = new ConnectionFactory();
connectionFactory.setHost("127.0.0.1");
connectionFactory.setPort(5672);// port
connectionFactory.setUsername("guest");
connectionFactory.setPassword("guest");
// Set up virtual machine , One mq Services can set up multiple virtual machines , Each virtual machine is equivalent to an independent mq
connectionFactory.setVirtualHost("/"); Connection connection = null;
Channel channel = null;
try {
// Build new connections
connection = connectionFactory.newConnection();
// Create a session channel , Producers and mq Service all communications are in channel Done in the channel
channel = connection.createChannel();
// Declaration queue , If the queue is in mq If not, create
// Parameters :String queue, boolean durable, boolean exclusive, boolean autoDelete, Map<String, Object> arguments
/**
* Parameter details
* 1、queue Queue name
* 2、durable Persistent or not , If you persist ,mq After the restart, the queue is still
* 3、exclusive Whether the connection is exclusive , The queue is only allowed access in this connection , If connection When the connection is closed, the queue will be deleted automatically , If you set this parameter true Can be used to create temporary queues
* 4、autoDelete Automatically delete , Whether to automatically delete the queue when it is no longer in use , If you add this parameter to exclusive Parameter set to true The temporary queue can be implemented ( The queue is automatically deleted when it is not in use )
* 5、arguments Parameters , You can set the extension parameters of a queue , such as : The survival time can be set
*/
channel.queueDeclare(QUEUE_INFORM_EMAIL,true,false,false,null);
channel.queueDeclare(QUEUE_INFORM_SMS,true,false,false,null);
// Declare a switch
// Parameters :String exchange, String type
/**
* Parameter details :
* 1、 Name of switch
* 2、 Type of switch
* fanout: Corresponding rabbitmq The working mode of publish/subscribe
* direct: Corresponding Routing Working mode
* topic: Corresponding Topics Working mode
* headers: Corresponding headers Working mode
*/
channel.exchangeDeclare(EXCHANGE_FANOUT_INFORM, BuiltinExchangeType.FANOUT); // Switch and queue binding
// Parameters :String queue, String exchange, String routingKey
/**
* Parameter details :
* 1、queue Queue name
* 2、exchange Switch name
* 3、routingKey route key, The function of the switch is based on routing key Forward the message to the specified queue , In the publish subscribe mode, the mediation is an empty string
*/
channel.queueBind(QUEUE_INFORM_EMAIL,EXCHANGE_FANOUT_INFORM,"");
channel.queueBind(QUEUE_INFORM_SMS,EXCHANGE_FANOUT_INFORM,"");
// Send a message
// Parameters :String exchange, String routingKey, BasicProperties props, byte[] body
/**
* Parameter details :
* 1、exchange, Switch , If not specified mq The default switch for ( Set to "")
* 2、routingKey, route key, Switch according to route key To forward the message to the specified queue , If you use the default switch ,routingKey Set to the name of the queue
* 3、props, The properties of the message
* 4、body, The message content
*/
for(int i=0;i<5;i++){
// The message content
String message = "send inform message to user";
channel.basicPublish(EXCHANGE_FANOUT_INFORM,"",null,message.getBytes());
System.out.println("send to mq "+message);
} } catch (Exception e) {
e.printStackTrace();
} finally {
// Close the connection
// Close the channel first
try {
channel.close();
} catch (IOException e) {
e.printStackTrace();
} catch (TimeoutException e) {
e.printStackTrace();
}
try {
connection.close();
} catch (IOException e) {
e.printStackTrace();
}
} }
}

Message Receiver 1

public class Consumer02_subscribe_email {
// Queue name
private static final String QUEUE_INFORM_EMAIL = "queue_inform_email";
private static final String EXCHANGE_FANOUT_INFORM="exchange_fanout_inform"; public static void main(String[] args) throws IOException, TimeoutException {
// Create new connections and mq Establishing a connection
ConnectionFactory connectionFactory = new ConnectionFactory();
connectionFactory.setHost("127.0.0.1");
connectionFactory.setPort(5672);// port
connectionFactory.setUsername("guest");
connectionFactory.setPassword("guest");
// Set up virtual machine , One mq Services can set up multiple virtual machines , Each virtual machine is equivalent to an independent mq
connectionFactory.setVirtualHost("/"); // Build new connections
Connection connection = connectionFactory.newConnection();
// Create a session channel , Producers and mq Service all communications are in channel Done in the channel
Channel channel = connection.createChannel(); /**
* Parameter details
* 1、queue Queue name
* 2、durable Persistent or not , If you persist ,mq After the restart, the queue is still
* 3、exclusive Whether the connection is exclusive , The queue is only allowed access in this connection , If connection When the connection is closed, the queue will be deleted automatically , If you set this parameter true Can be used to create temporary queues
* 4、autoDelete Automatically delete , Whether to automatically delete the queue when it is no longer in use , If you add this parameter to exclusive Parameter set to true The temporary queue can be implemented ( The queue is automatically deleted when it is not in use )
* 5、arguments Parameters , You can set the extension parameters of a queue , such as : The survival time can be set
*/
channel.queueDeclare(QUEUE_INFORM_EMAIL,true,false,false,null);
// Declare a switch
// Parameters :String exchange, String type
/**
* Parameter details :
* 1、 Name of switch
* 2、 Type of switch
* fanout: Corresponding rabbitmq The working mode of publish/subscribe
* direct: Corresponding Routing Working mode
* topic: Corresponding Topics Working mode
* headers: Corresponding headers Working mode
*/
channel.exchangeDeclare(EXCHANGE_FANOUT_INFORM, BuiltinExchangeType.FANOUT);
// Switch and queue binding
// Parameters :String queue, String exchange, String routingKey
/**
* Parameter details :
* 1、queue Queue name
* 2、exchange Switch name
* 3、routingKey route key, The function of the switch is based on routing key Forward the message to the specified queue , In the publish subscribe mode, the mediation is an empty string
*/
channel.queueBind(QUEUE_INFORM_EMAIL, EXCHANGE_FANOUT_INFORM, ""); // Realize the consumption method
DefaultConsumer defaultConsumer = new DefaultConsumer(channel){ /**
* When the message is received, this method will be called
* @param consumerTag Consumer labels , Used to identify consumers , Set when listening to the queue channel.basicConsume
* @param envelope The envelope , adopt envelope
* @param properties Message properties
* @param body The message content
* @throws IOException
*/
@Override
public void handleDelivery(String consumerTag, Envelope envelope, AMQP.BasicProperties properties, byte[] body) throws IOException {
// Switch
String exchange = envelope.getExchange();
// news id,mq stay channel Used to identify messages in id, Can be used to confirm that a message has been received
long deliveryTag = envelope.getDeliveryTag();
// The message content
String message= new String(body,"utf-8");
System.out.println("receive message:"+message);
}
}; // Listening to the queue
// Parameters :String queue, boolean autoAck, Consumer callback
/**
* Parameter details :
* 1、queue Queue name
* 2、autoAck Automatic recovery , When the consumer receives the message, he should tell mq Message received , If this parameter is set to tru It means that you will reply automatically mq, If set to false Reply by programming
* 3、callback, Consumption method , When the consumer receives the message, the method to be executed
*/
channel.basicConsume(QUEUE_INFORM_EMAIL,true,defaultConsumer); }
}

Message Receiver 2

public class Consumer02_subscribe_sms {
// Queue name
private static final String QUEUE_INFORM_SMS = "queue_inform_sms";
private static final String EXCHANGE_FANOUT_INFORM="exchange_fanout_inform"; public static void main(String[] args) throws IOException, TimeoutException {
// Create new connections and mq Establishing a connection
ConnectionFactory connectionFactory = new ConnectionFactory();
connectionFactory.setHost("127.0.0.1");
connectionFactory.setPort(5672);// port
connectionFactory.setUsername("guest");
connectionFactory.setPassword("guest");
// Set up virtual machine , One mq Services can set up multiple virtual machines , Each virtual machine is equivalent to an independent mq
connectionFactory.setVirtualHost("/"); // Build new connections
Connection connection = connectionFactory.newConnection();
// Create a session channel , Producers and mq Service all communications are in channel Done in the channel
Channel channel = connection.createChannel(); /**
* Parameter details
* 1、queue Queue name
* 2、durable Persistent or not , If you persist ,mq After the restart, the queue is still
* 3、exclusive Whether the connection is exclusive , The queue is only allowed access in this connection , If connection When the connection is closed, the queue will be deleted automatically , If you set this parameter true Can be used to create temporary queues
* 4、autoDelete Automatically delete , Whether to automatically delete the queue when it is no longer in use , If you add this parameter to exclusive Parameter set to true The temporary queue can be implemented ( The queue is automatically deleted when it is not in use )
* 5、arguments Parameters , You can set the extension parameters of a queue , such as : The survival time can be set
*/
channel.queueDeclare(QUEUE_INFORM_SMS,true,false,false,null);
// Declare a switch
// Parameters :String exchange, String type
/**
* Parameter details :
* 1、 Name of switch
* 2、 Type of switch
* fanout: Corresponding rabbitmq The working mode of publish/subscribe
* direct: Corresponding Routing Working mode
* topic: Corresponding Topics Working mode
* headers: Corresponding headers Working mode
*/
channel.exchangeDeclare(EXCHANGE_FANOUT_INFORM, BuiltinExchangeType.FANOUT);
// Switch and queue binding
// Parameters :String queue, String exchange, String routingKey
/**
* Parameter details :
* 1、queue Queue name
* 2、exchange Switch name
* 3、routingKey route key, The function of the switch is based on routing key Forward the message to the specified queue , In the publish subscribe mode, the mediation is an empty string
*/
channel.queueBind(QUEUE_INFORM_SMS, EXCHANGE_FANOUT_INFORM, ""); // Realize the consumption method
DefaultConsumer defaultConsumer = new DefaultConsumer(channel){ /**
* When the message is received, this method will be called
* @param consumerTag Consumer labels , Used to identify consumers , Set when listening to the queue channel.basicConsume
* @param envelope The envelope , adopt envelope
* @param properties Message properties
* @param body The message content
* @throws IOException
*/
@Override
public void handleDelivery(String consumerTag, Envelope envelope, AMQP.BasicProperties properties, byte[] body) throws IOException {
// Switch
String exchange = envelope.getExchange();
// news id,mq stay channel Used to identify messages in id, Can be used to confirm that a message has been received
long deliveryTag = envelope.getDeliveryTag();
// The message content
String message= new String(body,"utf-8");
System.out.println("receive message:"+message);
}
}; // Listening to the queue
// Parameters :String queue, boolean autoAck, Consumer callback
/**
* Parameter details :
* 1、queue Queue name
* 2、autoAck Automatic recovery , When the consumer receives the message, he should tell mq Message received , If this parameter is set to tru It means that you will reply automatically mq, If set to false Reply by programming
* 3、callback, Consumption method , When the consumer receives the message, the method to be executed
*/
channel.basicConsume(QUEUE_INFORM_SMS,true,defaultConsumer); }
}

Four 、Routing Routing mode


Message producer

public class Producer03_routing {
// Queue name
private static final String QUEUE_INFORM_EMAIL = "queue_inform_email";
private static final String QUEUE_INFORM_SMS = "queue_inform_sms";
// Switch name
private static final String EXCHANGE_ROUTING_INFORM="exchange_routing_inform";
// Routing key name
private static final String ROUTINGKEY_EMAIL="inform_email";
private static final String ROUTINGKEY_SMS="inform_sms"; public static void main(String[] args) {
// Create new connections and mq Establishing a connection
ConnectionFactory connectionFactory = new ConnectionFactory();
connectionFactory.setHost("127.0.0.1");
connectionFactory.setPort(5672);// port
connectionFactory.setUsername("guest");
connectionFactory.setPassword("guest");
// Set up virtual machine , One mq Services can set up multiple virtual machines , Each virtual machine is equivalent to an independent mq
connectionFactory.setVirtualHost("/"); Connection connection = null;
Channel channel = null;
try {
// Build new connections
connection = connectionFactory.newConnection();
// Create a session channel , Producers and mq Service all communications are in channel Done in the channel
channel = connection.createChannel(); // Declaration queue , If the queue is in mq If not, create
// Parameters :String queue, boolean durable, boolean exclusive, boolean autoDelete, Map<String, Object> arguments
/**
* Parameter details
* 1、queue Queue name
* 2、durable Persistent or not , If you persist ,mq After the restart, the queue is still
* 3、exclusive Whether the connection is exclusive , The queue is only allowed access in this connection , If connection When the connection is closed, the queue will be deleted automatically , If you set this parameter true Can be used to create temporary queues
* 4、autoDelete Automatically delete , Whether to automatically delete the queue when it is no longer in use , If you add this parameter to exclusive Parameter set to true The temporary queue can be implemented ( The queue is automatically deleted when it is not in use )
* 5、arguments Parameters , You can set the extension parameters of a queue , such as : The survival time can be set
*/
channel.queueDeclare(QUEUE_INFORM_EMAIL,true,false,false,null);
channel.queueDeclare(QUEUE_INFORM_SMS,true,false,false,null); // Declare a switch
// Parameters :String exchange, String type
/**
* Parameter details :
* 1、 Name of switch
* 2、 Type of switch
* fanout: Corresponding rabbitmq The working mode of publish/subscribe
* direct: Corresponding Routing Working mode
* topic: Corresponding Topics Working mode
* headers: Corresponding headers Working mode
*/
channel.exchangeDeclare(EXCHANGE_ROUTING_INFORM, BuiltinExchangeType.DIRECT); // Switch and queue binding
// Parameters :String queue, String exchange, String routingKey
/**
* Parameter details :
* 1、queue Queue name
* 2、exchange Switch name
* 3、routingKey route key, The function of the switch is based on routing key Forward the message to the specified queue , In the publish subscribe mode, the mediation is an empty string
*/
channel.queueBind(QUEUE_INFORM_EMAIL,EXCHANGE_ROUTING_INFORM,ROUTINGKEY_EMAIL);
//channel.queueBind(QUEUE_INFORM_EMAIL,EXCHANGE_ROUTING_INFORM,"inform");
channel.queueBind(QUEUE_INFORM_SMS,EXCHANGE_ROUTING_INFORM,ROUTINGKEY_SMS);
//channel.queueBind(QUEUE_INFORM_SMS,EXCHANGE_ROUTING_INFORM,"inform"); // Send a message
// Parameters :String exchange, String routingKey, BasicProperties props, byte[] body
/**
* Parameter details :
* 1、exchange, Switch , If not specified mq The default switch for ( Set to "")
* 2、routingKey, route key, Switch according to route key To forward the message to the specified queue , If you use the default switch ,routingKey Set to the name of the queue
* 3、props, The properties of the message
* 4、body, The message content
*/
/* for(int i=0;i<5;i++){
// Specify when sending a message routingKey
String message = "send email inform message to user";
channel.basicPublish(EXCHANGE_ROUTING_INFORM,ROUTINGKEY_EMAIL,null,message.getBytes());
System.out.println("send to mq "+message);
}*/
for(int i=0;i<5;i++){
// Specify when sending a message routingKey
String message = "send sms inform message to user";
channel.basicPublish(EXCHANGE_ROUTING_INFORM,ROUTINGKEY_SMS,null,message.getBytes());
System.out.println("send to mq "+message);
} // At this point, the specified routing key is inform, So both consumers can consume
/*for(int i=0;i<5;i++){
// Specify when sending a message routingKey
String message = "send inform message to user";
channel.basicPublish(EXCHANGE_ROUTING_INFORM,"inform",null,message.getBytes());
System.out.println("send to mq "+message);
}*/ } catch (Exception e) {
e.printStackTrace();
} finally {
// Close the connection
// Close the channel first
try {
channel.close();
} catch (IOException e) {
e.printStackTrace();
} catch (TimeoutException e) {
e.printStackTrace();
}
try {
connection.close();
} catch (IOException e) {
e.printStackTrace();
}
}
}
}

Message Receiver 1

public class Consumer03_routing_email {
// Queue name
private static final String QUEUE_INFORM_EMAIL = "queue_inform_email";
// Switch name
private static final String EXCHANGE_ROUTING_INFORM="exchange_routing_inform";
// Routing key name
private static final String ROUTINGKEY_EMAIL="inform_email"; public static void main(String[] args) throws IOException, TimeoutException {
// Create new connections and mq Establishing a connection
ConnectionFactory connectionFactory = new ConnectionFactory();
connectionFactory.setHost("127.0.0.1");
connectionFactory.setPort(5672);// port
connectionFactory.setUsername("guest");
connectionFactory.setPassword("guest");
// Set up virtual machine , One mq Services can set up multiple virtual machines , Each virtual machine is equivalent to an independent mq
connectionFactory.setVirtualHost("/"); // Build new connections
Connection connection = connectionFactory.newConnection();
// Create a session channel , Producers and mq Service all communications are in channel Done in the channel
Channel channel = connection.createChannel(); /**
* Parameter details
* 1、queue Queue name
* 2、durable Persistent or not , If you persist ,mq After the restart, the queue is still
* 3、exclusive Whether the connection is exclusive , The queue is only allowed access in this connection , If connection When the connection is closed, the queue will be deleted automatically , If you set this parameter true Can be used to create temporary queues
* 4、autoDelete Automatically delete , Whether to automatically delete the queue when it is no longer in use , If you add this parameter to exclusive Parameter set to true The temporary queue can be implemented ( The queue is automatically deleted when it is not in use )
* 5、arguments Parameters , You can set the extension parameters of a queue , such as : The survival time can be set
*/
channel.queueDeclare(QUEUE_INFORM_EMAIL,true,false,false,null);
// Declare a switch
// Parameters :String exchange, String type
/**
* Parameter details :
* 1、 Name of switch
* 2、 Type of switch
* fanout: Corresponding rabbitmq The working mode of publish/subscribe
* direct: Corresponding Routing Working mode
* topic: Corresponding Topics Working mode
* headers: Corresponding headers Working mode
*/
channel.exchangeDeclare(EXCHANGE_ROUTING_INFORM, BuiltinExchangeType.DIRECT);
// Switch and queue binding
// Parameters :String queue, String exchange, String routingKey
/**
* Parameter details :
* 1、queue Queue name
* 2、exchange Switch name
* 3、routingKey route key, The function of the switch is based on routing key Forward the message to the specified queue , In the publish subscribe mode, the mediation is an empty string
*/
channel.queueBind(QUEUE_INFORM_EMAIL, EXCHANGE_ROUTING_INFORM,ROUTINGKEY_EMAIL); // Realize the consumption method
DefaultConsumer defaultConsumer = new DefaultConsumer(channel){ /**
* When the message is received, this method will be called
* @param consumerTag Consumer labels , Used to identify consumers , Set when listening to the queue channel.basicConsume
* @param envelope The envelope , adopt envelope
* @param properties Message properties
* @param body The message content
* @throws IOException
*/
@Override
public void handleDelivery(String consumerTag, Envelope envelope, AMQP.BasicProperties properties, byte[] body) throws IOException {
// Switch
String exchange = envelope.getExchange();
// news id,mq stay channel Used to identify messages in id, Can be used to confirm that a message has been received
long deliveryTag = envelope.getDeliveryTag();
// The message content
String message= new String(body,"utf-8");
System.out.println("receive message:"+message);
}
}; // Listening to the queue
// Parameters :String queue, boolean autoAck, Consumer callback
/**
* Parameter details :
* 1、queue Queue name
* 2、autoAck Automatic recovery , When the consumer receives the message, he should tell mq Message received , If this parameter is set to tru It means that you will reply automatically mq, If set to false Reply by programming
* 3、callback, Consumption method , When the consumer receives the message, the method to be executed
*/
channel.basicConsume(QUEUE_INFORM_EMAIL,true,defaultConsumer); }
}
http://www.dtmao.cc/news_show_631033.shtml

Message Receiver 2

public class Consumer03_routing_sms {
// Queue name
private static final String QUEUE_INFORM_SMS = "queue_inform_sms";
private static final String EXCHANGE_ROUTING_INFORM="exchange_routing_inform";
private static final String ROUTINGKEY_SMS="inform_sms"; public static void main(String[] args) throws IOException, TimeoutException {
// Create new connections and mq Establishing a connection
ConnectionFactory connectionFactory = new ConnectionFactory();
connectionFactory.setHost("127.0.0.1");
connectionFactory.setPort(5672);// port
connectionFactory.setUsername("guest");
connectionFactory.setPassword("guest");
// Set up virtual machine , One mq Services can set up multiple virtual machines , Each virtual machine is equivalent to an independent mq
connectionFactory.setVirtualHost("/"); // Build new connections
Connection connection = connectionFactory.newConnection();
// Create a session channel , Producers and mq Service all communications are in channel Done in the channel
Channel channel = connection.createChannel(); /**
* Parameter details
* 1、queue Queue name
* 2、durable Persistent or not , If you persist ,mq After the restart, the queue is still
* 3、exclusive Whether the connection is exclusive , The queue is only allowed access in this connection , If connection When the connection is closed, the queue will be deleted automatically , If you set this parameter true Can be used to create temporary queues
* 4、autoDelete Automatically delete , Whether to automatically delete the queue when it is no longer in use , If you add this parameter to exclusive Parameter set to true The temporary queue can be implemented ( The queue is automatically deleted when it is not in use )
* 5、arguments Parameters , You can set the extension parameters of a queue , such as : The survival time can be set
*/
channel.queueDeclare(QUEUE_INFORM_SMS,true,false,false,null);
// Declare a switch
// Parameters :String exchange, String type
/**
* Parameter details :
* 1、 Name of switch
* 2、 Type of switch
* fanout: Corresponding rabbitmq The working mode of publish/subscribe
* direct: Corresponding Routing Working mode
* topic: Corresponding Topics Working mode
* headers: Corresponding headers Working mode
*/
channel.exchangeDeclare(EXCHANGE_ROUTING_INFORM, BuiltinExchangeType.DIRECT);
// Switch and queue binding
// Parameters :String queue, String exchange, String routingKey
/**
* Parameter details :
* 1、queue Queue name
* 2、exchange Switch name
* 3、routingKey route key, The function of the switch is based on routing key Forward the message to the specified queue , In the publish subscribe mode, the mediation is an empty string
*/
channel.queueBind(QUEUE_INFORM_SMS, EXCHANGE_ROUTING_INFORM,ROUTINGKEY_SMS); // Realize the consumption method
DefaultConsumer defaultConsumer = new DefaultConsumer(channel){ /**
* When the message is received, this method will be called
* @param consumerTag Consumer labels , Used to identify consumers , Set when listening to the queue channel.basicConsume
* @param envelope The envelope , adopt envelope
* @param properties Message properties
* @param body The message content
* @throws IOException
*/
@Override
public void handleDelivery(String consumerTag, Envelope envelope, AMQP.BasicProperties properties, byte[] body) throws IOException {
// Switch
String exchange = envelope.getExchange();
// news id,mq stay channel Used to identify messages in id, Can be used to confirm that a message has been received
long deliveryTag = envelope.getDeliveryTag();
// The message content
String message= new String(body,"utf-8");
System.out.println("receive message:"+message);
}
}; // Listening to the queue
// Parameters :String queue, boolean autoAck, Consumer callback
/**
* Parameter details :
* 1、queue Queue name
* 2、autoAck Automatic recovery , When the consumer receives the message, he should tell mq Message received , If this parameter is set to tru It means that you will reply automatically mq, If set to false Reply by programming
* 3、callback, Consumption method , When the consumer receives the message, the method to be executed
*/
channel.basicConsume(QUEUE_INFORM_SMS,true,defaultConsumer); }
}

5、 ... and 、Topics

public class Producer04_topics {
// Queue name
private static final String QUEUE_INFORM_EMAIL = "queue_inform_email";
private static final String QUEUE_INFORM_SMS = "queue_inform_sms";
// Declaration switch
private static final String EXCHANGE_TOPICS_INFORM="exchange_topics_inform";
// Use wildcards to , Set the routing key
private static final String ROUTINGKEY_EMAIL="inform.#.email.#";
private static final String ROUTINGKEY_SMS="inform.#.sms.#";
public static void main(String[] args) {
// Create new connections and mq Establishing a connection
ConnectionFactory connectionFactory = new ConnectionFactory();
connectionFactory.setHost("127.0.0.1");
connectionFactory.setPort(5672);// port
connectionFactory.setUsername("guest");
connectionFactory.setPassword("guest");
// Set up virtual machine , One mq Services can set up multiple virtual machines , Each virtual machine is equivalent to an independent mq
connectionFactory.setVirtualHost("/"); Connection connection = null;
Channel channel = null;
try {
// Build new connections
connection = connectionFactory.newConnection();
// Create a session channel , Producers and mq Service all communications are in channel Done in the channel
channel = connection.createChannel();
// Declaration queue , If the queue is in mq If not, create
// Parameters :String queue, boolean durable, boolean exclusive, boolean autoDelete, Map<String, Object> arguments
/**
* Parameter details
* 1、queue Queue name
* 2、durable Persistent or not , If you persist ,mq After the restart, the queue is still
* 3、exclusive Whether the connection is exclusive , The queue is only allowed access in this connection , If connection When the connection is closed, the queue will be deleted automatically , If you set this parameter true Can be used to create temporary queues
* 4、autoDelete Automatically delete , Whether to automatically delete the queue when it is no longer in use , If you add this parameter to exclusive Parameter set to true The temporary queue can be implemented ( The queue is automatically deleted when it is not in use )
* 5、arguments Parameters , You can set the extension parameters of a queue , such as : The survival time can be set
*/
channel.queueDeclare(QUEUE_INFORM_EMAIL,true,false,false,null);
channel.queueDeclare(QUEUE_INFORM_SMS,true,false,false,null);
// Declare a switch
// Parameters :String exchange, String type
/**
* Parameter details :
* 1、 Name of switch
* 2、 Type of switch
* fanout: Corresponding rabbitmq The working mode of publish/subscribe
* direct: Corresponding Routing Working mode
* topic: Corresponding Topics Working mode
* headers: Corresponding headers Working mode
*/
channel.exchangeDeclare(EXCHANGE_TOPICS_INFORM, BuiltinExchangeType.TOPIC);
// Switch and queue binding
// Parameters :String queue, String exchange, String routingKey
/**
* Parameter details :
* 1、queue Queue name
* 2、exchange Switch name
* 3、routingKey route key, The function of the switch is based on routing key Forward the message to the specified queue , In the publish subscribe mode, the mediation is an empty string
*/
channel.queueBind(QUEUE_INFORM_EMAIL,EXCHANGE_TOPICS_INFORM,ROUTINGKEY_EMAIL);
channel.queueBind(QUEUE_INFORM_SMS,EXCHANGE_TOPICS_INFORM,ROUTINGKEY_SMS);
// Send a message
// Parameters :String exchange, String routingKey, BasicProperties props, byte[] body
/**
* Parameter details :
* 1、exchange, Switch , If not specified mq The default switch for ( Set to "")
* 2、routingKey, route key, Switch according to route key To forward the message to the specified queue , If you use the default switch ,routingKey Set to the name of the queue
* 3、props, The properties of the message
* 4、body, The message content
*/
for(int i=0;i<5;i++){
// Specify when sending a message routingKey
String message = "send email inform message to user";
channel.basicPublish(EXCHANGE_TOPICS_INFORM,"inform.email",null,message.getBytes());
System.out.println("send to mq "+message);
}
for(int i=0;i<5;i++){
// Specify when sending a message routingKey
String message = "send sms inform message to user";
channel.basicPublish(EXCHANGE_TOPICS_INFORM,"inform.sms",null,message.getBytes());
System.out.println("send to mq "+message);
}
for(int i=0;i<5;i++){
// Specify when sending a message routingKey
String message = "send sms and email inform message to user";
channel.basicPublish(EXCHANGE_TOPICS_INFORM,"inform.sms.email",null,message.getBytes());
System.out.println("send to mq "+message);
} } catch (Exception e) {
e.printStackTrace();
} finally {
// Close the connection
// Close the channel first
try {
channel.close();
} catch (IOException e) {
e.printStackTrace();
} catch (TimeoutException e) {
e.printStackTrace();
}
try {
connection.close();
} catch (IOException e) {
e.printStackTrace();
}
}
}
}

Message Receiver 1

public class Consumer04_topics_email {
// Queue name
private static final String QUEUE_INFORM_EMAIL = "queue_inform_email";
private static final String EXCHANGE_TOPICS_INFORM="exchange_topics_inform";
private static final String ROUTINGKEY_EMAIL="inform.#.email.#"; public static void main(String[] args) throws IOException, TimeoutException {
// Create new connections and mq Establishing a connection
ConnectionFactory connectionFactory = new ConnectionFactory();
connectionFactory.setHost("127.0.0.1");
connectionFactory.setPort(5672);// port
connectionFactory.setUsername("guest");
connectionFactory.setPassword("guest");
// Set up virtual machine , One mq Services can set up multiple virtual machines , Each virtual machine is equivalent to an independent mq
connectionFactory.setVirtualHost("/"); // Build new connections
Connection connection = connectionFactory.newConnection();
// Create a session channel , Producers and mq Service all communications are in channel Done in the channel
Channel channel = connection.createChannel(); /**
* Parameter details
* 1、queue Queue name
* 2、durable Persistent or not , If you persist ,mq After the restart, the queue is still
* 3、exclusive Whether the connection is exclusive , The queue is only allowed access in this connection , If connection When the connection is closed, the queue will be deleted automatically , If you set this parameter true Can be used to create temporary queues
* 4、autoDelete Automatically delete , Whether to automatically delete the queue when it is no longer in use , If you add this parameter to exclusive Parameter set to true The temporary queue can be implemented ( The queue is automatically deleted when it is not in use )
* 5、arguments Parameters , You can set the extension parameters of a queue , such as : The survival time can be set
*/
channel.queueDeclare(QUEUE_INFORM_EMAIL,true,false,false,null);
// Declare a switch
// Parameters :String exchange, String type
/**
* Parameter details :
* 1、 Name of switch
* 2、 Type of switch
* fanout: Corresponding rabbitmq The working mode of publish/subscribe
* direct: Corresponding Routing Working mode
* topic: Corresponding Topics Working mode
* headers: Corresponding headers Working mode
*/
channel.exchangeDeclare(EXCHANGE_TOPICS_INFORM, BuiltinExchangeType.TOPIC);
// Switch and queue binding
// Parameters :String queue, String exchange, String routingKey
/**
* Parameter details :
* 1、queue Queue name
* 2、exchange Switch name
* 3、routingKey route key, The function of the switch is based on routing key Forward the message to the specified queue , In the publish subscribe mode, the mediation is an empty string
*/
channel.queueBind(QUEUE_INFORM_EMAIL, EXCHANGE_TOPICS_INFORM,ROUTINGKEY_EMAIL); // Realize the consumption method
DefaultConsumer defaultConsumer = new DefaultConsumer(channel){ /**
* When the message is received, this method will be called
* @param consumerTag Consumer labels , Used to identify consumers , Set when listening to the queue channel.basicConsume
* @param envelope The envelope , adopt envelope
* @param properties Message properties
* @param body The message content
* @throws IOException
*/
@Override
public void handleDelivery(String consumerTag, Envelope envelope, AMQP.BasicProperties properties, byte[] body) throws IOException {
// Switch
String exchange = envelope.getExchange();
// news id,mq stay channel Used to identify messages in id, Can be used to confirm that a message has been received
long deliveryTag = envelope.getDeliveryTag();
// The message content
String message= new String(body,"utf-8");
System.out.println("receive message:"+message);
}
}; // Listening to the queue
// Parameters :String queue, boolean autoAck, Consumer callback
/**
* Parameter details :
* 1、queue Queue name
* 2、autoAck Automatic recovery , When the consumer receives the message, he should tell mq Message received , If this parameter is set to tru It means that you will reply automatically mq, If set to false Reply by programming
* 3、callback, Consumption method , When the consumer receives the message, the method to be executed
*/
channel.basicConsume(QUEUE_INFORM_EMAIL,true,defaultConsumer); }
}

Lowercase recipients 2

public class Consumer04_topics_sms {
// Queue name
private static final String QUEUE_INFORM_SMS = "queue_inform_sms";
private static final String EXCHANGE_TOPICS_INFORM="exchange_topics_inform";
private static final String ROUTINGKEY_SMS="inform.#.sms.#"; public static void main(String[] args) throws IOException, TimeoutException {
// Create new connections and mq Establishing a connection
ConnectionFactory connectionFactory = new ConnectionFactory();
connectionFactory.setHost("127.0.0.1");
connectionFactory.setPort(5672);// port
connectionFactory.setUsername("guest");
connectionFactory.setPassword("guest");
// Set up virtual machine , One mq Services can set up multiple virtual machines , Each virtual machine is equivalent to an independent mq
connectionFactory.setVirtualHost("/"); // Build new connections
Connection connection = connectionFactory.newConnection();
// Create a session channel , Producers and mq Service all communications are in channel Done in the channel
Channel channel = connection.createChannel(); /**
* Parameter details
* 1、queue Queue name
* 2、durable Persistent or not , If you persist ,mq After the restart, the queue is still
* 3、exclusive Whether the connection is exclusive , The queue is only allowed access in this connection , If connection When the connection is closed, the queue will be deleted automatically , If you set this parameter true Can be used to create temporary queues
* 4、autoDelete Automatically delete , Whether to automatically delete the queue when it is no longer in use , If you add this parameter to exclusive Parameter set to true The temporary queue can be implemented ( The queue is automatically deleted when it is not in use )
* 5、arguments Parameters , You can set the extension parameters of a queue , such as : The survival time can be set
*/
channel.queueDeclare(QUEUE_INFORM_SMS,true,false,false,null);
// Declare a switch
// Parameters :String exchange, String type
/**
* Parameter details :
* 1、 Name of switch
* 2、 Type of switch
* fanout: Corresponding rabbitmq The working mode of publish/subscribe
* direct: Corresponding Routing Working mode
* topic: Corresponding Topics Working mode
* headers: Corresponding headers Working mode
*/
channel.exchangeDeclare(EXCHANGE_TOPICS_INFORM, BuiltinExchangeType.TOPIC);
// Switch and queue binding
// Parameters :String queue, String exchange, String routingKey
/**
* Parameter details :
* 1、queue Queue name
* 2、exchange Switch name
* 3、routingKey route key, The function of the switch is based on routing key Forward the message to the specified queue , In the publish subscribe mode, the mediation is an empty string
*/
channel.queueBind(QUEUE_INFORM_SMS, EXCHANGE_TOPICS_INFORM,ROUTINGKEY_SMS); // Realize the consumption method
DefaultConsumer defaultConsumer = new DefaultConsumer(channel){ /**
* When the message is received, this method will be called
* @param consumerTag Consumer labels , Used to identify consumers , Set when listening to the queue channel.basicConsume
* @param envelope The envelope , adopt envelope
* @param properties Message properties
* @param body The message content
* @throws IOException
*/
@Override
public void handleDelivery(String consumerTag, Envelope envelope, AMQP.BasicProperties properties, byte[] body) throws IOException {
// Switch
String exchange = envelope.getExchange();
// news id,mq stay channel Used to identify messages in id, Can be used to confirm that a message has been received
long deliveryTag = envelope.getDeliveryTag();
// The message content
String message= new String(body,"utf-8");
System.out.println("receive message:"+message);
}
}; // Listening to the queue
// Parameters :String queue, boolean autoAck, Consumer callback
/**
* Parameter details :
* 1、queue Queue name
* 2、autoAck Automatic recovery , When the consumer receives the message, he should tell mq Message received , If this parameter is set to tru It means that you will reply automatically mq, If set to false Reply by programming
* 3、callback, Consumption method , When the consumer receives the message, the method to be executed
*/
channel.basicConsume(QUEUE_INFORM_SMS,true,defaultConsumer); }
}

6、 ... and 、Header

7、 ... and 、RPC

8、 ... and 、Spring Data Elasticsearch

rabbitmq-producer Message sender

@Configuration
public class RabbitMQConfig {
// Declare two queue constants
public static final String QUEUE_INFORM_EMAIL = "queue_inform_email";
public static final String QUEUE_INFORM_SMS = "queue_inform_sms";
// Declare switch constants
public static final String EXCHANGE_TOPICS_INFORM="exchange_topics_inform";
// Declare two routing key constants
public static final String ROUTINGKEY_EMAIL="inform.#.email.#";
public static final String ROUTINGKEY_SMS="inform.#.sms.#"; // Declaration switch
@Bean(EXCHANGE_TOPICS_INFORM)
public Exchange EXCHANGE_TOPICS_INFORM(){
//durable(true) Persistence ,mq After the restart, the switch is still
return ExchangeBuilder.topicExchange(EXCHANGE_TOPICS_INFORM).durable(true).build();
} // Declaration queue // Statement QUEUE_INFORM_EMAIL queue
@Bean(QUEUE_INFORM_EMAIL)
public Queue QUEUE_INFORM_EMAIL(){
return new Queue(QUEUE_INFORM_EMAIL);
}
// Statement QUEUE_INFORM_SMS queue
@Bean(QUEUE_INFORM_SMS)
public Queue QUEUE_INFORM_SMS(){
return new Queue(QUEUE_INFORM_SMS);
} // Bind switches and queues
//ROUTINGKEY_EMAIL Queue bound switches , Appoint routingKey
@Bean
public Binding BINDING_QUEUE_INFORM_EMAIL(@Qualifier(QUEUE_INFORM_EMAIL) Queue queue,
@Qualifier(EXCHANGE_TOPICS_INFORM) Exchange exchange){
return BindingBuilder.bind(queue).to(exchange).with(ROUTINGKEY_EMAIL).noargs();
}
//ROUTINGKEY_SMS Queue bound switches , Appoint routingKey
@Bean
public Binding BINDING_ROUTINGKEY_SMS(@Qualifier(QUEUE_INFORM_SMS) Queue queue,
@Qualifier(EXCHANGE_TOPICS_INFORM) Exchange exchange){
return BindingBuilder.bind(queue).to(exchange).with(ROUTINGKEY_SMS).noargs();
}
}

rabbitmq-consumer Message Receiver

@Configuration
public class RabbitMQConfig {
public static final String QUEUE_INFORM_EMAIL = "queue_inform_email";
public static final String QUEUE_INFORM_SMS = "queue_inform_sms";
public static final String EXCHANGE_TOPICS_INFORM="exchange_topics_inform";
public static final String ROUTINGKEY_EMAIL="inform.#.email.#";
public static final String ROUTINGKEY_SMS="inform.#.sms.#"; // Declaration switch
@Bean(EXCHANGE_TOPICS_INFORM)
public Exchange EXCHANGE_TOPICS_INFORM(){
//durable(true) Persistence ,mq After the restart, the switch is still
return ExchangeBuilder.topicExchange(EXCHANGE_TOPICS_INFORM).durable(true).build();
} // Declaration queue // Statement QUEUE_INFORM_EMAIL queue
@Bean(QUEUE_INFORM_EMAIL)
public Queue QUEUE_INFORM_EMAIL(){
return new Queue(QUEUE_INFORM_EMAIL);
}
// Statement QUEUE_INFORM_SMS queue
@Bean(QUEUE_INFORM_SMS)
public Queue QUEUE_INFORM_SMS(){
return new Queue(QUEUE_INFORM_SMS);
} // Bind switches and queues
//ROUTINGKEY_EMAIL Queue bound switches , Appoint routingKey
@Bean
public Binding BINDING_QUEUE_INFORM_EMAIL(@Qualifier(QUEUE_INFORM_EMAIL) Queue queue,
@Qualifier(EXCHANGE_TOPICS_INFORM) Exchange exchange){
return BindingBuilder.bind(queue).to(exchange).with(ROUTINGKEY_EMAIL).noargs();
}
//ROUTINGKEY_SMS Queue bound switches , Appoint routingKey
@Bean
public Binding BINDING_ROUTINGKEY_SMS(@Qualifier(QUEUE_INFORM_SMS) Queue queue,
@Qualifier(EXCHANGE_TOPICS_INFORM) Exchange exchange){
return BindingBuilder.bind(queue).to(exchange).with(ROUTINGKEY_SMS).noargs();
}
}
@SpringBootApplication
@EnableRabbit
public class TestRabbitMQApplication {
public static void main(String[] args) {
SpringApplication.run(TestRabbitMQApplication.class, args);
}
}

Listen message queue

@Component
public class ReceiveHandler { @RabbitListener(queues = {RabbitMQConfig.QUEUE_INFORM_EMAIL})
public void receiveMsg(String msg) {
System.out.println(" The message received was = " + msg);
}
}

stay rabbitmq-provider Medium test

@SpringBootTest
@RunWith(SpringRunner.class)
public class Producer05_topics_springboot { // Use rabbitTemplate Send a message
@Autowired
private RabbitTemplate rabbitTemplate; @Test
public void testSendEmail() {
String message = "send email message to user";
/**
* arg1: Switch name
* arg2: Routing key
* arg3: The message content
*/
rabbitTemplate.convertAndSend(RabbitMQConfig.EXCHANGE_TOPICS_INFORM, "inform.email", message);
} }

RabbitMQ What are the six working modes ? How to use SpringBoot Integrate RabbitMQ More articles about

  1. rabbitmq Six official modes of work

    1.RabbitMq1.1 Introduce RabbitMQ Is a message broker : It receives and forwards messages . You can think of it as a post office : When you want to post a letter , You'll put the letters in the delivery box , And be sure that the postman will eventually deliver the letter to the recipient . In this case ...

  2. After learning one article rabbitmq Basic knowledge of ,springboot Integrate rabbitmq

    One    rabbitmq Introduce MQ Its full name is Message Queue, That's message queuing , RabbitMQ By erlang Language development , be based on AMQP(Advanced MessageQueue Advanced message queue protocol ...

  3. RabbitMQ Six working modes of

    One . be based on erlang Language : It's a language that supports high concurrency RabbitMQ Six working modes of : 1.1 simple Simple mode The news produced § Put messages in the queue Consumers of messages (consumer) monitor (while) eliminate ...

  4. RabbitMQ Summary of the six working modes of

    Recent learning RabbitMQ How to use , recorded , Convenient for future use , It's also convenient to share , Communicate with each other . RabbitMQ Six working modes of : 1.Work queues2.Publish/subscribe3.Rout ...

  5. RabbitMQ Six queue modes - Simple queue mode

    Preface RabbitMQ Six queue modes - Simple queue [ this paper ]RabbitMQ Six queue modes - Work queue RabbitMQ Six queue modes - Publish subscribe RabbitMQ Six queue modes - Routing mode RabbitMQ Six queue modes - Lord ...

  6. RabbitMQ Six queue modes - Work queue mode

    Preface RabbitMQ Six queue modes - Simple queue RabbitMQ Six queue modes - Work queue [ this paper ]RabbitMQ Six queue modes - Publish subscribe RabbitMQ Six queue modes - Routing mode RabbitMQ Six queue modes - Lord ...

  7. RabbitMQ Six queue modes - Publish subscribe mode

    Preface RabbitMQ Six queue modes - Simple queue RabbitMQ Six queue modes - Work queue RabbitMQ Six queue modes - Publish subscribe [ this paper ]RabbitMQ Six queue modes - Routing mode RabbitMQ Six queue modes - Lord ...

  8. RabbitMQ Six queue modes - Routing mode

    Preface RabbitMQ Six queue modes - Simple queue RabbitMQ Six queue modes - Work queue RabbitMQ Six queue modes - Publish subscribe RabbitMQ Six queue modes - Routing mode [ this paper ]RabbitMQ Six queue modes - Lord ...

  9. RabbitMQ Six queue modes - Theme mode

    Preface RabbitMQ Six queue modes - Simple queue RabbitMQ Six queue modes - Work queue RabbitMQ Six queue modes - Publish subscribe RabbitMQ Six queue modes - Routing mode RabbitMQ Six queue modes - Theme mode [ ...

  10. springboot Learning notes -6 springboot Integrate RabbitMQ

    One RabbitMQ Introduction to RabbitMQ Is a kind of message middleware , Message middleware is the basic software for message sending and receiving in distributed system . There are a lot of these software , Include ActiveMQ(apache The company's ),RocketMQ( o ...

Random recommendation

  1. idea Static resources cannot be updated immediately

  2. IOS The main framework is introduced ( turn )

    This article is about <Sunvey the Major Framworks> The translation of one article A framework is a catalog , This directory contains shared libraries , Access the header file of the code in the shared library , And other image and sound resource files . A shared library definition method ...

  3. NOIP2011 Answer key

    NOIP2011 Actually, it's already done .... I've been too lazy to write .... Day1 T1 Carpet I don't want to say anything , If you can't do it, you don't have to watch it .... #include<iostream> using name ...

  4. FixedThreadPool Swallowing the anomaly

    In order to describe the problem easily , Here's a simplified version public class RunException { public static void main(String[] args) { ExecutorServi ...

  5. MySQL【 Text processing function 】 How to use

    Text processing function name Invoke the sample Sample results describe LEFT LEFT('abc123', 3) abc Returns a substring of a specified length taken from the left RIGHT RIGHT('abc123', 3) 123 Go back and take the finger from the right ...

  6. CentOS7.5 Install from scratch Python3.6.6

    ps: Environment like title Installation may require dependencies yum install openssl-devel bzip2-devel expat-devel gdbm-devel readline-devel sqlit ...

  7. LAMP Platform construction and application

    The experimental requirements 1. structure PHP Running environment , Realization LAMP Collaborative Architecture , The prerequisite is that the server has been compiled Apache HTTP Server and MySQL database ,( Compilation and installation apache And compile and install mysql Please check the official account L ...

  8. Technology enthusiast's SLR Canon 700d Medium and high end

    http://detail.zol.com.cn/series/15/15795_1.html Top three Canon nikon SONY Canon 5d 1.6w Canon 70d 5k Canon 6d 9k Canon d7100 5k nikon ...

  9. JavaScript introduction :004—JS The writing and basic operators of gaze

    JS My gaze JS Chinese and Canadian gaze and ordinary writing C# The code is almost the same . Yes // and /* */ These two kinds of . Single line gaze uses double slashes, such as . <script type="text/javascript"> ...

  10. vim Instructions , Shortcut key summary

    Vim command . operation . The complete set of shortcut keys Command history With : and / There's a history of the first orders , You can type : or / Then press the up and down arrows to select a history command . start-up vim Enter the following command in the command line window vim Direct start vim vi ...