activemq-dev mailing list archives

Site index · List index
Message view « Date » · « Thread »
Top « Date » · « Thread »
From cmaxo <cm...@engineer.com>
Subject Re: activemq-cpp getStringProperty
Date Fri, 05 Oct 2007 19:29:05 GMT


Hmm ... you certainly should be able to set properties on text messages.  If
you wouldn't mind, it would help us a lot if you could provide a sample main
that demonstrates the problem.

Thanks,
Nate



Here is a mockup main.  I'm using gcc 4.1.3 on ubuntu feisty.  Like I said
the messages come across great and the text is complete.  I just get the
exception everytime I look for the property.

#include <cms/Connection.h>
#include <cms/MessageConsumer.h>
#include <activemq/connector/stomp/commands/CommandConstants.h>

int main(int argc, char *argv[])
{
  ActiveMQConnectionFactory* factory = NULL;
  try
  {
     // Create a ConnectionFactory
     ActiveMQConnectionFactory* factory = new
ActiveMQConnectionFactory("tcp://127.0.0.1:61613?wireFormat=stomp");
 
     cleanup();
 
     Connection *connection = factory->createConnection();
     connection->start();
 
     Session *session = connection->createSession(fAckMode);
     Destination *destination  = session->createQueue("myqueue");

     MessageProducer *producer = session->createProducer(destination);
     
     TextMessage* textMessage = session->createTextMessage("Hello message");
     textMessage->setStringProperty("session_id", "1234");

     producer->send(textMessage);

     /* cleanup code here */
   }
 }

The consumer code is very similar except for the lines dealing with the
TextMessage are replaced with:
TextMessage *textMessage = dynamic_cast<TextMessage*>(mc->receive(1000));
if (textMessage)
{
  try
  {
    char *propValue = textMessage->getStringProperty("session_id").c_str();
    printf("%s", propValue);
  }
  catch (CMSException &exception)
  {
    printf("%s", exception.getMessage().c_str());
  }
  char *message = textMessage->getText().c_str();
  printf("%s", message);
}
-- 
View this message in context: http://www.nabble.com/activemq-cpp-getStringProperty-tf4576622s2354.html#a13065924
Sent from the ActiveMQ - Dev mailing list archive at Nabble.com.


Mime
View raw message