Example: jms_set_message_property

This example shows using jms_set_message_property to set up for queuing a message.

long t=1;
char *chr;
t=time(&t);
t = t + 100000;
chr = (char*)malloc(20, sizeof(char));
sprintf(chr,"%d",t);
jms_set_message_property("JMSExpiration","JMSExpiration", chr);
jms_set_message_property("JMSMessageID","JMSMessageID", "-JMSMessageID-");
jms_set_message_property("JMSPriority","JMSPriority", "9"); //0-9, 4 is default
jms_set_message_property("JMSRedelivered","JMSRedelivered", "true"); 
jms_send_message_queue("sending message 1","RecordedBuffer1", "TestJMSQueue");

This example shows setting the JMSCorrelationID property, and then sending/receiving a message.
jms_set_message_property("step0: set the JMSCorrelationID", 
    "JMSCorrelationID", 
    "VuserID-{VuserID}");

jms_send_receive_message_queue("step1: send and receive message", 
    "Test Message", 
    "weblogic.jms.inqueue", 
    "weblogic.jms.outqueue");

lr_message(lr_eval_string("{JMS_message}"));

This example shows how to set a custom selector for a subscription. Any message whose flag value is set to "no" is received on a specific topic. 
jms_set_message_property("selector_step", "JMSSelector", "flag = \'no\'");
jms_subscribe_topic("subscribe_step", "subscription_1", "testTopic");
jms_publish_message_topic("publish_step", "message to publish", "testTopic");
jms_receive_message_topic("receive_step", "subscription_1", "testTopic");
lr_output_message(lr_eval_string("message : \n{JMS_message}\n"));
This example shows how to filter messages received for a subscription by correlation ID. Only messages whose correlation ID is 4566636 are received.
/* This call sets the filter for the all messages received for this subscription. */
jms_set_message_property("prop","JMSCorrelationID","4566636");
jms_subscribe_topic("subcribe_step", "subscription_1", "testTopic"); 
/* This call sets the correlation ID for the next message to be sent. */
jms_set_message_property("prop","JMSCorrelationID","123");
jms_publish_message_topic("publish_step", "This message matches Correlation ID 123", "testTopic");
/* This message is not received because the correlation ID does not match the filter. */
jms_receive_message_topic("receive_step", "subscription_1", "testTopic"); 
lr_output_message(lr_eval_string("message: {JMS_message}\n"));
/* This call sets the correlation ID for the next message to be sent. */
jms_set_message_property("prop","JMSCorrelationID","4566636");
jms_publish_message_topic("publish_step", "This message matches Correlation ID 4566636", "testTopic"); 
/* This message is received because the correlation ID matches the filter. */
jms_receive_message_topic("receive_step", "subscription_1", "testTopic"); 
lr_output_message(lr_eval_string("message: {JMS_message}\n"));