gpt4 book ai didi

java - RabbitMQ,话题交流

转载 作者:行者123 更新时间:2023-11-30 11:26:40 26 4
gpt4 key购买 nike

我的 RabbitMQ 上有一个 Topic Exchange。发送消息出错。

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");异常(exception)情况:不能用不同类型、持久、内部或自动删除值,class-id=40,method-id=10,在虚拟主机“/”中重新声明交换“EX_TEST”

如何解决?谢谢你:D

最佳答案

中的方法参数
mModel.exchangeDeclare(EXCHANGE_NAME, MyExchangeType, true);

channel.exchangeDeclare(EXCHANGE_NAME, "topic");

应该相同。

关于java - RabbitMQ,话题交流,我们在Stack Overflow上找到一个类似的问题: https://stackoverflow.com/questions/19723037/

26 4 0
Copyright 2021 - 2024 cfsdn All Rights Reserved 蜀ICP备2022000587号
广告合作:1813099741@qq.com 6ren.com