[jboss-user] [JBoss Messaging] - Re: Problem getting correct IP for CallbackServer
clebert.suconic@jboss.com
do-not-reply at jboss.com
Tue Sep 5 12:32:58 EDT 2006
I will fix this by getting the IP from serverLocator.
This way, we will get the same IP configured.
| protected Connector startCallbackServer(InvokerLocator serverLocator) throws Exception
| {
| if (log.isTraceEnabled()) { log.trace(this + " setting up connection to " + serverLocator); }
|
| final int MAX_RETRIES = 50;
| boolean completed = false;
| Connector server = null;
| String serializationType = null;
| int count = 0;
|
| String thisAddress = serverLocator.getHost();
|
| boolean isSSL = serverLocator.getProtocol().equals("sslsocket");
| Map params = serverLocator.getParameters();
|
| if (params != null)
| {
| serializationType = (String)params.get("serializationtype");
| }
|
| while (!completed && count < MAX_RETRIES)
| {
| try
| {
| int bindPort = PortUtil.findFreePort(thisAddress);
|
| String callbackServerURI;
|
| if (isSSL)
| {
| // See http://jira.jboss.com/jira/browse/JBREM-470
| callbackServerURI =
| "sslsocket://" + thisAddress + ":" + bindPort + CALLBACK_SERVER_PARAMS +
| "&" + SSLSocketBuilder.REMOTING_SERVER_SOCKET_USE_CLIENT_MODE + "=true";
| }
| else
| {
| callbackServerURI = serverLocator.getProtocol() + "://" + thisAddress +
| ":" + bindPort + CALLBACK_SERVER_PARAMS;
| }
|
| if (serializationType != null)
| {
| callbackServerURI += "&serializationType=" + serializationType;
| }
|
| InvokerLocator callbackServerLocator = new InvokerLocator(callbackServerURI);
|
| log.debug(this + " starting callback server " + callbackServerLocator.getLocatorURI());
|
| server = new Connector();
| server.setInvokerLocator(callbackServerLocator.getLocatorURI());
| server.create();
| server.addInvocationHandler(JMS_CALLBACK_SUBSYSTEM, new CallbackManager());
| server.start();
|
| if (log.isTraceEnabled()) { log.trace("callback server started"); }
|
| completed = true;
| }
| catch (Exception e)
| {
| log.warn("Failed to start connection. Will retry", e);
|
| // Intermittently we can fail to open a socket on the address since it's already in use
| // This is despite remoting having checked the port is free. This is probably because
| // of the small window between remoting checking the port is free and getting the
| // port number and actually opening the connection during which some one else can use
| // that port. Therefore we catch this and retry.
|
| count++;
|
| if (count == MAX_RETRIES)
| {
| final String msg = "Cannot start callbackserver after " + MAX_RETRIES + " retries";
| log.error(msg, e);
| throw new MessagingJMSException(msg, e);
| }
| }
| }
|
| return server;
| }
|
View the original post : http://www.jboss.com/index.html?module=bb&op=viewtopic&p=3969529#3969529
Reply to the post : http://www.jboss.com/index.html?module=bb&op=posting&mode=reply&p=3969529
More information about the jboss-user
mailing list