我创建了一个rabbitmq的服务实例,并将其绑定到我的应用程序,这是一个带有spring-cloud库支持的spring启动应用程序。当我尝试运行应用程序时,它无法说出以下内容。
2016-03-30T17:30:51.77+0530 [App/0] OUT java.lang.IllegalStateException: In
valid configuration: 'virtualHost' must be non-null.
控制器类方法的代码如下。
@Controller
@RequestMapping("/rabbit")
public class RabbitController {
@Autowired
CachingConnectionFactory rabbitConnectionFactory;
@RequestMapping(method = RequestMethod.GET)
public @ResponseBody String onRootAccess() {
if (rabbitConnectionFactory != null) {
StringBuilder sb = new StringBuilder();
sb.append("Connected successfully to Redis!!!!!!!! \n");
sb.append("Host is " + rabbitConnectionFactory.getHost() + "\n ");
sb.append("Port is " + rabbitConnectionFactory.getPort() + "\n ");
sb.append("Virtual Host is " + rabbitConnectionFactory.getVirtualHost() + "\n ");
AmqpAdmin admin = new RabbitAdmin(rabbitConnectionFactory);
Queue queue = admin.declareQueue();
AmqpTemplate template = new RabbitTemplate(rabbitConnectionFactory);
sb.append("Pushing data foo in myqueue Queue \n ");
template.convertAndSend(queue.getName(), "foo");
String foo = (String) template.receiveAndConvert(queue.getName());
sb.append("Received data from myqueue is " + foo + "\n ");
return sb.toString();
} else {
return "connection not successful";
}
}
cf env显示了退回rabbitmq服务的以下详细信息。
"rabbitmq-3.5.6-lite": [
{
"credentials": {
"hostname": "10.3.1.1",
"password": "lmprqrhu3gafazkn",
"port": "32986",
"ports": {
"15672/tcp": "32985",
"5672/tcp": "32986"
},
"uri": "amqp://z6nfr8blhtwena67:lmprqrhu3gafazkn@10.3.1.1:32986",
"username": "z6nfr8blhtwena67"
},
"label": "rabbitmq-3.5.6-lite",
"name": "rabbitmq-service",
"plan": "free",
"tags": [
"rabbitmq",
"mbus",
"pubsub",
"amqp"
]
}
],
可能是什么问题?任何指向解决方案的指针都会有很大的帮助。如果需要更多信息,请告诉我。
此致 Subhankar