AMQP-97: add cookie in constructor
This commit is contained in:
@@ -22,6 +22,7 @@ import org.apache.commons.logging.LogFactory;
|
||||
import org.springframework.beans.factory.InitializingBean;
|
||||
import org.springframework.erlang.OtpIOException;
|
||||
import org.springframework.util.Assert;
|
||||
import org.springframework.util.StringUtils;
|
||||
|
||||
import com.ericsson.otp.erlang.OtpAuthException;
|
||||
import com.ericsson.otp.erlang.OtpPeer;
|
||||
@@ -84,7 +85,7 @@ public class SimpleConnectionFactory implements ConnectionFactory, InitializingB
|
||||
|
||||
private OtpPeer otpPeer;
|
||||
|
||||
public SimpleConnectionFactory(String selfNodeName, String cookie, String peerNodeName) {
|
||||
public SimpleConnectionFactory(String selfNodeName, String peerNodeName, String cookie) {
|
||||
this(selfNodeName, peerNodeName);
|
||||
this.cookie = cookie;
|
||||
}
|
||||
@@ -121,10 +122,10 @@ public class SimpleConnectionFactory implements ConnectionFactory, InitializingB
|
||||
logger.debug("Creating OtpSelf with node name = [" + selfNodeNameToUse + "]");
|
||||
}
|
||||
try {
|
||||
if (this.cookie == null) {
|
||||
this.otpSelf = new OtpSelf(selfNodeNameToUse.trim());
|
||||
} else {
|
||||
if (StringUtils.hasText(cookie)) {
|
||||
this.otpSelf = new OtpSelf(selfNodeNameToUse.trim(), this.cookie);
|
||||
} else {
|
||||
this.otpSelf = new OtpSelf(selfNodeNameToUse.trim());
|
||||
}
|
||||
} catch (IOException e) {
|
||||
throw new OtpIOException(e);
|
||||
|
||||
@@ -74,6 +74,8 @@ public class RabbitBrokerAdmin implements RabbitBrokerOperations {
|
||||
|
||||
private final String hostName;
|
||||
|
||||
private final String cookie;
|
||||
|
||||
// TODO: RABBITMQ_NODE_PORT=5672
|
||||
|
||||
static {
|
||||
@@ -89,9 +91,14 @@ public class RabbitBrokerAdmin implements RabbitBrokerOperations {
|
||||
}
|
||||
|
||||
public RabbitBrokerAdmin(String hostName) {
|
||||
this(hostName, null);
|
||||
}
|
||||
|
||||
public RabbitBrokerAdmin(String hostName, String cookie) {
|
||||
if (Os.isFamily("windows") && !DEFAULT_HOST.equals(hostName)) {
|
||||
hostName = hostName.toUpperCase();
|
||||
}
|
||||
this.cookie = cookie;
|
||||
this.hostName = hostName;
|
||||
this.executor.setDaemon(true);
|
||||
initializeDefaultErlangTemplate(hostName);
|
||||
@@ -514,7 +521,7 @@ public class RabbitBrokerAdmin implements RabbitBrokerOperations {
|
||||
String peerNodeName = "rabbit@" + host;
|
||||
logger.debug("Creating jinterface connection with peerNodeName = [" + peerNodeName + "]");
|
||||
SimpleConnectionFactory otpConnectionFactory = new SimpleConnectionFactory("rabbit-spring-monitor",
|
||||
peerNodeName);
|
||||
peerNodeName, this.cookie);
|
||||
otpConnectionFactory.afterPropertiesSet();
|
||||
createErlangTemplate(otpConnectionFactory);
|
||||
}
|
||||
|
||||
Reference in New Issue
Block a user