2

I have a Topic Exchange on my RabbitMQ. An error by sending a message.

EXCHANGE_NAME = "EX_TEST";

Receive Section:

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);

Send Section:

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

error on line: channel.exchangeDeclare(EXCHANGE_NAME, "topic"); Exceptions: cannot redeclare exchange 'EX_TEST' in vhost '/' with different type, durable, internal or autodelete value, class-id=40, method-id=10

How to resolve this? thankyou :D

Matteo
  • 37,680
  • 11
  • 100
  • 115

1 Answers1

1

Method arguments in

mModel.exchangeDeclare(EXCHANGE_NAME, MyExchangeType, true);

and

channel.exchangeDeclare(EXCHANGE_NAME, "topic");

should be identical.

pinepain
  • 12,453
  • 3
  • 60
  • 65