The advisory topic "ActiveMQ.Advisory.Consumer.Queue.TEST.Q" will send
messages alerting you of new consumers and you will receive a
"ConsumerInfo" object which won't contain the user name.  That will contain
a reference to the consumerId instead, since the connection was already
created.  The consumerId will contain the connectionId.  There can be
multiple consumers per connection which all share the same user name which
is why you need to listen for connection advisories on
ActiveMQ.Advisory.Connection
topic if you want to know what user name was used to connect.

If you want to know the user name for when new consumers come online then
you will need to keep track of the connections first and match it up.  If
you listen on ActiveMQ.Advisory.Connection, you could keep track of
connectionIds and associated user names.  Then, when you receive a message
on ActiveMQ.Advisory.Consumer.Queue.TEST.Q, the consumer info object will
contain the ConsumerId (which contains connection id) and you can then use
that to look up the user name that matches up with the connection.

The other alternative besides using advisories is to do something similar
with a BrokerFilter (as you mentioned in your first message) but it will be
the same strategy.  You would need to keep track of new connections in the
addConnection method (which passes a ConnectionInfo object to the method
and will have the user name for the connection) and then in the addConsumer
method you can look up the connection associated with the ConsumerInfo that
is passed to that method.

On Tue, Jun 16, 2015 at 8:05 AM, ALi <osat...@gmail.com> wrote:

> i dont know where .... i am connecting with stomp and ws ..... this is what
> this log shows:
>
> (using camel to print message)
>
> <route>
> <from
>
> uri="activemq:topic:ActiveMQ.Advisory.Consumer.Queue.TEST.Q?mapJmsMessage=false"
> />
>    <convertBodyTo type="java.lang.String"/>
>    <transform>
>       <simple>\r\n${date:now:yyyyMMdd-hh-mm-ss}  ${in.header.user}
> ${in.body} ${in.headers} \r\n</simple>
>    </transform>
>    <to
>
> uri="file://c:/folder/?fileExist=Append&amp;fileName=advisoryConnection-${date:now:yyyyMMdd}.txt"
> />
> </route>
>
>
> 20150616-01-16-27   ActiveMQMessage {commandId = 0, responseRequired =
> false, messageId = ID:COMPUTER-62265-1434453235120-1:1:0:0:10,
> originalDestination = null, originalTransactionId = null, producerId =
> ID:COMPUTER-62265-1434453235120-1:1:0:0, destination =
> topic://ActiveMQ.Advisory.Consumer.Queue.TEST.Q, transactionId = null,
> expiration = 0, timestamp = 0, arrival = 0, brokerInTime = 1434453387887,
> brokerOutTime = 1434453387890, correlationId = null, replyTo = null,
> persistent = false, type = Advisory, priority = 0, groupID = null,
> groupSequence = 0, targetConsumerId = null, compressed = false, userID =
> null, content = null, marshalledProperties = null, dataStructure =
> ConsumerInfo {commandId = 3, responseRequired = false, consumerId =
> ID:COMPUTER-62265-1434453235120-6:1:-1:1, destination = queue://TEST.Q,
> prefetchSize = 1000, maximumPendingMessageLimit = 0, browser = false,
> dispatchAsync = true, selector = null, subscriptionName = null, noLocal =
> false, exclusive = false, retroactive = false, priority = 0, brokerPath =
> null, optimizedAcknowledge = false, noRangeAcks = false,
> additionalPredicate = null}, redeliveryCounter = 0, size = 1024, properties
> = {consumerCount=1, originBrokerURL=tcp://127.0.0.1:61616,
> originBrokerId=ID:COMPUTER-62265-1434453235120-0:1,
> originBrokerName=amq-broker}, readOnlyProperties = true, readOnlyBody =
> true, droppable = false}  ::::{originBrokerURL=tcp://127.0.0.1:61616,
> JMSRedelivered=false,
> breadcrumbId=ID:COMPUTER-62265-1434453235120-1:1:0:0:10, JMSType=Advisory,
> JMSDeliveryMode=1, JMSCorrelationID=null, JMSReplyTo=null,
> JMSXGroupID=null, JMSMessageID=ID:COMPUTER-62265-1434453235120-1:1:0:0:10,
> originBrokerId=ID:COMPUTER-62265-1434453235120-0:1,
> originBrokerName=amq-broker, consumerCount=1, JMSTimestamp=0,
> JMSExpiration=0,
> JMSDestination=topic://ActiveMQ.Advisory.Consumer.Queue.TEST.Q,
> JMSPriority=0}::{originBrokerURL=tcp://127.0.0.1:61616,
> JMSRedelivered=false,
> breadcrumbId=ID:COMPUTER-62265-1434453235120-1:1:0:0:10, JMSType=Advisory,
> JMSDeliveryMode=1, JMSCorrelationID=null, JMSReplyTo=null,
> JMSXGroupID=null, JMSMessageID=ID:COMPUTER-62265-1434453235120-1:1:0:0:10,
> originBrokerId=ID:COMPUTER-62265-1434453235120-0:1,
> originBrokerName=amq-broker, consumerCount=1, JMSTimestamp=0,
> JMSExpiration=0,
> JMSDestination=topic://ActiveMQ.Advisory.Consumer.Queue.TEST.Q,
> JMSPriority=0}
>
>
> perhaps the headers are twice (i dont remember my last editiion) and i dont
> see the user in this log (guest)
>
> the username in jmx is null
>
>
>
>
>
>
> On Tue, Jun 16, 2015 at 1:42 PM, Christopher Shannon <
> christopher.l.shan...@gmail.com> wrote:
>
> > Advisory messages delivered to ActiveMQ.Advisory.Connection will contain
> a
> > ConnectionInfo object as part of the data structure field of the message.
> > That object will contain the user name used for the new connection.
> > Passwords will always be cleared, however.
> >
> > On Tue, Jun 16, 2015 at 5:41 AM, ALi <osat...@gmail.com> wrote:
> >
> > > hello i want to log every user that connects to an  specific queue, i
> > think
> > > that it is dont by reading advisory messages or by doing a plugin that
> > > intercepts calls to the broker. (BrokerFilter) the first try is
> reading
> > > advisory .. but the username is not setted receiving null....any
> help????
> > >
> >
>

Reply via email to