You are viewing a plain text version of this content. The canonical link for it is here.
Posted to users@camel.apache.org by Daniel Kleine-Albers <da...@nowcast.de> on 2013/07/23 14:06:49 UTC

How to get User ID from ActiveMQ to Camel

Hi everyone,

I'm trying to get the ActiveMQ username of the sender of a particular 
message into Camel for further processing. However this does not seem to 
work.

I have setup my ActiveMQ broker to populate the JMSXUserID message property.

     <broker id="broker" brokerName="kronosBroker" 
useShutdownHook="false" useJmx="true"
                    persistent="true" dataDirectory="activemq-data"
                    populateJMSXUserID="true" 
useAuthenticatedPrincipalForJMSXUserID="true"
xmlns="http://activemq.apache.org/schema/core">


With debugging enabled I can see that the message contains the userID as 
expected:

13-07-23 13:46:27,916 [INFO] 
(org.apache.activemq.broker.util.LoggingBrokerPlugin) - 
postProcessDispatch :MessageDispatch {commandId = 7, responseRequired = 
false, consumerId = ID:pc22-37613-1374579904970-3:1:1:1, destination = 
queue://fromclient, message = ActiveMQBytesMessage {commandId = 6, 
responseRequired = false, messageId = 
ID:pc22-37613-1374579904970-6:12:-1:1:2, originalDestination = null, 
originalTransactionId = null, producerId = 
ID:pc22-37613-1374579904970-6:12:-1:1, destination = queue://fromclient, 
transactionId = null, expiration = 0, timestamp = 1374579987913, arrival 
= 0, brokerInTime = 1374579987913, brokerOutTime = 1374579987914, 
correlationId = z1hbqqt065, replyTo = null, persistent = false, type = 
null, priority = 4, groupID = null, groupSequence = 0, targetConsumerId 
= null, compressed = false, *userID = 
ws:RoWkBu9W9HrLXyPyOeXLgD3OwtIrW4si*, content = 
org.apache.activemq.util.ByteSequence@6cb2b9ec, marshalledProperties = 
null, dataStructure = null, redeliveryCounter = 0, size = 1028, 
properties = {LMSMessageType=Ping}, readOnlyProperties = true, 
readOnlyBody = true, droppable = false} ActiveMQBytesMessage{ bytesOut = 
null, dataOut = null, dataIn = null }, redeliveryCounter = 0}


Additionally I have a very short route defined that just logs the message:

13-07-23 13:46:27,918 [INFO] (fromclient) - 
Exchange[ExchangePattern:InOnly, 
Properties:{CamelBinding=org.apache.camel.component.jms.JmsBinding@5f41ab78, 
CamelToEndpoint=log://fromclient?showHeaders=true&showProperties=true, 
CamelCreatedTimestamp=Tue Jul 23 13:46:27 CEST 2013, 
CamelExternalRedelivered=false}, Headers:{JMSExpiration=0, 
JMSPriority=4, JMSReplyTo=null, JMSDeliveryMode=1, 
JMSDestination=queue://fromclient, JMSRedelivered=false, JMSType=null, 
JMSMessageID=ID:pc22-37613-1374579904970-6:12:-1:1:2, 
JMSCorrelationID=z1hbqqt065, 
breadcrumbId=ID:pc22-37613-1374579904970-6:12:-1:1:2, JMSXGroupID=null, 
JMSTimestamp=1374579987913}, BodyType:byte[], Body:PING]

--> Here I can't see a user ID (I would expect a JMSXUserID header)

Do you have any idea on why this could happen?


Thanks
Daniel

Re: How to get User ID from ActiveMQ to Camel

Posted by Daniel Kleine-Albers <da...@nowcast.de>.
Hi,

thank you very much! I had already tried to override the Header Filter 
Strategy, but I have not been successful with this method.

However, I was able to create a small ActiveMQ Plugin that puts the 
authenticated username in another header - and voila, this is perfectly 
visible in Camel.


Best regards
Daniel

