activemq-users mailing list archives

Site index · List index
Message view « Date » · « Thread »
Top « Date » · « Thread »
From ironrooster <greens...@lowell.edu>
Subject how to get topicName from within onMessage()
Date Fri, 15 Jan 2010 00:43:46 GMT

Hi all,
    I am an ActiveMQ newbie who has managed to get a consumer/producer
system working using topics.  I would like to know which topic has sent a
particular message, but I can't figure out how to do it.  Perhaps someone
will have mercy on this problem and shoot it, like an injured horse.

Thanks!

p.s. here is a code sample, with a lot removed for simplicity.  The
if...else is what matters to me.

---
virtual void onMessage( const Message* message ){

 <do some stuff here>

  const TextMessage* textMessage =
                dynamic_cast< const TextMessage* >( message );

  string text = textMessage->getText();

  if( message->propertyExists( "topicName" ))
	text.append( message->getStringProperty("topicName") );
  else
	text.append("nope!");
  text.append("*");

  <do some more stuff here>
}

After execution, "text" always contains "*nope!*"
-- 
View this message in context: http://old.nabble.com/how-to-get-topicName-from-within-onMessage%28%29-tp27170708p27170708.html
Sent from the ActiveMQ - User mailing list archive at Nabble.com.


Mime
View raw message