Exemplo n.º 1
0
        public static IDurableTopicSubscription RunPatternBasedSubscriber(string topicPattern, string subscriptionName)
        {
            ITopic topic = _cache.MessagingService.GetTopic(topicPattern, Alachisoft.NCache.Runtime.Caching.Messaging.TopicSearchOptions.ByPattern);

            //Create durable subscriptions with an expiry of 1 hour on all the topics matching the specified pattern
            if (topic != null)
            {
                return(topic.CreateDurableSubscription(subscriptionName, SubscriptionPolicy.Shared, MessageReceivedCallbackPatternBased, new TimeSpan(1, 0, 0)));
            }

            return(null);
        }
Exemplo n.º 2
0
 public IDurableTopicSubscription CreateSubscriptions(string topicName, MessageReceivedCallback messageReceivedCallback)
 {
     // cretews a subscription against a topic
     try
     {
         ITopic topic = GetTopic(topicName);
         return(topic.CreateDurableSubscription(Guid.NewGuid().ToString(), SubscriptionPolicy.Exclusive, messageReceivedCallback, null));
     }
     catch
     {
         throw;
     }
 }
Exemplo n.º 3
0
        public static IDurableTopicSubscription RunSubscriber(string topicName, string subscriptionName, SubscriptionPolicy policy)
        {
            ITopic topic = _cache.MessagingService.GetTopic(topicName);

            if (topic == null)
            {
                topic = _cache.MessagingService.CreateTopic(topicName);
            }

            //Creates durable subscription
            //subscriptionName: User defined name for subscription
            //Subscription Policy: If subscription policy is shared , it means subscription can hold multiple active subscribers
            //                     If subscription policy is exclusive , it means subscription can hold one active client only.
            return(topic.CreateDurableSubscription(subscriptionName, policy, MessageReceivedCallback, new TimeSpan(1, 0, 0)));
        }