You are viewing a plain text version of this content. The canonical link for it is here.
Posted to users@activemq.apache.org by gauche <ke...@hsbcib.com> on 2012/05/18 17:26:39 UTC

JMSXUserID propagation not working

Hi,

I am trying to get JMSXUserID to pass from producer (client) to consumer
(server) but am having no luck.

My client is a .NET app using NMS V1.5.0.2194, with STOMP V1.5.2.2508. My
server is a Java app using (indirectly via an internal framework)
activemq-core-5.3.0.

My understanding was that all I needed to do was:

1. From the client, connect to the broker using a given user name and
password:

    this.connection = this.factory.CreateConnection(userName, password);
    this.session =
(Session)this.connection.CreateSession(AcknowledgementMode.AutoAcknowledge);
    
2. Set populateJMSXUserID="true" in the broker configuration:

    <broker useJmx="true" persistent="false"
xmlns="http://activemq.apache.org/schema/core"
destroyApplicationContextOnStop="true" populateJMSXUserID="true"
useAuthenticatedPrincipalForJMSXUserID="true">

3. From the server, obtain the JMSXUserID from the message headers:

    userId = (String) headers.get("JMSXUserID");
    
With that in place, I was expecting to see the JMSXUserID come through
server-side, but it didn't. Even though I couldn't find any documentation
stating it was necessary, I then tried enabling security on the broker. I
confirmed that my client and server could only connect with the credentials
I set up, but still the JMSXUserID was not passed through.

I noticed a number of bug reports around JMSXUserID propagation and decided
to upgrade my AMQ 5.5.0 to 5.6.0. But still no joy.

Am I missing something obvious here? Can anyone give me some guidance on how
to get JMSXUserID to correctly propagate from my client to server? I'd
prefer to have broker security disabled if possible.

--
View this message in context: http://activemq.2283324.n4.nabble.com/JMSXUserID-propagation-not-working-tp4644649.html
Sent from the ActiveMQ - User mailing list archive at Nabble.com.

Re: JMSXUserID propagation not working

Posted by Timothy Bish <ta...@gmail.com>.
On Thu, 2012-05-24 at 08:14 -0700, gauche wrote: 
> OK, I've found out what's causing this and would greatly appreciate some
> advice for moving forward. I'm not even sure that this is an AMQ issue
> anymore...
> 
> The internal framework I depend on uses spring-integration-jms to wrap the
> JMS message. The code in question looks like this:
> 
> 		Map<String, Object> headers = headerMapper.toHeaders(jmsMessage);
> 		Message<?> requestMessage = (result instanceof Message<?>) ?
> 				MessageBuilder.fromMessage((Message<?>)
> result).copyHeaders(headers).build() : 
> 				MessageBuilder.withPayload(result).copyHeaders(headers).build();
> 
> jmsMessage in my case is an instance of ActiveMQTextMessage. It has the
> userID correctly set, and the "JMSXUserID" property is not present in its
> property map. This is also the case when I run the relevant unit tests in
> the AMQ code base, so I assume it's all working correctly at this point.
> 
> However, the header mapper being used is DefaultJmsHeaderMapper, which is
> part of spring-integration-jms. This mapper does not set JMSXUserID, and it
> kind of can't without taking a dependency on AMQ. Since JmsMessage does not
> have a getUserID() method, it would need to cast the message to AMQ's
> Message type first.
> 
> And thus, the user ID just kind of gets lost.
> 
> I'm interested to hear whether this is an issue with AMQ,
> spring-integration, neither, or both.
> 
> Meanwhile, I'm at least attempting to get this internal framework to use my
> own header mapper, but it looks tedious at best.
> 
> Thanks
> 
> --
> View this message in context: http://activemq.2283324.n4.nabble.com/JMSXUserID-propagation-not-working-tp4644649p4652689.html
> Sent from the ActiveMQ - User mailing list archive at Nabble.com.

One possiblity here is that this isn't working because the JMSXUserID
value isn't returned in the ActiveMQConnectionMetaData's
getJMSXPropertyNames which could be why the mapper isn't catching that
property.  That is of course if it uses that method to catch the vendor
specific property names. 

-- 
Tim Bish
Sr Software Engineer | FuseSource Corp
tim.bish@fusesource.com | www.fusesource.com
skype: tabish121 | twitter: @tabish121
blog: http://timbish.blogspot.com/


Re: JMSXUserID propagation not working

Posted by gauche <ke...@hsbcib.com>.
OK, I've found out what's causing this and would greatly appreciate some
advice for moving forward. I'm not even sure that this is an AMQ issue
anymore...

The internal framework I depend on uses spring-integration-jms to wrap the
JMS message. The code in question looks like this:

		Map<String, Object> headers = headerMapper.toHeaders(jmsMessage);
		Message<?> requestMessage = (result instanceof Message<?>) ?
				MessageBuilder.fromMessage((Message<?>)
result).copyHeaders(headers).build() : 
				MessageBuilder.withPayload(result).copyHeaders(headers).build();