On 28.07.2013 12:50, Claus Ibsen wrote:
> Hi
>
> Logged a ticket to improve this
> https://issues.apache.org/jira/browse/CAMEL-6583
>
> On Sun, Jul 28, 2013 at 12:22 PM, Claus Ibsen <cl...@gmail.com> wrote:
>> Hi
>>
>> Ah spotted this, see the source code of
>> org.apache.camel.component.jms.JmsHeaderFilterStrategy
>>
>> On Sun, Jul 28, 2013 at 12:21 PM, Claus Ibsen <cl...@gmail.com> wrote:
>>> Hi
>>>
>>> What version of ActiveMQ and Camel are you using?
>>>
>>> And you can enable DEBUG or TRACE logging on
>>> org.apache.camel.component.jms.EndpointMessageListener
>>>
>>> Then Camel should log the receive JMS message. Maybe you can see if it
>>> contains the user id somewhere.
>>>
>>> You can also always get the original javax.jms.Message using a processor / bean
>>>
>>> javax.jms.Message jms = exchange.getIn(JmsMessage.class).getJmsMessage();
>>>
>>> and then check that original jms message what it contains
>>>
>>> On Tue, Jul 23, 2013 at 2:06 PM, Daniel Kleine-Albers
>>> <da...@nowcast.de> wrote:
>>>> Hi everyone,
>>>>
>>>> I'm trying to get the ActiveMQ username of the sender of a particular
>>>> message into Camel for further processing. However this does not seem to
>>>> work.
>>>>
>>>> I have setup my ActiveMQ broker to populate the JMSXUserID message property.
>>>>
>>>>      <broker id="broker" brokerName="kronosBroker" useShutdownHook="false"
>>>> useJmx="true"
>>>>                     persistent="true" dataDirectory="activemq-data"
>>>>                     populateJMSXUserID="true"
>>>> useAuthenticatedPrincipalForJMSXUserID="true"
>>>> xmlns="http://activemq.apache.org/schema/core">
>>>>
>>>>
>>>> With debugging enabled I can see that the message contains the userID as
>>>> expected:
>>>>
>>>> 13-07-23 13:46:27,916 [INFO]
>>>> (org.apache.activemq.broker.util.LoggingBrokerPlugin) - postProcessDispatch
>>>> :MessageDispatch {commandId = 7, responseRequired = false, consumerId =
>>>> ID:pc22-37613-1374579904970-3:1:1:1, destination = queue://fromclient,
>>>> message = ActiveMQBytesMessage {commandId = 6, responseRequired = false,
>>>> messageId = ID:pc22-37613-1374579904970-6:12:-1:1:2, originalDestination =
>>>> null, originalTransactionId = null, producerId =
>>>> ID:pc22-37613-1374579904970-6:12:-1:1, destination = queue://fromclient,
>>>> transactionId = null, expiration = 0, timestamp = 1374579987913, arrival =
>>>> 0, brokerInTime = 1374579987913, brokerOutTime = 1374579987914,
>>>> correlationId = z1hbqqt065, replyTo = null, persistent = false, type = null,
>>>> priority = 4, groupID = null, groupSequence = 0, targetConsumerId = null,
>>>> compressed = false, *userID = ws:RoWkBu9W9HrLXyPyOeXLgD3OwtIrW4si*, content
>>>> = org.apache.activemq.util.ByteSequence@6cb2b9ec, marshalledProperties =
>>>> null, dataStructure = null, redeliveryCounter = 0, size = 1028, properties =
>>>> {LMSMessageType=Ping}, readOnlyProperties = true, readOnlyBody = true,
>>>> droppable = false} ActiveMQBytesMessage{ bytesOut = null, dataOut = null,
>>>> dataIn = null }, redeliveryCounter = 0}
>>>>
>>>>
>>>> Additionally I have a very short route defined that just logs the message:
>>>>
>>>> 13-07-23 13:46:27,918 [INFO] (fromclient) - Exchange[ExchangePattern:InOnly,
>>>> Properties:{CamelBinding=org.apache.camel.component.jms.JmsBinding@5f41ab78,
>>>> CamelToEndpoint=log://fromclient?showHeaders=true&showProperties=true,
>>>> CamelCreatedTimestamp=Tue Jul 23 13:46:27 CEST 2013,
>>>> CamelExternalRedelivered=false}, Headers:{JMSExpiration=0, JMSPriority=4,
>>>> JMSReplyTo=null, JMSDeliveryMode=1, JMSDestination=queue://fromclient,
>>>> JMSRedelivered=false, JMSType=null,
>>>> JMSMessageID=ID:pc22-37613-1374579904970-6:12:-1:1:2,
>>>> JMSCorrelationID=z1hbqqt065,
>>>> breadcrumbId=ID:pc22-37613-1374579904970-6:12:-1:1:2, JMSXGroupID=null,
>>>> JMSTimestamp=1374579987913}, BodyType:byte[], Body:PING]
>>>>
>>>> --> Here I can't see a user ID (I would expect a JMSXUserID header)
>>>>
>>>> Do you have any idea on why this could happen?
>>>>
>>>>
>>>> Thanks
>>>> Daniel
>>>
>>>
>>> --
>>> Claus Ibsen
>>> -----------------
>>> Red Hat, Inc.
>>> Email: cibsen@redhat.com
>>> Twitter: davsclaus
>>> Blog: http://davsclaus.com
>>> Author of Camel in Action: http://www.manning.com/ibsen
>>
>>
>> --
>> Claus Ibsen
>> -----------------
>> Red Hat, Inc.
>> Email: cibsen@redhat.com
>> Twitter: davsclaus
>> Blog: http://davsclaus.com
>> Author of Camel in Action: http://www.manning.com/ibsen
>
>

