tags:

views:

326

answers:

8

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...

A: 

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.

svlists
A: 

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.

fawce
Jinks! (what we said as kids if we said the same thing simultaneously with someone else)
John M
haha, you owe me a coke :).
fawce
A: 

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);
...
John M
This isn't easy at all. How do you detect the client IP? Most IPs are behind a NAT in a intranet and you will only get an internal IP like 192.168.100.1
Marcel
Then you may be out of luck.- There's no standard way to accomplish it- You apparently can't get your client to help out+ Maybe your JMS implementation has some feature to do this. Not portable, but maybe good enough for you.
John M
A: 

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

+3  A: 

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

James Strachan
A: 

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.

iMack
A: 

Short answer: NO

Marcel
A: 

Under JBOSS, the getJMSMessageID() function only returns an ID values with some sort of timestamp, so this function is very implementation specific and can not be trusted to work in all situations.

Kevin S.