Method CreateSubscription
CreateSubscription(MessageReceivedCallback)
Subscribes for receiving messages of a particular topic.
Declaration
ITopicSubscription CreateSubscription(MessageReceivedCallback messageReceivedCallback)
Parameters
Type | Name | Description |
---|---|---|
MessageReceivedCallback | messageReceivedCallback | Message is delivered through this callback |
Returns
Type | Description |
---|---|
ITopicSubscription | Returns the created topic subscription |
Examples
The following example demonstrates how to create a subscription on topic.
First initialize cache.
Cache cache = NCache.InitializeCache("myCache");
Then get messaging service from cache.
IMessagingService messagingService=cache.MessagingService;
Then get topic from messagingService
ITopic topic=messagingService.GetTopic("mytopic");
if(topic==null) //If topic not exists create it.
{
topic=messagingService.CreateTopic("mytopic");
}
Then create subscription
void MessageReceivedCallback(object sender, MessageEventArgs args)
{
}
topic.CreateSubscription(MessageReceivedCallback);