第一步 :设置过滤条件
RabbitMQ的过滤条件是amqp
第二步:运行RabbitMQ程序
package com.rabbitmq.msgdirection.alternateexchange;
import com.rabbitmq.client.AMQP;
import com.rabbitmq.client.Channel;
import com.rabbitmq.client.Connection;
import com.rabbitmq.client.ReturnListener;
import com.rabbitmq.util.ConnectionUtils;
import lombok.extern.slf4j.Slf4j;
import java.io.IOException;
import java.util.HashMap;
import java.util.Map;
import java.util.concurrent.TimeoutException;
import static com.rabbitmq.common.Constant.NUM3;
/**
* 备用交换器
*/
@Slf4j
public class AlternateExchange {
public static void main( String[] args ) {
try {
// 创建连接
Connection connection = ConnectionUtils.getConnection();
// 创建信道
Channel channel = connection.creat