use of com.sun.messaging.jmq.io.MQAddress in project openmq by eclipse-ee4j.
the class MQAddressUtil method getServiceMQAddress.
/**
* Return connection service MQAddress. Connection service addresses can have 2 forms and the bypassPortmapper parameter
* allows the caller to select which one is desired. The 2 forms depend on whether the client will contact the
* portmapper (mq://host:port) or the connection service directly ({mqtcp,mqssl}://host:port/svcname).
*
* @param svcName Connection service name.
* @param port Portmapper port or connection service port.
* @param bypassPortmapper Boolean to indicate which type of address is desired. If the value for bypassPortmapper is
* false, the address will be of the form mq://host:port/svcName. If the value is true, the scheme will be one of mqtcp
* or mqssl. The address will be of the form scheme://host:svc_port/svc_name. e.g. mqtcp://myhost:87635/jms
* @return Connection service address.
*/
public static MQAddress getServiceMQAddress(String svcName, Integer port, boolean bypassPortmapper) {
MQAddress addr = null;
String scheme = "mq";
Logger logger = Globals.getLogger();
if ((svcName == null) || (svcName.equals("")) || (port == null)) {
if (DEBUG) {
logger.log(Logger.DEBUG, "Null service name and/or port passed in to getServiceMQAddress()");
}
return (null);
}
if (bypassPortmapper) {
scheme = getScheme(svcName);
}
if (scheme == null) {
return (null);
}
if (bypassPortmapper) {
try {
String url = scheme + "://" + Globals.getMQAddress().getHostName() + ":" + port.toString() + "/" + svcName;
addr = MQAddress.getMQAddress(url);
} catch (Exception e) {
if (DEBUG) {
logger.log(Logger.DEBUG, "Failed to create service address", e);
}
}
} else {
try {
String url = Globals.getMQAddress().getHostName() + ":" + port.toString() + "/" + svcName;
addr = PortMapperMQAddress.createAddress(url);
} catch (Exception e) {
if (DEBUG) {
logger.log(Logger.DEBUG, "Failed to create service address", e);
}
}
}
return (addr);
}
use of com.sun.messaging.jmq.io.MQAddress in project openmq by eclipse-ee4j.
the class MQAddressUtil method getPortMapperMQAddress.
/**
* Return portmapper MQAddress. This MQAddress does not include the service name and is of the form mq://host:port
*
* @param port Portmapper port
* @return Portmapper address. This MQAddress does not include the service name. It is of the form mq://host:port.
*/
public static MQAddress getPortMapperMQAddress(Integer port) {
MQAddress addr = null;
if (port == null) {
if (DEBUG) {
Logger logger = Globals.getLogger();
logger.log(Logger.DEBUG, "Null port passed in to getPortMapperMQAddress()");
}
return (null);
}
try {
String url = Globals.getMQAddress().getHostName() + ":" + port.toString();
addr = PortMapperMQAddress.createAddress(url);
} catch (Exception e) {
if (DEBUG) {
Logger logger = Globals.getLogger();
logger.log(Logger.DEBUG, "Failed to create portmapper address", e);
}
}
return (addr);
}
use of com.sun.messaging.jmq.io.MQAddress in project openmq by eclipse-ee4j.
the class Agent method getDefaultJMXUrlPathBase.
public String getDefaultJMXUrlPathBase() throws BrokerException {
MQAddress addr = Globals.getMQAddress();
String rmiRegHostName, brokerHostName, ret = null;
int brokerPort, rmiRegistryPort;
if (addr == null) {
return (null);
}
/*
* These other methods work too. Would be good if we could obtain a fully qualified hostname i.e. with domain.
* brokerHostName = Globals.getBrokerHostName(); brokerHostName = Globals.getBrokerInetAddress().getCanonicalHostName();
*/
brokerHostName = addr.getHostName();
rmiRegHostName = Globals.getJMXHostname();
brokerPort = addr.getPort();
rmiRegistryPort = getRmiRegistryPort();
/*
* rmiRegHostName can be null if imq.jmx.hostname or imq.hostname is not set.
*/
if (rmiRegHostName == null) {
rmiRegHostName = brokerHostName;
} else {
try {
rmiRegHostName = MQAddress.getMQAddress(rmiRegHostName, rmiRegistryPort).getHostName();
} catch (MalformedURLException e) {
throw new BrokerException(e.toString(), e);
}
}
/*
* The default urlpath base is: /jndi/rmi://<brokerhost>:<rmiport>/<brokerhost>/<brokerport>/ e.g
* /jndi/rmi://myhost:1099/myhost/7676/
*/
ret = "/jndi/rmi://" + rmiRegHostName + ":" + Integer.toString(rmiRegistryPort) + "/" + brokerHostName + "/" + Integer.toString(brokerPort) + "/";
return (ret);
}
use of com.sun.messaging.jmq.io.MQAddress in project openmq by eclipse-ee4j.
the class ClusterMonitor method getLocalBrokerInfo.
public CompositeData getLocalBrokerInfo() throws MBeanException {
ClusterManager cm = Globals.getClusterManager();
CompositeData cd = null;
if (cm == null) {
return (null);
}
MQAddress address = cm.getMQAddress();
String id = null;
try {
id = cm.lookupBrokerID(BrokerMQAddress.createAddress(address.toString()));
} catch (Exception e) {
handleGetterException(ClusterAttributes.LOCAL_BROKER_INFO, e);
}
if ((id == null) || (id.equals(""))) {
return (null);
}
try {
ClusteredBroker cb = cm.getBroker(id);
if (cb == null) {
return (null);
}
cd = getCompositeData(cb);
} catch (Exception e) {
handleGetterException(ClusterAttributes.LOCAL_BROKER_INFO, e);
}
return (cd);
}
use of com.sun.messaging.jmq.io.MQAddress in project openmq by eclipse-ee4j.
the class ClusterManagerImpl method mqAddressChanged.
/**
* Method called when the MQAddress is changed on the system.
*
* @param address the new address of the local brokers portmapper
*/
protected void mqAddressChanged(MQAddress address) throws Exception {
ClusteredBroker cb = getLocalBroker();
MQAddress oldAddress = cb.getBrokerURL();
cb.setBrokerURL(address);
brokerChanged(ClusterReason.ADDRESS_CHANGED, cb.getBrokerName(), oldAddress, address, null, null);
}
Aggregations