jmsMessage in my case is an instance of ActiveMQTextMessage. It has the
userID correctly set, and the "JMSXUserID" property is not present in its
property map. This is also the case when I run the relevant unit tests in
the AMQ code base, so I assume it's all working correctly at this point.

However, the header mapper being used is DefaultJmsHeaderMapper, which is
part of spring-integration-jms. This mapper does not set JMSXUserID, and it
kind of can't without taking a dependency on AMQ. Since JmsMessage does not
have a getUserID() method, it would need to cast the message to AMQ's
Message type first.

And thus, the user ID just kind of gets lost.

I'm interested to hear whether this is an issue with AMQ,
spring-integration, neither, or both.

Meanwhile, I'm at least attempting to get this internal framework to use my
own header mapper, but it looks tedious at best.

Thanks

--
View this message in context: http://activemq.2283324.n4.nabble.com/JMSXUserID-propagation-not-working-tp4644649p4652689.html
Sent from the ActiveMQ - User mailing list archive at Nabble.com.

Re: JMSXUserID propagation not working

Posted by Timothy Bish <ta...@gmail.com>.
On Fri, 2012-05-18 at 08:59 -0700, gauche wrote: 
> Hmmm, I assume it is an AMQ issue rather than an NMS one. I just stepped
> through the NMS code and can see that it is not modifying the headers at
> all. If I explicitly set JMSXUserID then it gets sent, if I don't then it
> doesn't. Guess I'm thinking it is AMQ's responsibility to use the connection
> user name and place it in JMSXUserID.
> 
> I will put together a repro/test on Monday.
> 
> Thanks
> 
> --
> View this message in context: http://activemq.2283324.n4.nabble.com/JMSXUserID-propagation-not-working-tp4644649p4644707.html
> Sent from the ActiveMQ - User mailing list archive at Nabble.com.

That's fine, have a look in StompTest.java as there's already a test for
this. 

-- 
Tim Bish
Sr Software Engineer | FuseSource Corp
tim.bish@fusesource.com | www.fusesource.com
skype: tabish121 | twitter: @tabish121
blog: http://timbish.blogspot.com/


Re: JMSXUserID propagation not working

Posted by gauche <ke...@hsbcib.com>.
Hmmm, I assume it is an AMQ issue rather than an NMS one. I just stepped
through the NMS code and can see that it is not modifying the headers at
all. If I explicitly set JMSXUserID then it gets sent, if I don't then it
doesn't. Guess I'm thinking it is AMQ's responsibility to use the connection
user name and place it in JMSXUserID.

I will put together a repro/test on Monday.

Thanks

--
View this message in context: http://activemq.2283324.n4.nabble.com/JMSXUserID-propagation-not-working-tp4644649p4644707.html
Sent from the ActiveMQ - User mailing list archive at Nabble.com.

Re: JMSXUserID propagation not working

Posted by Timothy Bish <ta...@gmail.com>.
On Fri, 2012-05-18 at 08:26 -0700, gauche wrote: 
> Hi,
> 
> I am trying to get JMSXUserID to pass from producer (client) to consumer
> (server) but am having no luck.
> 
> My client is a .NET app using NMS V1.5.0.2194, with STOMP V1.5.2.2508. My
> server is a Java app using (indirectly via an internal framework)
> activemq-core-5.3.0.
> 
> My understanding was that all I needed to do was:
> 
> 1. From the client, connect to the broker using a given user name and
> password:
> 
>     this.connection = this.factory.CreateConnection(userName, password);
>     this.session =
> (Session)this.connection.CreateSession(AcknowledgementMode.AutoAcknowledge);
>     
> 2. Set populateJMSXUserID="true" in the broker configuration:
> 
>     <broker useJmx="true" persistent="false"
> xmlns="http://activemq.apache.org/schema/core"
> destroyApplicationContextOnStop="true" populateJMSXUserID="true"
> useAuthenticatedPrincipalForJMSXUserID="true">
> 
> 3. From the server, obtain the JMSXUserID from the message headers:
> 
>     userId = (String) headers.get("JMSXUserID");
>     
> With that in place, I was expecting to see the JMSXUserID come through
> server-side, but it didn't. Even though I couldn't find any documentation
> stating it was necessary, I then tried enabling security on the broker. I
> confirmed that my client and server could only connect with the credentials
> I set up, but still the JMSXUserID was not passed through.
> 
> I noticed a number of bug reports around JMSXUserID propagation and decided
> to upgrade my AMQ 5.5.0 to 5.6.0. But still no joy.
> 
> Am I missing something obvious here? Can anyone give me some guidance on how
> to get JMSXUserID to correctly propagate from my client to server? I'd
> prefer to have broker security disabled if possible.

I don't think 5.3.0 had that option so pretty sure it doesn't work
there.  I know that there is a unit test for this in 5.6.0 and its
working so its possible the Stomp client isn't setting something
correctly. Best thing to do here is create a new Jira issue for
NMS.Stomp with an NUnit test showing your issue along with a broker
config.  

-- 
Tim Bish
Sr Software Engineer | FuseSource Corp
tim.bish@fusesource.com | www.fusesource.com
skype: tabish121 | twitter: @tabish121
blog: http://timbish.blogspot.com/