我刚开始研究rabbitmq。因此,虽然只是在使用java客户端在rabbitmq中做一些基本的东西我得到了以下问题
Exception in thread "main" java.util.concurrent.TimeoutException
at com.rabbitmq.utility.BlockingCell.get(BlockingCell.java:76)
at com.rabbitmq.utility.BlockingCell.uninterruptibleGet(BlockingCell.java:110)
at com.rabbitmq.utility.BlockingValueOrException.uninterruptibleGetValue(BlockingValueOrException.java:36)
at com.rabbitmq.client.impl.AMQChannel$BlockingRpcContinuation.getReply(AMQChannel.java:372)
at com.rabbitmq.client.impl.AMQConnection.start(AMQConnection.java:298)
at com.rabbitmq.client.impl.recovery.RecoveryAwareAMQConnectionFactory.newConnection(RecoveryAwareAMQConnectionFactory.java:58)
at com.rabbitmq.client.impl.recovery.AutorecoveringConnection.init(AutorecoveringConnection.java:103)
at com.rabbitmq.client.ConnectionFactory.newConnection(ConnectionFactory.java:877)
at com.rabbitmq.client.ConnectionFactory.newConnection(ConnectionFactory.java:839)
at com.rabbitmq.client.ConnectionFactory.newConnection(ConnectionFactory.java:797)
at com.rabbitmq.client.ConnectionFactory.newConnection(ConnectionFactory.java:930)
at com.sharique.jobs.HelloWorldProducer.produce(HelloWorldProducer.java:32)
及以下是创建连接的代码
ConnectionFactory factory = new ConnectionFactory();
factory.setUsername("guest");
factory.setPassword("guest");
factory.setHost("localhost");
factory.setPort(5672);
Connection connection = factory.newConnection();
还有一件事,即rabbitmq服务器正在运行。
请帮忙
答案 0 :(得分:0)
将虚拟主机setVirtualHost
设置为:
String uri = System.getenv("URL");
if (uri == null) uri = "amqp://guest:guest@localhost";
ConnectionFactory factory = new ConnectionFactory();
factory.setUri(uri);
.
.
factory.setVirtualHost("/");
Connection connection = factory.newConnection();
您也可以设置setConnectionTimeout
。
答案 1 :(得分:-3)
打字" netstat / an |找到" 5672" "在cmd上。 如果该端口正在侦听,请更改端口或重新启动服务器