summaryrefslogtreecommitdiff
path: root/java/common/src
diff options
context:
space:
mode:
authorRajith Muditha Attapattu <rajith@apache.org>2010-01-11 18:15:03 +0000
committerRajith Muditha Attapattu <rajith@apache.org>2010-01-11 18:15:03 +0000
commitdd9365811468be2dbb6bb34f5942bbe87ec4c830 (patch)
tree6e27fafa31fdfbed4b4e570a51da27380c465a8d /java/common/src
parent892e84f39a40a3868ca5630371784e883127f21a (diff)
downloadqpid-python-dd9365811468be2dbb6bb34f5942bbe87ec4c830.tar.gz
This is a fix for QPID-2173
The qpid.client_process could also be set to something more descriptive as follows using a jvm argument. -Dqpid.client_process="My Billing App" Currently added the prop names as plain strings. They will be moved to a single location as part of wider effort in organizing our configuration. git-svn-id: https://svn.apache.org/repos/asf/qpid/trunk/qpid@897985 13f79535-47bb-0310-9956-ffa450edef68
Diffstat (limited to 'java/common/src')
-rw-r--r--java/common/src/main/java/org/apache/qpid/transport/ClientDelegate.java34
1 files changed, 32 insertions, 2 deletions
diff --git a/java/common/src/main/java/org/apache/qpid/transport/ClientDelegate.java b/java/common/src/main/java/org/apache/qpid/transport/ClientDelegate.java
index 09d91ae6c6..934d8f2949 100644
--- a/java/common/src/main/java/org/apache/qpid/transport/ClientDelegate.java
+++ b/java/common/src/main/java/org/apache/qpid/transport/ClientDelegate.java
@@ -22,6 +22,8 @@ package org.apache.qpid.transport;
import static org.apache.qpid.transport.Connection.State.OPEN;
+import java.lang.management.ManagementFactory;
+import java.lang.management.RuntimeMXBean;
import java.util.HashMap;
import java.util.List;
import java.util.Map;
@@ -73,9 +75,13 @@ public class ClientDelegate extends ConnectionDelegate
@Override public void connectionStart(Connection conn, ConnectionStart start)
{
- Map clientProperties = new HashMap();
+ Map<String,Object> clientProperties = new HashMap<String,Object>();
clientProperties.put("qpid.session_flow", 1);
-
+ clientProperties.put("qpid.client_pid",getPID());
+ clientProperties.put("qpid.client_pid",clientProperties.get("qpid.client_pid"));
+ clientProperties.put("qpid.client_process",
+ System.getProperty("qpid.client_process","Qpid Java Client"));
+
List<Object> mechanisms = start.getMechanisms();
if (mechanisms == null || mechanisms.isEmpty())
{
@@ -173,4 +179,28 @@ public class ClientDelegate extends ConnectionDelegate
return max;
}
}
+
+ private int getPID()
+ {
+ RuntimeMXBean rtb = ManagementFactory.getRuntimeMXBean();
+ String processName = rtb.getName();
+ if (processName != null && processName.indexOf('@')>0)
+ {
+ try
+ {
+ return Integer.parseInt(processName.substring(0,processName.indexOf('@')));
+ }
+ catch(Exception e)
+ {
+ log.warn("Unable to get the client PID due to error",e);
+ return -1;
+ }
+ }
+ else
+ {
+ log.warn("Unable to get the client PID due to unsupported format : " + processName);
+ return -1;
+ }
+
+ }
}