2

RabbitMQ にトピック交換があります。メッセージ送信によるエラー。

EXCHANGE_NAME = "EX_TEST";

受信セクション:

ConnectionFactory connectionFactory = new ConnectionFactory();
connectionFactory.setHost(mServer);
mConnection = connectionFactory.newConnection();
mModel = mConnection.createChannel();
mModel.exchangeDeclare(EXCHANGE_NAME, MyExchangeType, true);
mQueue = mModel.queueDeclare().getQueue();
MySubscription = new QueueingConsumer(mModel);
mModel.queueBind(mQueue, EXCHANGE_NAME, routingKey);
mModel.basicConsume(mQueue, true, MySubscription);

送信セクション:

ConnectionFactory factory = new ConnectionFactory();
        factory.setHost("localhost");
        Connection connection = factory.newConnection();
        Channel channel = connection.createChannel();
        channel.exchangeDeclare(EXCHANGE_NAME, "topic");

行のエラー:channel.exchangeDeclare(EXCHANGE_NAME, "topic"); 例外: 交換 'EX_TEST' を vhost '/' で再宣言できません

これを解決するには?ありがとう:D

4

1 に答える 1