- Java 双重比较
- java - 比较器与 Apache BeanComparator
- Objective-C 完成 block 导致额外的方法调用?
- database - RESTful URI 是否应该公开数据库主键?
我正在使用 rabbit mq 3.4.1 java 客户端库,但无法使自动恢复机制正常工作。
这就是我创建 rabbit mq 连接工厂的方式:
factory = new ConnectionFactory();
factory.setUsername(userName);
factory.setPassword(password);
factory.setVirtualHost(virtualHost);
factory.setAutomaticRecoveryEnabled(true);
factory.setNetworkRecoveryInterval(5);
factory.setRequestedHeartbeat(3);
消息发布后,如果我关闭 rabbit mq 代理并再次启动它,我希望恢复机制启动并将连接恢复到“正常”状态。但是我收到以下错误:
com.rabbitmq.client.AlreadyClosedException: connection is already closed due to connection error; protocol method: #method<connection.close>(reply-code=320, reply-text=CONNECTION_FORCED - broker forced connection closure with reason 'shutdown', class-id=0, method-id=0)
at com.rabbitmq.client.impl.AMQChannel.ensureIsOpen(AMQChannel.java:190) ~[amqp-client-3.4.1.jar:na]
at com.rabbitmq.client.impl.AMQChannel.transmit(AMQChannel.java:291) ~[amqp-client-3.4.1.jar:na]
at com.rabbitmq.client.impl.ChannelN.basicPublish(ChannelN.java:654) ~[amqp-client-3.4.1.jar:na]
at com.rabbitmq.client.impl.ChannelN.basicPublish(ChannelN.java:631) ~[amqp-client-3.4.1.jar:na]
at com.rabbitmq.client.impl.ChannelN.basicPublish(ChannelN.java:622) ~[amqp-client-3.4.1.jar:na]
我在这里遗漏了什么吗?解决此问题的唯一方法是注册 ShutDownListener 并重新初始化 rabbit mq 连接工厂、连接和 channel 。
也来回答
"chrislott"
评论,我看到自动恢复开始恢复。我使用临时 channel 创建交换:
Channel channel = connection.createChannel();
channel.exchangeDeclare(exchangeName, exchangeType, durable);
channel.close();
我在尝试恢复拓扑时看到以下异常:
Caught an exception when recovering topology Caught an exception while recovering exchange testSuccessfulInitVirtualHost_Exchange: channel is already closed due to clean channel shutdown; protocol method: #method<channel.close>(reply-code=200, reply-text=OK, class-id=0, method-id=0)
com.rabbitmq.client.TopologyRecoveryException: Caught an exception while recovering exchange testSuccessfulInitVirtualHost_Exchange: channel is already closed due to clean channel shutdown; protocol method: #method<channel.close>(reply-code=200, reply-text=OK, class-id=0, method-id=0)
at com.rabbitmq.client.impl.recovery.AutorecoveringConnection.recoverExchanges(AutorecoveringConnection.java:482)
at com.rabbitmq.client.impl.recovery.AutorecoveringConnection.recoverEntities(AutorecoveringConnection.java:467)
at com.rabbitmq.client.impl.recovery.AutorecoveringConnection.beginAutomaticRecovery(AutorecoveringConnection.java:411)
at com.rabbitmq.client.impl.recovery.AutorecoveringConnection.access$000(AutorecoveringConnection.java:52)
at com.rabbitmq.client.impl.recovery.AutorecoveringConnection$1.shutdownCompleted(AutorecoveringConnection.java:351)
at com.rabbitmq.client.impl.ShutdownNotifierComponent.notifyListeners(ShutdownNotifierComponent.java:75)
at com.rabbitmq.client.impl.AMQConnection$MainLoop.run(AMQConnection.java:574)
如果我不关闭用于创建交换的 channel ,则不会出现上述异常。
最佳答案
我对 RabbitMQ ConnectionFactory#setAutomaticRecoveryEnabled(Boolean) 方法的解读是,它主要支持从 NETWORK 故障中恢复。
这是一个很好的讨论:https://www.rabbitmq.com/api-guide.html
例如,如果您的机器在一段时间内丢失了到代理的路由,可能是由于切换或其他故障,那么自动恢复可以重新建立连接等。文档没有说明幸存经纪人关闭/重启,我认为你的期望是不合理的。
恕我直言,从代理重启中恢复,关闭监听器方法似乎是一种可靠的方法。
关于java - 兔子MQ : Connection recovery mechanism,我们在Stack Overflow上找到一个类似的问题: https://stackoverflow.com/questions/29760670/
我想通过恢复从 sdcard 安装 zip,我写了一个名为 command 的文件: --update_package=/sdcard/my-rom.zip 将文件放入/cache/recovery
在 recovery.conf 中,如果我们将 recovery_target_time 设置为 2018-09-07 03:25:46(无 EST)并重新启动 PostgreSQL,恢复。 conf
据说nosteal是指事务提交之前更新的缓冲区不会写入磁盘,noforce也有类似的定义,那么它们之间有什么区别呢? 最佳答案 假设事务 T1 想要读取数据对象 X,但工作内存已被所有其他事务的工作填
不管我是如何到达这里的,我都可以从备份中恢复 SVN 存储库。不幸的是,备份略有损坏,在超过 19000 次修订中,大约有 80 次丢失。备份是一个 bzip2 文件,我能够使用 bzip2recov
使用 mariaDB 作为支持数据库创建了一个 VPS 来处理多个 WordPress 站点。在安装用于站点统计的 matomo 的过程中,不知怎的,整个 mysql 区域(考虑到 mariadb 和
每次运行查询时,我的数据库都不会立即响应第二个查询并提示它处于恢复模式(尽管它除了数据库名称之外没有显示任何内容)。这会发生大约 5-10 分钟,之后一切都会恢复正常。 我预计会发生重大崩溃,因此我将
我需要编写一个程序,在可能状态的大空间中执行并行搜索,在此过程中发现了新区域(并开始了他们的探索),并且由于在其他地方获得的中间结果消除了可能性,因此提前终止了对某些区域的探索在其中发现新的有用结果。
如何编写可以恢复 FAT32 文件的程序? 最佳答案 这很复杂,但是 FAT32 有很好的文档记录: 我只使用这些资源编写了一个直接访问 FAT32 的工具: http://en.wikipedia.
1、概述 Password Recovery Bundle Pro 是一个方便的工具,可以轻松恢复所有丢失的密码或忘记密码。使用 Password Recovery Bundle 时
由于服务器上的数据库使用很长时间了日志文件已经是好几个了 数据库服务器的一直采用的备份我想应该可以放弃以前的日志文件了所以清理以前的日志文件 我现在想的问题是在利用备份文件恢复的时候 要不要使
在teamcity中运行构建时出现以下错误。 Failed to collect changes, error: '"C:\Program Files\TortoiseHg\hg.exe" --con
作业系统:Win 2012 R2 你好 我尝试设置某些服务,以便当它们第二次失败时,将触发Powershell脚本向某些人发送电子邮件。这是通过services > (specific service
在 Azure 站点恢复服务的 REST API 中,位于此处:Get a list of replication protected items in Azure Site Recovery我找不到
我昨天在我的开发机器上恢复了一个 35Gb 的数据库,一切都很顺利,直到今天早上我的客户端应用程序无法连接。所以我打开 SQL Management Studio 来查找数据库“In Recovery
在 Azure 站点恢复服务的 REST API 中,位于此处:Get a list of replication protected items in Azure Site Recovery我找不到
当我尝试打开 Excel 文件时,会出现一个消息框提示,例如 “我们发现文件名中的某些内容存在问题。您希望我们尝试尽可能恢复吗?如果您信任此工作簿的来源,请单击"is"。”。实际上,我设计了一个 Ex
我可以使用 cs50 中关于此 pset 的一些指导。下面是我到目前为止的代码。我被困在这一点上,我不知道如何继续。当我运行该程序时,它确实输出了 16 个 jpg 文件,但我无法查看它们,所以一定有
我终于设法使重启代码正常工作。我使用了以下代码: Runtime runtime = Runtime.getRuntime(); Process proc = null
我正在尝试向我的应用程序添加一个默认处理程序,以便我可以从其他未处理的异常中恢复。 我发现了 Android/MonoDroid 提供的三种机制,据我所知,应该可以实现这一点,但我无法让其中任何一种发
我正在使用 rabbit mq 3.4.1 java 客户端库,但无法使自动恢复机制正常工作。 这就是我创建 rabbit mq 连接工厂的方式: factory = new ConnectionFa
我是一名优秀的程序员,十分优秀!