一段时间以来,我一直在使用Rabbitmq Java Client 3.6.5,最近在其中一种设置中,我开始观察AmqpTimeoutExceptions。我的rabbitmq客户端和服务器位于同一台机器上,并且连接到本地主机上的服务器:5671。
设置详细信息: rabbitmq-java-client-v3.6.5, spring-amqp版本-1.6.5.RELEASE, Rabbitmq服务器-v3.7.6, 运行该应用程序的环境是CentOS Linux 7.6。
自从过去1年以来,一直使用相同的设置和应用代码,没有任何更改。但是,从上周开始,在Azure Centos Linux 7.6 VM上测试应用程序时,我开始观察到AmqpTimeoutExceptions错误。
我尝试将客户端升级到(rabbitmq-java-client / v4.11.0),但是我仍然收到AmqpTimeoutExceptions。
如果我通过rabbitmqadmin.py实用程序(由rabbitmq https://raw.githubusercontent.com/rabbitmq/rabbitmq-management/v3.7.6/bin/rabbitmqadmin共享)连接到rabbitmq服务器,则交换,队列声明和消息发布+都可以正常工作。禁用ssl并连接到5672也无济于事。
任何指针都会很有帮助。
配置: 服务器端:
# netstat -nlp |grep beam
tcp 0 0 0.0.0.0:25672 0.0.0.0:* LISTEN 57926/beam.smp
tcp6 0 0 :::5671 :::* LISTEN 57926/beam.smp
# rabbitmqctl list_users
Listing users ...
user tags
xxmq [administrator]
# rabbitmqctl list_permissions -p xxvhost
Listing permissions for vhost "xxvhost" ...
user configure write read
xxmq .* .* .*
# rabbitmqctl status
Radditmq config:
warning: the VM is running with native name encoding of latin1 which may cause Elixir to malfunction as it expects utf8. Please ensure your locale is set to UTF-8 (which can be verified by running "locale" in your shell)
Status of node rabbit@localhost ...
[{pid,3045},
{running_applications,
[{rabbit,"RabbitMQ","3.7.6"},
{os_mon,"CPO CXC 138 46","2.4.2"},
{rabbit_common,
"Modules shared by rabbitmq-server and rabbitmq-erlang-client",
"3.7.6"},
{recon,"Diagnostic tools for production use","2.3.2"},
{xmerl,"XML parser","1.3.14"},
{ranch_proxy_protocol,"Ranch Proxy Protocol Transport","1.5.0"},
{ranch,"Socket acceptor pool for TCP protocols.","1.5.0"},
{ssl,"Erlang/OTP SSL application","8.1.3.1.1"},
{public_key,"Public key infrastructure","1.4"},
{asn1,"The Erlang ASN1 compiler version 4.0.4","4.0.4"},
{crypto,"CRYPTO","3.7.4"},
{jsx,"a streaming, evented json parsing toolkit","2.8.2"},
{inets,"INETS CXC 138 49","6.3.9"},
{mnesia,"MNESIA CXC 138 12","4.14.3.1"},
{lager,"Erlang logging framework","3.5.1"},
{goldrush,"Erlang event stream processor","0.1.9"},
{compiler,"ERTS CXC 138 10","7.0.4.1"},
{syntax_tools,"Syntax tools","2.1.1.1"},
{syslog,"An RFC 3164 and RFC 5424 compliant logging framework.","3.4.2"},
{sasl,"SASL CXC 138 11","3.0.3"},
{stdlib,"ERTS CXC 138 10","3.3"},
{kernel,"ERTS CXC 138 10","5.2.0.1"}]},
{os,{unix,linux}},
{erlang_version,
"Erlang/OTP 19 [erts-8.3.5.6] [source] [64-bit] [smp:4:4] [async-threads:64] [hipe] [kernel-poll:true]\n"},
{memory,
[{connection_readers,0},
{connection_writers,0},
{connection_channels,0},
{connection_other,0},
{queue_procs,0},
{queue_slave_procs,0},
{plugins,8864},
{other_proc,19775968},
{metrics,184528},
{mgmt_db,0},
{mnesia,78624},
{other_ets,2287864},
{binary,117544},
{msg_index,57568},
{code,24983007},
{atom,1041593},
{other_system,10562176},
{allocated_unused,19299704},
{reserved_unallocated,131072},
{strategy,rss},
{total,[{erlang,59097736},{rss,78528512},{allocated,78397440}]}]},
{alarms,[]},
{listeners,[{clustering,25672,"::"},{'amqp/ssl',5671,"::"}]},
{vm_memory_calculation_strategy,rss},
{vm_memory_high_watermark,0.4},
{vm_memory_limit,6722687795},
{disk_free_limit,50000000},
{disk_free,29344493568},
{file_descriptors,
[{total_limit,924},{total_used,4},{sockets_limit,829},{sockets_used,0}]},
{processes,[{limit,1048576},{used,217}]},
{run_queue,0},
{uptime,1671},
{kernel,{net_ticktime,60}}]
客户端配置:
<!-- Spring AMQP Admin -->
<rabbit:admin id="rabbitAdmin" connection-factory="rabbitmqConnectionFactory" />
<!-- Connection Factory -->
<rabbit:connection-factory id="rabbitmqConnectionFactory"
connection-factory="clientConnectionFactory"
host="${rabbitmq.host:localhost}" port="${rabbitmq.port:5671}"
username="${rabbitmq.username}" password="${rabbitmq.password}"
virtual-host="${rabbitmq.vhost:/}" cache-mode="CHANNEL"
channel-cache-size="${rabbitmq.channel-cache-size:25}" />
<bean id="clientConnectionFactory"
class="org.springframework.amqp.rabbit.connection.RabbitConnectionFactoryBean">
<property name="useSSL" value="${rabbitmq.usessl}" />
</bean>
---示例代码段
// Sample of our code to declare exchange
logger.info("Declaring exchange: " + exchangeName);
try {
DirectExchange exchange = new DirectExchange(exchangeName, true,
false);
exchange.setIgnoreDeclarationExceptions(true);
rabbitAdmin.declareExchange(exchange);
logger.info("Declared/Declare-confirmed for "
+ exchangeType.toString() + " exchange: " + exchangeName);
return exchange;
} catch (Exception e) {
...
}
// Sample of our code to declare queue
try {
Queue queue = getQueue(queueName, exclusive, autodelete);
String s = rabbitAdmin.declareQueue(queue);
if (queueName.equals(s)) {
logger.info("Declared/Declare-confirmed for queue: "
+ queueName);
return queue;
} else {
logger.error("Failed to declare queue: " + queueName);
return null;
}
} catch (Exception e) {
...
}
// Binding
binding = BindingBuilder.bind(queue).to((DirectExchange) exchange)
.with(routingKey);
May 28 21:38:43 xxx-service-start.sh: [WARN] RabbitAdmin - Failed to declare queue: Queue [name=EVENT_RESPONSE_QUEUE, durable=true, autoDelete=false, exclusive=false, arguments=null], continuing... <org.springframework.amqp.AmqpTimeoutException: java.util.concurrent.TimeoutException>org.springframework.amqp.AmqpTimeoutException: java.util.concurrent.TimeoutException
May 28 21:38:43 xxx-service-start.sh: at org.springframework.amqp.rabbit.support.RabbitExceptionTranslator.convertRabbitAccessException(RabbitExceptionTranslator.java:74)
May 28 21:38:43 xxx-service-start.sh: at org.springframework.amqp.rabbit.connection.AbstractConnectionFactory.createBareConnection(AbstractConnectionFactory.java:309)
May 28 21:38:43 xxx-service-start.sh: at org.springframework.amqp.rabbit.connection.CachingConnectionFactory.createConnection(CachingConnectionFactory.java:547)
May 28 21:38:43 xxx-service-start.sh: at org.springframework.amqp.rabbit.core.RabbitTemplate.doExecute(RabbitTemplate.java:1389)
May 28 21:38:43 xxx-service-start.sh: at org.springframework.amqp.rabbit.core.RabbitTemplate.execute(RabbitTemplate.java:1370)
May 28 21:38:43 xxx-service-start.sh: at org.springframework.amqp.rabbit.core.RabbitTemplate.execute(RabbitTemplate.java:1346)
.....
May 28 21:38:43 xxx-service-start.sh: Caused by: java.util.concurrent.TimeoutException
May 28 21:38:43 xxx-service-start.sh: at com.rabbitmq.utility.BlockingCell.get(BlockingCell.java:77)
May 28 21:38:43 xxx-service-start.sh: at com.rabbitmq.utility.BlockingCell.uninterruptibleGet(BlockingCell.java:120)
May 28 21:38:43 xxx-service-start.sh: at com.rabbitmq.utility.BlockingValueOrException.uninterruptibleGetValue(BlockingValueOrException.java:36)
May 28 21:38:43 xxx-service-start.sh: at com.rabbitmq.client.impl.AMQChannel$BlockingRpcContinuation.getReply(AMQChannel.java:451)
May 28 21:38:43 xxx-service-start.sh: at com.rabbitmq.client.impl.AMQConnection.start(AMQConnection.java:323)
May 28 21:38:43 xxx-service-start.sh: at com.rabbitmq.client.impl.recovery.RecoveryAwareAMQConnectionFactory.newConnection(RecoveryAwareAMQConnectionFactory.java:63)
May 28 21:38:43 xxx-service-start.sh: at com.rabbitmq.client.impl.recovery.AutorecoveringConnection.init(AutorecoveringConnection.java:177)
May 28 21:38:43 xxx-service-start.sh: at com.rabbitmq.client.ConnectionFactory.newConnection(ConnectionFactory.java:1161)
May 28 21:38:43 xxx-service-start.sh: at com.rabbitmq.client.ConnectionFactory.newConnection(ConnectionFactory.java:1118)
May 28 21:38:43 xxx-service-start.sh: at com.rabbitmq.client.ConnectionFactory.newConnection(ConnectionFactory.java:1076)
May 28 21:38:43 xxx-service-start.sh: at com.rabbitmq.client.ConnectionFactory.newConnection(ConnectionFactory.java:1267)
May 28 21:38:43 xxx-service-start.sh: at org.springframework.amqp.rabbit.connection.AbstractConnectionFactory.createBareConnection(AbstractConnectionFactory.java:297)