Commit d03caafd authored by Andre Freyssinet's avatar Andre Freyssinet

FIx JORAM-333: Allows to set a user-defined prefix to the JMS MessageID.

The prefix can be determined either by the ConnectionFactory (method
setMessageIdPrefix of FactoryParameters), or by the  property
"org.objectweb.joram.client.jms.messageid.prefix".
parent 1cf62214
/*
* 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
......@@ -54,6 +54,7 @@ import org.objectweb.joram.shared.security.Identity;
import org.objectweb.util.monolog.api.BasicLevel;
import org.objectweb.util.monolog.api.Logger;
import fr.dyade.aaa.common.Configuration;
import fr.dyade.aaa.common.Debug;
import fr.dyade.aaa.util.management.MXWrapper;
......@@ -218,6 +219,9 @@ public class Connection implements javax.jms.Connection, ConnectionMBean {
logger.log(BasicLevel.DEBUG, "Connection.<init>");
}
// This property allows to customize the JMS MessageID adding the specified string.
public final String MESSAGE_ID_PREFIX_PROPERTY = "org.objectweb.joram.client.jms.messageid.prefix";
/**
* Open the <code>Connection</code>.
*
......@@ -259,7 +263,18 @@ public class Connection implements javax.jms.Connection, ConnectionMBean {
key = rep.getCnxKey();
sessionsC = new AtomicCounter("c" + key + 's');
messagesC = new AtomicCounter("ID:" + proxyId.substring(1) + 'c' + key + 'm');
// Get an eventual MessageID prefix defined by a global property. If it is not defined checks
// in the settings of the ConnectionFactory.
String messageIdPrefix = Configuration.getProperty(MESSAGE_ID_PREFIX_PROPERTY);
if (messageIdPrefix == null)
messageIdPrefix = factoryParameters.messageIdPrefix;
if (messageIdPrefix == null)
messagesC = new AtomicCounter("ID:" + proxyId.substring(1) + 'c' + key + 'm');
else
messagesC = new AtomicCounter("ID:" + messageIdPrefix + '_' + proxyId.substring(1) + 'c' + key + 'm');
subsC = new AtomicCounter("c" + key + "sub");
stringImage = getClass().getSimpleName() + ":c" + key + '[' + proxyId + ']';
......
/*
* JORAM: Java(TM) Open Reliable Asynchronous Messaging
* Copyright (C) 2001 - 2015 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
......@@ -267,6 +267,29 @@ public class FactoryParameters implements java.io.Serializable, Cloneable {
*/
public boolean noAckedQueue = false;
/**
* This attribute allows to customize the JMS MessageID adding the specified string.
* This value is overloaded by the property org.objectweb.joram.client.jms.messageid.prefix if it defined.
* By default empty.
*/
public String messageIdPrefix = null;
/**
* Gets the prefix to add to the JMS MessageID of connection created from this factory.
* @return the prefix to add to the JMS MessageID.
*/
public String getMessageIdPrefix() {
return messageIdPrefix;
}
/**
* Setsthe prefix to add to the JMS MessageID of connection created from this factory.
* @param messageIdPrefix the prefix to add to the JMS MessageID.
*/
public void setMessageIdPrefix(String messageIdPrefix) {
this.messageIdPrefix = messageIdPrefix;
}
/**
* Constructs a <code>FactoryParameters</code> instance.
*
......@@ -299,7 +322,7 @@ public class FactoryParameters implements java.io.Serializable, Cloneable {
// }
public void toReference(Reference ref, String prefix) {
// if (prefix == null) prefix = "cf";
// if (prefix == null) prefix = "cf";
ref.add(new StringRefAddr(prefix + ".host", getHost()));
ref.add(new StringRefAddr(prefix + ".port",
......@@ -348,10 +371,12 @@ public class FactoryParameters implements java.io.Serializable, Cloneable {
ref.add(new StringRefAddr(prefix + ".outLocalPort", new Integer(outLocalPort).toString()));
if (outLocalAddress != null)
ref.add(new StringRefAddr(prefix + ".outLocalAddress", outLocalAddress));
if(!inInterceptors.isEmpty())
if (!inInterceptors.isEmpty())
ref.add(new StringRefAddr(prefix + ".inInterceptors", getListInInterceptorClassName()));
if(outInterceptors!=null)
ref.add(new StringRefAddr(prefix + ".outInterceptors", getListOutInterceptorClassName()));
if (outInterceptors!=null)
ref.add(new StringRefAddr(prefix + ".outInterceptors", getListOutInterceptorClassName()));
if (messageIdPrefix != null)
ref.add(new StringRefAddr(prefix + ".messageIdPrefix", messageIdPrefix));
}
// public void fromReference(Reference ref) {
......@@ -401,6 +426,7 @@ public class FactoryParameters implements java.io.Serializable, Cloneable {
if(interceptorRef!=null){
setListOutInterceptorClassName((String)interceptorRef.getContent());
}
messageIdPrefix = (String) ref.get(prefix + ".messageIdPrefix").getContent();
}
public Hashtable code(Hashtable h, String prefix) {
......@@ -421,7 +447,7 @@ public class FactoryParameters implements java.io.Serializable, Cloneable {
h.put(prefix + ".cnxPendingTimer", new Integer(cnxPendingTimer));
h.put(prefix + ".socketFactory", socketFactory);
h.put(prefix + ".implicitAck", new Boolean(implicitAck));
h.put(prefix + ".asyncSend", new Boolean(asyncSend));
h.put(prefix + ".queueMessageReadMax", new Integer(queueMessageReadMax));
......@@ -440,7 +466,10 @@ public class FactoryParameters implements java.io.Serializable, Cloneable {
if(inInterceptors!=null)
h.put(prefix + ".inInterceptors", getListInInterceptorClassName());
if(outInterceptors!=null)
h.put(prefix + ".outInterceptors", getListOutInterceptorClassName());
h.put(prefix + ".outInterceptors", getListOutInterceptorClassName());
if (messageIdPrefix != null)
h.put(prefix + ".messageIdPrefix", messageIdPrefix);
return h;
}
......@@ -483,6 +512,7 @@ public class FactoryParameters implements java.io.Serializable, Cloneable {
if(listInterceptorClassNames!=null){
setListOutInterceptorClassName(listInterceptorClassNames);
}
messageIdPrefix = (String) h.get(prefix + ".messageIdPrefix");
}
public Object clone() {
......@@ -496,36 +526,39 @@ public class FactoryParameters implements java.io.Serializable, Cloneable {
}
public String toString() {
StringBuffer strbuf = new StringBuffer();
strbuf.append('(').append(super.toString());
strbuf.append(",host=").append(host);
strbuf.append(",port=").append(port);
strbuf.append(",url=").append(url);
strbuf.append(",connectingTimer=").append(connectingTimer);
strbuf.append(",txPendingTimer=").append(txPendingTimer);
strbuf.append(",cnxPendingTimer=").append(cnxPendingTimer);
strbuf.append(",implicitAck=").append(implicitAck);
strbuf.append(",asyncSend=").append(asyncSend);
strbuf.append(",queueMessageReadMax=").append(queueMessageReadMax);
strbuf.append(",topicAckBufferMax=").append(topicAckBufferMax);
strbuf.append(",multiThreadSync=").append(multiThreadSync);
strbuf.append(",multiThreadSyncDelay=").append(multiThreadSyncDelay);
strbuf.append(",multiThreadSyncThreshold=").append(multiThreadSyncThreshold);
strbuf.append(",topicPassivationThreshold=").append(topicPassivationThreshold);
strbuf.append(",topicActivationThreshold=").append(topicActivationThreshold);
strbuf.append(",compressedMinSize=").append(compressedMinSize);
strbuf.append(",compressionLevel=").append(compressionLevel);
strbuf.append(",noAckedQueue=").append(noAckedQueue);
strbuf.append(",outLocalAddress=").append(outLocalAddress);
strbuf.append(",outLocalPort=").append(outLocalPort);
if(inInterceptors!=null)
strbuf.append(",inInterceptors=").append(getListInInterceptorClassName());
if(outInterceptors!=null)
strbuf.append(",outInterceptors=").append(getListOutInterceptorClassName());
return strbuf.toString();
StringBuffer strbuf = new StringBuffer();
strbuf.append('(').append(super.toString());
strbuf.append(",host=").append(host);
strbuf.append(",port=").append(port);
strbuf.append(",url=").append(url);
strbuf.append(",connectingTimer=").append(connectingTimer);
strbuf.append(",txPendingTimer=").append(txPendingTimer);
strbuf.append(",cnxPendingTimer=").append(cnxPendingTimer);
strbuf.append(",implicitAck=").append(implicitAck);
strbuf.append(",asyncSend=").append(asyncSend);
strbuf.append(",queueMessageReadMax=").append(queueMessageReadMax);
strbuf.append(",topicAckBufferMax=").append(topicAckBufferMax);
strbuf.append(",multiThreadSync=").append(multiThreadSync);
strbuf.append(",multiThreadSyncDelay=").append(multiThreadSyncDelay);
strbuf.append(",multiThreadSyncThreshold=").append(multiThreadSyncThreshold);
strbuf.append(",topicPassivationThreshold=").append(topicPassivationThreshold);
strbuf.append(",topicActivationThreshold=").append(topicActivationThreshold);
strbuf.append(",compressedMinSize=").append(compressedMinSize);
strbuf.append(",compressionLevel=").append(compressionLevel);
strbuf.append(",noAckedQueue=").append(noAckedQueue);
strbuf.append(",outLocalAddress=").append(outLocalAddress);
strbuf.append(",outLocalPort=").append(outLocalPort);
if (inInterceptors != null)
strbuf.append(",inInterceptors=").append(getListInInterceptorClassName());
if (outInterceptors != null)
strbuf.append(",outInterceptors=").append(getListOutInterceptorClassName());
if (messageIdPrefix != null)
strbuf.append(",messageIdPrefix=").append(messageIdPrefix);
return strbuf.toString();
}
// Methods needed to manage interceptors in administration stuff.
......@@ -661,6 +694,8 @@ public class FactoryParameters implements java.io.Serializable, Cloneable {
outLocalAddress = value;
} else if ("clientID".equals(name)) {
clientID = value;
} else if ("messageIdPrefix".equals(name)) {
messageIdPrefix = value;
} else {
logger.log(BasicLevel.ERROR,
"Could not set FactoryParameters <" + name + ", " + value + ">",
......
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