你好我想问一下,基于AMQP协议实现的消息总线客户端方案中的connection方法中有这几个string类型
ip
- 服务IP
port
- 端口号
hostName
- 虚拟主机名
usrName
- 用户名
password
- 用户密码
clientID
- 用户自定义客户端名,可以用来区分是谁发送的消息
这里指的IP是localhost还是什么?hostName,uerName,password是指的iserver上的还是iportal上的还是什么?我看了消息总线的simplecode还是不很理解,我的code上是这样写的:
private String sIP = "localhost";
private int sPort = 5672;
private String sHostName = "/";//?"/sm/sensors"
private String sUserName = "guest";
private String sPassword = "guest";
我的iserver、iportal连接正常也没有报错,但是会显示服务器连接失败,报的错是出自这里:
public boolean sendMessageByType(String geoJson, int type) {
if(mAMQPSender != null)
{
// publish message
if (geoJson.isEmpty()) {
return true;
}
else {
boolean bSend = false;
if (type == 1) {// multimedia
bSend = mAMQPSender.sendMessage(sExchange, geoJson, sRoutingKey_MultiMedia);
} else if (type == 2) {//plot
bSend = mAMQPSender.sendMessage(sExchange, geoJson, sRoutingKey_Plot);
} else if (type == 3) {//text
bSend = mAMQPSender.sendMessage(sExchange, geoJson, sRoutingKey_TxtMessage);
} else if (type == 0) {//location
bSend = mAMQPSender.sendMessage(sExchange, geoJson, sRoutingKey_Location);
}
System.out.println("send:"+bSend);
}
}
else
{
System.out.println("No connection has been made, please create the connection");
return false;
}
return true;
}