Share this page

# jms_subscribe_topic

Creates a subscription for a topic.

Web Services Functions (SOAP, WEB_SERVICE, Silverlight)

    int jms_subscribe_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. To retrieve messages on the subscription created by a jms_subscribe_topic step, call jms_receive_message_topic using the same SubscriberName value.
TopicName | The JNDI name of the topic for which to receive messages.

The jms_subscribe_topic function creates a subscription for a topic.

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

Call this function before any jms_receive_message_topic calls for the subscription.

To filter messages received for this subscription, insert the jms_set_message_property function before this function call. Filters for topics apply for the duration of the subscription. Filters for queues only apply to the next received 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.

- A communication error occurs.

- The subscription failed.

- The selector set using jms_set_message_property is not legal. See jms_set_message_property for how to set a selector.

## Example

This example shows how to set a custom selector for a subscription. Any message for a specific topic whose flag value is set to "no" is received.

Copy code

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

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: