ActiveMQ MessageListener can't differentiate between command and text message

classic Classic list List threaded Threaded
4 messages Options
Reply | Threaded
Open this post in threaded view
|

ActiveMQ MessageListener can't differentiate between command and text message

sumit.wattal
Hi,

I have started to migrate from activemq 5.6 single broker to activemq 5.8 network of brokers. The new solution has one broker pumping data to a distributed queue that resides on another broker which has a message listener set up as under. I had an existing code which basically sets a message listener for asynchronus reception.

Something like

messageConsumer.setMessageListener(new MessageListener() {
                // ideally, we free this up as quickly as possible
                @Override
                public void onMessage(javax.jms.Message received) {
                 if(received != null)
                 {
                  ...............
                 }
             }
});

when i had a single broker solution the listener only received text messages. Now when I have migrated to network of brokers I am seeing other command structures as well (CONSUMER_INFO and PRODUCER_INFO). I am not sure why is this happening in a broker network or what should i do to filter these.

Regards,

Sumit
Reply | Threaded
Open this post in threaded view
|

Re: ActiveMQ MessageListener can't differentiate between command and text message

ceposta
Show how you create your consumer.
Your consumer shouldn't receive these messages unless you're subscribed to
advisory topics.


On Wed, Aug 7, 2013 at 2:08 PM, sumit.wattal <[hidden email]>wrote:

> Hi,
>
> I have started to migrate from activemq 5.6 single broker to activemq 5.8
> network of brokers. The new solution has one broker pumping data to a
> distributed queue that resides on another broker which has a message
> listener set up as under. I had an existing code which basically sets a
> message listener for asynchronus reception.
>
> Something like
>
> messageConsumer.setMessageListener(new MessageListener() {
>                 // ideally, we free this up as quickly as possible
>                 @Override
>                 public void onMessage(javax.jms.Message received) {
>                  if(received != null)
>                  {
>                   ...............
>                  }
>              }
> });
>
> when i had a single broker solution the listener only received text
> messages. Now when I have migrated to network of brokers I am seeing other
> command structures as well (CONSUMER_INFO and PRODUCER_INFO). I am not sure
> why is this happening in a broker network or what should i do to filter
> these.
>
> Regards,
>
> Sumit
>
>
>
> --
> View this message in context:
> http://activemq.2283324.n4.nabble.com/ActiveMQ-MessageListener-can-t-differentiate-between-command-and-text-message-tp4670173.html
> Sent from the ActiveMQ - User mailing list archive at Nabble.com.
>



--
*Christian Posta*
http://www.christianposta.com/blog
twitter: @christianposta
Reply | Threaded
Open this post in threaded view
|

Re: ActiveMQ MessageListener can't differentiate between command and text message

sumit.wattal
This is how I create my message consumer

ActiveMQConnectionFactory activeMQConnectionFactory = new ActiveMQConnectionFactory();

activeMQConnectionFactory.setBrokerURL("nio://localhost:61619"));

final Connection connection = activeMQConnectionFactory.createConnection()
;
final Session session = connection.createSession(false, Session.AUTO_ACKNOWLEDGE);
;

final Destination destination = new ActiveMQQueue(queueName+ "?consumer.exclusive=true")
final MessageConsumer messageConsumer = session.createConsumer(destination);

Then i set the messageListener for the consumer.

Thanks & Regards,

Sumit
Reply | Threaded
Open this post in threaded view
|

Re: ActiveMQ MessageListener can't differentiate between command and text message

ceposta
Don't need to use nio:// on the client side.


Your best bet is to create  unit test that can reproduce it.
Start here:
http://svn.apache.org/viewvc/activemq/trunk/activemq-unit-tests/src/test/java/org/apache/activemq/ExclusiveConsumerTest.java?view=markup

and here:
http://svn.apache.org/viewvc/activemq/trunk/activemq-unit-tests/src/test/java/org/apache/activemq/network/SimpleNetworkTest.java?view=markup


On Wed, Aug 7, 2013 at 3:44 PM, sumit.wattal <[hidden email]>wrote:

> This is how I create my message consumer
>
> ActiveMQConnectionFactory activeMQConnectionFactory = new
> ActiveMQConnectionFactory();
>
> activeMQConnectionFactory.setBrokerURL("nio://localhost:61619"));
>
> final Connection connection = activeMQConnectionFactory.createConnection()
> ;
> final Session session = connection.createSession(false,
> Session.AUTO_ACKNOWLEDGE);
> ;
>
> final Destination destination = new ActiveMQQueue(queueName+
> "?consumer.exclusive=true")
> final MessageConsumer messageConsumer =
> session.createConsumer(destination);
>
> Then i set the messageListener for the consumer.
>
> Thanks & Regards,
>
> Sumit
>
>
>
>
> --
> View this message in context:
> http://activemq.2283324.n4.nabble.com/ActiveMQ-MessageListener-can-t-differentiate-between-command-and-text-message-tp4670173p4670179.html
> Sent from the ActiveMQ - User mailing list archive at Nabble.com.
>



--
*Christian Posta*
http://www.christianposta.com/blog
twitter: @christianposta