示例#1
0
 /// <summary>
 /// Called when a message is successfully delivered by the service bus
 /// </summary>
 /// <param name="delivery"></param>
 protected internal virtual void OnMessageDelivered(MessageDelivery delivery)
 {
 }
示例#2
0
 /// <summary>
 /// Called when a message delivery fails
 /// </summary>
 /// <param name="delivery"></param>
 /// <param name="permanent">Indicates if the message will be retried (false) or placed in the failure queue (true)</param>
 protected internal virtual void OnMessageDeliveryFailed(MessageDelivery delivery, bool permanent)
 {
 }
        internal void NotifyFailure(MessageDelivery delivery, bool permanent)
        {
            foreach (RuntimeService service in ServiceLocator.GetAllInstances<RuntimeService>())
            {
                service.OnMessageDeliveryFailed(delivery, false);
            }

            var failed = _messageDeliveryFailed;
            if (failed != null) failed(this, new MessageDeliveryFailedEventArgs() { MessageDelivery = delivery, Permanent = permanent });
        }
        void deliverToSubscriptionEndpoint(TimeSpan timeout, PublishRequest publishRequest)
        {
            SubscriptionEndpoint se = _subscriptionEndpoint;

            publishRequest = PublishRequest.Copy(publishRequest, new KeyValuePair<MessageDeliveryContextKey, object>(MessageDelivery.PublishRequestId, publishRequest.PublishRequestId));

            using (TransactionScope ts = new TransactionScope())
            {
                MessageDelivery md = new MessageDelivery(Guid.NewGuid().ToString(), se.Id, publishRequest.ContractType, publishRequest.Action, publishRequest.Message, MaxRetries, 0, null, publishRequest.Context, DateTime.Now + timeout);
                DeliveryCore deliveryCore = ServiceLocator.GetInstance<DeliveryCore>();
                deliveryCore.Deliver(md);
                ts.Complete();
            }
        }
 internal void NotifyExpired(MessageDelivery delivery)
 {
     foreach (RuntimeService service in ServiceLocator.GetAllInstances<RuntimeService>())
     {
         service.OnMessageDeliveryExpired(delivery);
     }
     var handler = _messageDeliveryExpired;
     if (handler != null)
     {
         handler(this, new MessageDeliveryEventArgs() { MessageDelivery = delivery });
     }
 }