コード例 #1
0
        public bool ConsumeAddInstanceSubscription(
            AddInstanceSubscription subscription)
        {
            pht.Batch(actions =>
            {
                var message = new MemoryStream();
                messageSerializer.Serialize(new[] { subscription }, message);
                var itemId = actions.AddItem(new AddItemRequest
                {
                    Key  = SubscriptionsKey,
                    Data = message.ToArray()
                });

                remoteInstanceSubscriptions.Add(
                    subscription.InstanceSubscriptionKey,
                    subscription.Type,
                    new Uri(subscription.Endpoint),
                    itemId);

                actions.Commit();
            });

            RaiseSubscriptionChanged();
            return(true);
        }
コード例 #2
0
        public bool ConsumeAddInstanceSubscription(AddInstanceSubscription subscription)
        {
            if (logger.IsDebugEnabled)
            {
                logger.DebugFormat("Adding instance subscription for {0} on {1}.", subscription.InstanceSubscriptionKey, subscription.Endpoint);
            }

            int itemId = storage.AddItem(SubscriptionsKey + localEndpoint, subscription, SerializeMessage);

            remoteInstanceSubscriptions.Add(
                subscription.InstanceSubscriptionKey,
                subscription.Type,
                new Uri(subscription.Endpoint),
                itemId);

            RaiseSubscriptionChanged();
            return(true);
        }
コード例 #3
0
        private bool ConsumeAddInstanceSubscription(CurrentMessageInformation msgInfo, AddInstanceSubscription subscription)
        {
            var msmqMsgInfo = msgInfo as MsmqCurrentMessageInformation;
            var msgId       = msgInfo.TransportMessageId;

            if (msmqMsgInfo != null)
            {
                msmqMsgInfo.Queue.Send(
                    msmqMsgInfo.MsmqMessage.SetSubQueueToSendTo(SubQueue.Subscriptions));
                // may be changed by the sending
                msgId = msmqMsgInfo.MsmqMessage.Id;
            }
            remoteInstanceSubscriptions.Add(
                subscription.InstanceSubscriptionKey,
                subscription.Type,
                new Uri(subscription.Endpoint),
                msgId);
            RaiseSubscriptionChanged();
            return(true);
        }