Question

I have a system in which different server processes are handling requests passed as JMS messages from various clients via a JMS broker.

I am trying to identify the source of the messages. Is there a way to get the IP or some identifying information about the origin ?

Clarification: I already have the client deployed by unknown users, so I'm trying to avoid changing message classes...

Was it helpful?

Solution

There is an optional JMS header mentioned in the JMS specification called JMSXUserID which which identifies the user sending a message (which the broker validates and ensures is correct to avoid spoofing) which some JMS providers support.

For example here is how to enable it in Apache ActiveMQ

OTHER TIPS

I do not believe so. At least I was not able to find a way.

If you need to send a reply back to the source of the message, you can have the sender set the "JMSReplyTo" property and reply back to that destination.

Or, you could change your messaging schema slightly and embed the source information message itself. The sender would identify himself in the message and the receive could read it from there.

If you have control over the construction of the messages being sent, you can always add the IP address to the message as a property. Then you could check for the value with the getStringProperty method on Message.

If you control the code of the clients sending the messages, you could invent some property name, say "IPOfSender", and include that property on every message with Message.setStringProperty().

// client code
String myIPString = ...;
Message m = session.createTextMessage();
m.setStringProperty("IPOfSender", myIPString);
...

Its depends on your JMS Server. Some servers have Admin tools/API's that allow you to view connection details.

Using glassfish, if you look at the getJMSMessageID() of the message, you should see a string to the effect of "ID:40-192.168.0.242(f5:62:c6:58:22:6f)-52506-122885191641". It appears as though the IP is a substring of the message id.

Please note that this is what I can see under our setup, so there may be other factors at play (ie. spring), but I know that string wasn't created by us programatically.

Short answer: NO

Licensed under: CC-BY-SA with attribution
Not affiliated with StackOverflow
scroll top