下面是我用来创建rabbitmq连接的java代码,用于在elasticsearch中创建索引,抛出异常。
当我使用factory.setHost("localhost");
代替factory.setHost("192.168.xx.xxx");
时,它工作正常,但当我使用IP时,它会导致我在异常之下
异常com.rabbitmq.client.PossibleAuthenticationFailureException:可能是由身份验证失败引起的
下面是我用于连接的java代码 -
factory = new ConnectionFactory();
String value = null;
if(serviceConfiguration == null)
throw new NullObjectFoundException("ServiceConfiguration object is not set");
factory.setUsername("guest");
factory.setPassword("guest");
factory.setVirtualHost("/");
factory.setHost("192.168.xx.xxx");
factory.setPort(Integer.parseInt( 5672));
try{
conn = factory.newConnection();
return conn;
} // try
catch(Exception e){
System.out.println(e);
} // catch