activemq-dev mailing list archives

Site index · List index
Message view « Date » · « Thread »
Top « Date » · « Thread »
From cmaxo <>
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.


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;
     // Create a ConnectionFactory
     ActiveMQConnectionFactory* factory = new
     Connection *connection = factory->createConnection();
     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");


     /* 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)
    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:
Sent from the ActiveMQ - Dev mailing list archive at

View raw message