Re: How to get User ID from ActiveMQ to Camel

Posted by Claus Ibsen <cl...@gmail.com>.
Hi

Logged a ticket to improve this
https://issues.apache.org/jira/browse/CAMEL-6583

On Sun, Jul 28, 2013 at 12:22 PM, Claus Ibsen <cl...@gmail.com> wrote:
> Hi
>
> Ah spotted this, see the source code of
> org.apache.camel.component.jms.JmsHeaderFilterStrategy
>
> On Sun, Jul 28, 2013 at 12:21 PM, Claus Ibsen <cl...@gmail.com> wrote:
>> Hi
>>
>> What version of ActiveMQ and Camel are you using?
>>
>> And you can enable DEBUG or TRACE logging on
>> org.apache.camel.component.jms.EndpointMessageListener
>>
>> Then Camel should log the receive JMS message. Maybe you can see if it
>> contains the user id somewhere.
>>
>> You can also always get the original javax.jms.Message using a processor / bean
>>
>> javax.jms.Message jms = exchange.getIn(JmsMessage.class).getJmsMessage();
>>
>> and then check that original jms message what it contains
>>
>> On Tue, Jul 23, 2013 at 2:06 PM, Daniel Kleine-Albers
>> <da...@nowcast.de> wrote:
>>> Hi everyone,
>>>
>>> I'm trying to get the ActiveMQ username of the sender of a particular
>>> message into Camel for further processing. However this does not seem to
>>> work.
>>>
>>> I have setup my ActiveMQ broker to populate the JMSXUserID message property.
>>>
>>>     <broker id="broker" brokerName="kronosBroker" useShutdownHook="false"
>>> useJmx="true"
>>>                    persistent="true" dataDirectory="activemq-data"
>>>                    populateJMSXUserID="true"
>>> useAuthenticatedPrincipalForJMSXUserID="true"
>>> xmlns="http://activemq.apache.org/schema/core">
>>>
>>>
>>> With debugging enabled I can see that the message contains the userID as
>>> expected:
>>>
>>> 13-07-23 13:46:27,916 [INFO]
>>> (org.apache.activemq.broker.util.LoggingBrokerPlugin) - postProcessDispatch
>>> :MessageDispatch {commandId = 7, responseRequired = false, consumerId =
>>> ID:pc22-37613-1374579904970-3:1:1:1, destination = queue://fromclient,
>>> message = ActiveMQBytesMessage {commandId = 6, responseRequired = false,
>>> messageId = ID:pc22-37613-1374579904970-6:12:-1:1:2, originalDestination =
>>> null, originalTransactionId = null, producerId =
>>> ID:pc22-37613-1374579904970-6:12:-1:1, destination = queue://fromclient,
>>> transactionId = null, expiration = 0, timestamp = 1374579987913, arrival =
>>> 0, brokerInTime = 1374579987913, brokerOutTime = 1374579987914,
>>> correlationId = z1hbqqt065, replyTo = null, persistent = false, type = null,
>>> priority = 4, groupID = null, groupSequence = 0, targetConsumerId = null,
>>> compressed = false, *userID = ws:RoWkBu9W9HrLXyPyOeXLgD3OwtIrW4si*, content
>>> = org.apache.activemq.util.ByteSequence@6cb2b9ec, marshalledProperties =
>>> null, dataStructure = null, redeliveryCounter = 0, size = 1028, properties =
>>> {LMSMessageType=Ping}, readOnlyProperties = true, readOnlyBody = true,
>>> droppable = false} ActiveMQBytesMessage{ bytesOut = null, dataOut = null,
>>> dataIn = null }, redeliveryCounter = 0}
>>>
>>>
>>> Additionally I have a very short route defined that just logs the message:
>>>
>>> 13-07-23 13:46:27,918 [INFO] (fromclient) - Exchange[ExchangePattern:InOnly,
>>> Properties:{CamelBinding=org.apache.camel.component.jms.JmsBinding@5f41ab78,
>>> CamelToEndpoint=log://fromclient?showHeaders=true&showProperties=true,
>>> CamelCreatedTimestamp=Tue Jul 23 13:46:27 CEST 2013,
>>> CamelExternalRedelivered=false}, Headers:{JMSExpiration=0, JMSPriority=4,
>>> JMSReplyTo=null, JMSDeliveryMode=1, JMSDestination=queue://fromclient,
>>> JMSRedelivered=false, JMSType=null,
>>> JMSMessageID=ID:pc22-37613-1374579904970-6:12:-1:1:2,
>>> JMSCorrelationID=z1hbqqt065,
>>> breadcrumbId=ID:pc22-37613-1374579904970-6:12:-1:1:2, JMSXGroupID=null,
>>> JMSTimestamp=1374579987913}, BodyType:byte[], Body:PING]
>>>
>>> --> Here I can't see a user ID (I would expect a JMSXUserID header)
>>>
>>> Do you have any idea on why this could happen?
>>>
>>>
>>> Thanks
>>> Daniel
>>
>>
>>
>> --
>> Claus Ibsen
>> -----------------
>> Red Hat, Inc.
>> Email: cibsen@redhat.com
>> Twitter: davsclaus
>> Blog: http://davsclaus.com
>> Author of Camel in Action: http://www.manning.com/ibsen
>
>
>
> --
> Claus Ibsen
> -----------------
> Red Hat, Inc.
> Email: cibsen@redhat.com
> Twitter: davsclaus
> Blog: http://davsclaus.com
> Author of Camel in Action: http://www.manning.com/ibsen



