Commit 1cf62214 authored by Andre Freyssinet's avatar Andre Freyssinet

JORAM-332: Connection and Session tracking.

parent c0cbfb75
......@@ -80,6 +80,7 @@ import fr.dyade.aaa.util.management.MXWrapper;
*/
public class Connection implements javax.jms.Connection, ConnectionMBean {
public static Logger logger = Debug.getLogger(Connection.class.getName());
public static Logger tracker = Debug.getLogger(Connection.class.getName() + ".tracker");
/**
* Status of the connection.
......@@ -167,6 +168,10 @@ public class Connection implements javax.jms.Connection, ConnectionMBean {
/** Client's agent proxy identifier. */
private String proxyId;
final String getProxyId() {
return proxyId;
}
/** Connection key. */
private int key;
......@@ -227,6 +232,7 @@ public class Connection implements javax.jms.Connection, ConnectionMBean {
if (logger.isLoggable(BasicLevel.DEBUG))
logger.log(BasicLevel.DEBUG,
"Connection.open(" + factoryParameters + ',' + requestChannel + ')');
// We need to clone the FactoryParameter Object to avoid side-effect with
// external modifications.
this.factoryParameters = (FactoryParameters) factoryParameters.clone();
......@@ -256,8 +262,11 @@ public class Connection implements javax.jms.Connection, ConnectionMBean {
messagesC = new AtomicCounter("ID:" + proxyId.substring(1) + 'c' + key + 'm');
subsC = new AtomicCounter("c" + key + "sub");
stringImage = "Connection[" + proxyId + ':' + key + ']';
stringImage = getClass().getSimpleName() + ":c" + key + '[' + proxyId + ']';
hashCode = (proxyId.hashCode() & 0xFFFF0000) + key;
if (tracker.isLoggable(BasicLevel.DEBUG))
tracker.log(BasicLevel.DEBUG, stringImage + " established.", new Exception());
mtpx.setDemultiplexerDaemonName(toString());
......@@ -1077,6 +1086,9 @@ public class Connection implements javax.jms.Connection, ConnectionMBean {
synchronized (this) {
setStatus(Status.CLOSE);
}
if (tracker.isLoggable(BasicLevel.DEBUG))
tracker.log(BasicLevel.DEBUG, stringImage + " closed.", new Exception());
}
......
/*
* JORAM: Java(TM) Open Reliable Asynchronous Messaging
* Copyright (C) 2001 - 2013 ScalAgent Distributed Technologies
* Copyright (C) 2001 - 2019 ScalAgent Distributed Technologies
* Copyright (C) 1996 - 2000 Dyade
*
* This library is free software; you can redistribute it and/or
......@@ -48,11 +48,6 @@ public class QueueSession extends Session implements javax.jms.QueueSession {
super(cnx, transacted, acknowledgeMode, mtpx);
}
/** Returns a String image of this session. */
public String toString() {
return "QueueSess:" + getId();
}
/**
* API method.
* Creates a QueueSender object to send messages to the specified queue.
......
......@@ -101,6 +101,7 @@ public class Session implements javax.jms.Session, SessionMBean {
public static Logger logger = Debug.getLogger(Session.class.getName());
public static Logger trace = Debug.getLogger(Session.class.getName() + ".Message");
public static Logger tracker = Debug.getLogger(Session.class.getName() + ".tracker");
/**
* With this acknowledgment mode, the client acknowledges a consumed message by calling
......@@ -198,7 +199,7 @@ public class Session implements javax.jms.Session, SessionMBean {
protected javax.jms.MessageListener messageListener;
/** The identifier of the session. */
private String ident;
private final String ident;
/** The connection the session belongs to. */
private Connection cnx;
......@@ -788,6 +789,8 @@ public class Session implements javax.jms.Session, SessionMBean {
throw new JMSException("Can't create a non transacted session with an invalid acknowledge mode.");
this.ident = cnx.nextSessionId();
this.stringImage = getClass().getSimpleName() + ':' + ident + '[' + cnx.getProxyId() + ']';
this.cnx = cnx;
this.transacted = transacted;
this.acknowledgeMode = acknowledgeMode;
......@@ -822,6 +825,9 @@ public class Session implements javax.jms.Session, SessionMBean {
topicPassivationThreshold = cnx.getTopicPassivationThreshold();
compressedMinSize = cnx.getCompressedMinSize();
compressionLevel = cnx.getCompressionLevel();
if (tracker.isLoggable(BasicLevel.DEBUG))
tracker.log(BasicLevel.DEBUG, stringImage + " initialized.", new Exception());
setStatus(Status.STOP);
setSessionMode(SessionMode.NONE);
......@@ -914,9 +920,11 @@ public class Session implements javax.jms.Session, SessionMBean {
throw new IllegalStateException("The client identifier is unset.");
}
private String stringImage = null;
/** Returns a String image of this session. */
public String toString() {
return "Sess:" + ident;
public final String toString() {
return stringImage;
}
/**
......@@ -1855,6 +1863,9 @@ public class Session implements javax.jms.Session, SessionMBean {
synchronized (this) {
setStatus(Status.CLOSE);
}
if (tracker.isLoggable(BasicLevel.DEBUG))
tracker.log(BasicLevel.DEBUG, stringImage + " closed.", new Exception());
}
/**
......
/*
* JORAM: Java(TM) Open Reliable Asynchronous Messaging
* Copyright (C) 2001 - 2013 ScalAgent Distributed Technologies
* Copyright (C) 1996 - Dyade
* Copyright (C) 2001 - 2019 ScalAgent Distributed Technologies
* Copyright (C) 1996 - 2000 Dyade
*
* This library is free software; you can redistribute it and/or
* modify it under the terms of the GNU Lesser General Public
......@@ -31,8 +31,7 @@ import org.objectweb.joram.client.jms.connection.RequestMultiplexer;
/**
* Implements the <code>javax.jms.TopicSession</code> interface.
*/
public class TopicSession extends Session implements javax.jms.TopicSession
{
public class TopicSession extends Session implements javax.jms.TopicSession {
/**
* Constructs a topic session.
*
......@@ -45,18 +44,10 @@ public class TopicSession extends Session implements javax.jms.TopicSession
TopicSession(Connection cnx,
boolean transacted,
int acknowledgeMode,
RequestMultiplexer mtpx)
throws JMSException {
RequestMultiplexer mtpx) throws JMSException {
super(cnx, transacted, acknowledgeMode, mtpx);
}
/** Returns a String image of this session. */
public String toString()
{
return "TopicSess:" + getId();
}
/**
* API method.
*
......@@ -64,9 +55,7 @@ public class TopicSession extends Session implements javax.jms.TopicSession
* connection is broken.
* @exception JMSException If the creation fails for any other reason.
*/
public javax.jms.TopicPublisher
createPublisher(javax.jms.Topic topic) throws JMSException
{
public javax.jms.TopicPublisher createPublisher(javax.jms.Topic topic) throws JMSException {
checkClosed();
TopicPublisher tp = new TopicPublisher(this, (Destination) topic);
addProducer(tp);
......
Markdown is supported
0% or
You are about to add 0 people to the discussion. Proceed with caution.
Finish editing this message first!
Please register or to comment