Provides a SQL interface to subscribe or unsubscribe to a topic.
msg_subscribe::= msgsubscribe (subscription_name)
subscription_name::=basic_character_expression
is the name of the subscription to which you are subscribing. A basic_character_expression.
Tells the JMS messaging provider to begin holding messages published to the topic registered as “subscription_1”:
select msgsubscribe ('subscription_1')
Before you specify a subscription with msgsubscribe or msgunscunscribe, you must register the subscription with sp_msgadmin. This example registers the durable subscription “subscription_1”:
sp_msgadmin 'register', 'subscription', 'subscription_1', 'my_ems_provider?topic=topic.sample,user=user1,password=pwd', 'Supplier=12345', null, 'durable1', 'client1'
Once msgsubscribe is called, all messages published on the specified topic that qualify for the selector are held until msgconsume is called to read the messages. If you do not want to hold messages that arrive before you are ready to consume them, do not call msgsubscribe. Calling msgconsume without previously calling msgsubscribe starts the subscription when msgconsume is called.
msgsubscribe starts a subscription for the client to receive messages defined by the endpoint and filter specified by subscription_name. It returns 0 if it succeeds, or 1 if it fails.
If you specify with retain, the connection to the JMS messaging provider is terminated so that another subscription can connect, using the same subscriber client_id specified in the subscription. The durable subscriber remains defined within Adaptive Server and within the JMS message provider. If you specify with remove, the durable subscriber definition is removed from the JMS message provider. The default value is with retain.
In a separate scenario, a SQL session releases a subscription so that another session can consume messages. This example shows Session 1 releasing the subscription, so that Session 2 can begin consuming from it.
The following example shows msgsubscribe used before the application logic is ready to read the messages that force the TIBCO JMS client to hold messages. The application subscribes:
select msgsubscribe ('subscription_1')
The client consumes the message multiple times, and uses other application logic not related to messaging. It is then ready to read messages, and it receives all the messages that have arrived since msgsubscribe was called:
select msgconsume('subscription_1') select msgconsume('subscription_1')
The client application is finished with this subscription, and unsubscribes:
select msgunsubscribe('subscription_1')
Copyright © 2005. Sybase Inc. All rights reserved. |
![]() |