-- 
Claus Ibsen
-----------------
Red Hat, Inc.
Email: cibsen@redhat.com
Twitter: davsclaus
Blog: http://davsclaus.com
Author of Camel in Action: http://www.manning.com/ibsen

Re: How to get User ID from ActiveMQ to Camel

Posted by Claus Ibsen <cl...@gmail.com>.
Hi

Ah spotted this, see the source code of
org.apache.camel.component.jms.JmsHeaderFilterStrategy

On Sun, Jul 28, 2013 at 12:21 PM, Claus Ibsen <cl...@gmail.com> wrote:
> Hi
>
> What version of ActiveMQ and Camel are you using?
>
> And you can enable DEBUG or TRACE logging on
> org.apache.camel.component.jms.EndpointMessageListener
>
> Then Camel should log the receive JMS message. Maybe you can see if it
> contains the user id somewhere.
>
> You can also always get the original javax.jms.Message using a processor / bean
>
> javax.jms.Message jms = exchange.getIn(JmsMessage.class).getJmsMessage();
>
> and then check that original jms message what it contains
>
> On Tue, Jul 23, 2013 at 2:06 PM, Daniel Kleine-Albers
> <da...@nowcast.de> wrote:
>> Hi everyone,
>>
>> I'm trying to get the ActiveMQ username of the sender of a particular
>> message into Camel for further processing. However this does not seem to
>> work.
>>
>> I have setup my ActiveMQ broker to populate the JMSXUserID message property.
>>
>>     <broker id="broker" brokerName="kronosBroker" useShutdownHook="false"
>> useJmx="true"
>>                    persistent="true" dataDirectory="activemq-data"
>>                    populateJMSXUserID="true"
>> useAuthenticatedPrincipalForJMSXUserID="true"
>> xmlns="http://activemq.apache.org/schema/core">
>>
>>
>> With debugging enabled I can see that the message contains the userID as
>> expected:
>>
>> 13-07-23 13:46:27,916 [INFO]
>> (org.apache.activemq.broker.util.LoggingBrokerPlugin) - postProcessDispatch
>> :MessageDispatch {commandId = 7, responseRequired = false, consumerId =
>> ID:pc22-37613-1374579904970-3:1:1:1, destination = queue://fromclient,
>> message = ActiveMQBytesMessage {commandId = 6, responseRequired = false,
>> messageId = ID:pc22-37613-1374579904970-6:12:-1:1:2, originalDestination =
>> null, originalTransactionId = null, producerId =
>> ID:pc22-37613-1374579904970-6:12:-1:1, destination = queue://fromclient,
>> transactionId = null, expiration = 0, timestamp = 1374579987913, arrival =
>> 0, brokerInTime = 1374579987913, brokerOutTime = 1374579987914,
>> correlationId = z1hbqqt065, replyTo = null, persistent = false, type = null,
>> priority = 4, groupID = null, groupSequence = 0, targetConsumerId = null,
>> compressed = false, *userID = ws:RoWkBu9W9HrLXyPyOeXLgD3OwtIrW4si*, content
>> = org.apache.activemq.util.ByteSequence@6cb2b9ec, marshalledProperties =
>> null, dataStructure = null, redeliveryCounter = 0, size = 1028, properties =
>> {LMSMessageType=Ping}, readOnlyProperties = true, readOnlyBody = true,
>> droppable = false} ActiveMQBytesMessage{ bytesOut = null, dataOut = null,
>> dataIn = null }, redeliveryCounter = 0}
>>
>>
>> Additionally I have a very short route defined that just logs the message:
>>
>> 13-07-23 13:46:27,918 [INFO] (fromclient) - Exchange[ExchangePattern:InOnly,
>> Properties:{CamelBinding=org.apache.camel.component.jms.JmsBinding@5f41ab78,
>> CamelToEndpoint=log://fromclient?showHeaders=true&showProperties=true,
>> CamelCreatedTimestamp=Tue Jul 23 13:46:27 CEST 2013,
>> CamelExternalRedelivered=false}, Headers:{JMSExpiration=0, JMSPriority=4,
>> JMSReplyTo=null, JMSDeliveryMode=1, JMSDestination=queue://fromclient,
>> JMSRedelivered=false, JMSType=null,
>> JMSMessageID=ID:pc22-37613-1374579904970-6:12:-1:1:2,
>> JMSCorrelationID=z1hbqqt065,
>> breadcrumbId=ID:pc22-37613-1374579904970-6:12:-1:1:2, JMSXGroupID=null,
>> JMSTimestamp=1374579987913}, BodyType:byte[], Body:PING]
>>
>> --> Here I can't see a user ID (I would expect a JMSXUserID header)
>>
>> Do you have any idea on why this could happen?
>>
>>
>> Thanks
>> Daniel
>
>
>
> --
> Claus Ibsen
> -----------------
> Red Hat, Inc.
> Email: cibsen@redhat.com
> Twitter: davsclaus
> Blog: http://davsclaus.com
> Author of Camel in Action: http://www.manning.com/ibsen



-- 
Claus Ibsen
-----------------
Red Hat, Inc.
Email: cibsen@redhat.com
Twitter: davsclaus
Blog: http://davsclaus.com
Author of Camel in Action: http://www.manning.com/ibsen

Re: How to get User ID from ActiveMQ to Camel

Posted by Claus Ibsen <cl...@gmail.com>.
Hi

What version of ActiveMQ and Camel are you using?

And you can enable DEBUG or TRACE logging on
org.apache.camel.component.jms.EndpointMessageListener

Then Camel should log the receive JMS message. Maybe you can see if it
contains the user id somewhere.

You can also always get the original javax.jms.Message using a processor / bean

javax.jms.Message jms = exchange.getIn(JmsMessage.class).getJmsMessage();

and then check that original jms message what it contains

On Tue, Jul 23, 2013 at 2:06 PM, Daniel Kleine-Albers
<da...@nowcast.de> wrote:
> Hi everyone,
>
> I'm trying to get the ActiveMQ username of the sender of a particular
> message into Camel for further processing. However this does not seem to
> work.
>
> I have setup my ActiveMQ broker to populate the JMSXUserID message property.
>
>     <broker id="broker" brokerName="kronosBroker" useShutdownHook="false"
> useJmx="true"
>                    persistent="true" dataDirectory="activemq-data"
>                    populateJMSXUserID="true"
> useAuthenticatedPrincipalForJMSXUserID="true"
> xmlns="http://activemq.apache.org/schema/core">
>
>
> With debugging enabled I can see that the message contains the userID as
> expected:
>
> 13-07-23 13:46:27,916 [INFO]
> (org.apache.activemq.broker.util.LoggingBrokerPlugin) - postProcessDispatch
> :MessageDispatch {commandId = 7, responseRequired = false, consumerId =
> ID:pc22-37613-1374579904970-3:1:1:1, destination = queue://fromclient,
> message = ActiveMQBytesMessage {commandId = 6, responseRequired = false,
> messageId = ID:pc22-37613-1374579904970-6:12:-1:1:2, originalDestination =
> null, originalTransactionId = null, producerId =
> ID:pc22-37613-1374579904970-6:12:-1:1, destination = queue://fromclient,
> transactionId = null, expiration = 0, timestamp = 1374579987913, arrival =
> 0, brokerInTime = 1374579987913, brokerOutTime = 1374579987914,
> correlationId = z1hbqqt065, replyTo = null, persistent = false, type = null,
> priority = 4, groupID = null, groupSequence = 0, targetConsumerId = null,
> compressed = false, *userID = ws:RoWkBu9W9HrLXyPyOeXLgD3OwtIrW4si*, content
> = org.apache.activemq.util.ByteSequence@6cb2b9ec, marshalledProperties =
> null, dataStructure = null, redeliveryCounter = 0, size = 1028, properties =
> {LMSMessageType=Ping}, readOnlyProperties = true, readOnlyBody = true,
> droppable = false} ActiveMQBytesMessage{ bytesOut = null, dataOut = null,
> dataIn = null }, redeliveryCounter = 0}
>
>
> Additionally I have a very short route defined that just logs the message:
>
> 13-07-23 13:46:27,918 [INFO] (fromclient) - Exchange[ExchangePattern:InOnly,
> Properties:{CamelBinding=org.apache.camel.component.jms.JmsBinding@5f41ab78,
> CamelToEndpoint=log://fromclient?showHeaders=true&showProperties=true,
> CamelCreatedTimestamp=Tue Jul 23 13:46:27 CEST 2013,
> CamelExternalRedelivered=false}, Headers:{JMSExpiration=0, JMSPriority=4,
> JMSReplyTo=null, JMSDeliveryMode=1, JMSDestination=queue://fromclient,
> JMSRedelivered=false, JMSType=null,
> JMSMessageID=ID:pc22-37613-1374579904970-6:12:-1:1:2,
> JMSCorrelationID=z1hbqqt065,
> breadcrumbId=ID:pc22-37613-1374579904970-6:12:-1:1:2, JMSXGroupID=null,
> JMSTimestamp=1374579987913}, BodyType:byte[], Body:PING]
>
> --> Here I can't see a user ID (I would expect a JMSXUserID header)
>
> Do you have any idea on why this could happen?
>
>
> Thanks
> Daniel



-- 
Claus Ibsen
-----------------
Red Hat, Inc.
Email: cibsen@redhat.com
Twitter: davsclaus
Blog: http://davsclaus.com
Author of Camel in Action: http://www.manning.com/ibsen