BF [2865590] - Replication: opening connections

https://sourceforge.net/tracker/?func=detail&atid=879332&aid=2865590&group_id=176962
Patch [2865593] - BR:2865590 Replication: opening connections
https://sourceforge.net/tracker/?func=detail&aid=2865593&group_id=176962&atid=879334
Thank's to Colin!
This commit is contained in:
trifonnt 2009-09-24 10:05:25 +00:00
parent 304843ba46
commit 88a1b709b1
1 changed files with 19 additions and 12 deletions

View File

@ -191,15 +191,14 @@ public class TopicListener implements MessageListener {
ActiveMQConnectionFactory factory = new ActiveMQConnectionFactory( url ); ActiveMQConnectionFactory factory = new ActiveMQConnectionFactory( url );
log.finest("ActiveMQConnectionFactory = " + factory); log.finest("ActiveMQConnectionFactory = " + factory);
if (userName !=null && password != null) { if (userName !=null && password !=null) {
conn = factory.createConnection(userName, password); conn = factory.createConnection(userName, password);
} else { } else {
conn = factory.createConnection(); conn = factory.createConnection();
} }
log.finest("conn = " + conn ); log.finest("conn = " + conn );
if(conn.getClientID()==null) if (conn.getClientID()==null)
{ {
try try
{ {
@ -208,17 +207,27 @@ public class TopicListener implements MessageListener {
catch (Exception e) catch (Exception e)
{ {
log.info("Connection with clientID '" + clientID +"' already exists"); log.info("Connection with clientID '" + clientID +"' already exists");
conn.close();
return; return;
} }
}else } else {
{ if (conn.getClientID().equals(clientID))
if(conn.getClientID().equals(clientID))
{ {
log.warning("Connection with clientID '" + clientID log.warning("Connection with clientID '" + clientID + "' already exists");
+ "' already exists"); conn.close();
return; return;
}else } else {
conn.setClientID( clientID ); try
{
conn.setClientID( clientID );
}
catch (Exception e)
{
log.info("Error while invoking setClientID(" + clientID +")! " + e.getMessage());
conn.close();
return;
}
}
} }
@ -254,7 +263,6 @@ public class TopicListener implements MessageListener {
pLog.setReference( logReference.toString() ); pLog.setReference( logReference.toString() );
boolean resultSave = pLog.save(); boolean resultSave = pLog.save();
log.finest("Result Save = " + resultSave); log.finest("Result Save = " + resultSave);
} }
/** /**
@ -302,7 +310,6 @@ public class TopicListener implements MessageListener {
} else { } else {
log.finest("Received NO TEXT Message: " ); log.finest("Received NO TEXT Message: " );
// Received non text message!!!
} }
} }