Share this page

# jms_receive_message_topic

Receives published messages to a specific topic on a subscription.

Web Services Functions (SOAP, WEB_SERVICE, Silverlight)

    int jms_receive_message_topic( const char * StepName, const char * SubscriberName, const char * TopicName );

This function returns LR_PASS (0) on success or LR_FAIL (1) on failure. Note that LR_PASS and LR_FAIL generally indicate whether the function call completed without an exception, and not that the test step succeeded.

All input string arguments (char type) except the step name can be parameterized using standard parameterization.

StepName | The name of the step, as it appears in the test tree. Any text can be used.
SubscriberName | The name of the subscription. Use the same subscriber name value from the previously-called jms_subscribe_topic.
TopicName | The JNDI name of the topic from which to receive the message.

The jms_receive_message_topic function receives messages synchronously on a topic for a subscription.

VuGen identifies the topic and subscription by calling a lookup method on a JNDI context defined in the JMS runtime settings.

Call this function after jms_subscribe_topic. Use the same SubscriberName value from the jms_subscribe_topic call.

To filter received messages, set a JMSSelector message header by calling jms_set_message_property, making sure to insert the selector before the jms_subscribe_topic call. The filter applies to all messages received during the duration of the subscription.

When received, the message is saved in a VuGen output parameter called JMS_message.

This function fails, causing the script to stop (if the Continue on Error runtime setting is not selected) if:

- The JNDI context is incorrect.

- The topic cannot be located.

- No message arrives after the timeout configured in the runtime settings.

- A communication error occurs.

- SubscriberName does not match any subscription (as defined in jms_subscribe_topic).

## Example

This example shows sending and receiving messages for the topic testTopic on subscription subscription_1. Received messages are saved in the JMS_message parameter.

Copy code

    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"));

Tips to improve your search results... VuGen Function Reference Version 26.1-26.3 Function Reference 26.1-26.3 All View Local Help Center View Online Help Center Version: