Example #1
0
 public EasyNetQPublisher(IAdvancedBus bus, string exchangename, IModelNamingConventionController modelNamingConventionController)
 {
     _bus      = bus;
     _exchange = new AsyncLazy <IExchange>(async() =>
                                           await _bus.ExchangeDeclareAsync(exchangename, ExchangeType.Topic));
     _modelNamingConventionController = modelNamingConventionController;
 }
 public TrackingEventsSubscriptionSelector(IModelNamingConventionController modelNamingConventionController)
 {
     _modelNamingConventionController        = modelNamingConventionController;
     _defaultTrackingMessageEventType        = _modelNamingConventionController.GetTrackingMessageEventType("*");
     _defaultDeadLetterQueueMessageEventType =
         _modelNamingConventionController.GetDeadLetterQueueMessageEventType("*");
 }
 public DefaultDeadLetterSubscriberFactory(ISubscriberFactory subscriberFactory,
                                           IModelNamingConventionController modelNamingConventionController,
                                           IPublisher publisher)
 {
     _subscriberFactory = subscriberFactory;
     _modelNamingConventionController = modelNamingConventionController;
     _publisher = publisher;
 }
 public DefaultTrackerFactory(ISubscriberFactory subscriberFactory,
                              ITrackerNamingConventionController trackerNamingConventionController,
                              IModelNamingConventionController modelNamingConventionController)
 {
     _subscriberFactory = subscriberFactory;
     _trackerNamingConventionController = trackerNamingConventionController;
     _modelNamingConventionController   = modelNamingConventionController;
 }
 public DefaultDeadLetterSubscriber(ISubscriber subscriber,
                                    IModelNamingConventionController modelNamingConventionController,
                                    IPublisher publisher, string targetSubscriberDeadLetterQueueName)
 {
     _subscriber = subscriber;
     _modelNamingConventionController = modelNamingConventionController;
     _publisher = publisher;
     _targetSubscriberDeadLetterQueueName = targetSubscriberDeadLetterQueueName;
 }
Example #6
0
        public void Subscribe_SubscriptionsAreProvided_EventTypesAreAdjustedAndSubscriptionsAreApplied()
        {
            //prepare

            var mockSubscriber = new Mock <ISubscriber>();

            IDictionary <string, ISubscription> actualSubscriptions = null;

            mockSubscriber.Setup(x => x.Subscribe(It.IsAny <IDictionary <string, ISubscription> >()))
            .Callback <IDictionary <string, ISubscription> > (
                (subscriptions) => { actualSubscriptions = subscriptions; });

            var mockModelNamingConventionController = new Mock <IModelNamingConventionController>();

            mockModelNamingConventionController.Setup(x => x.GetDeadLetterQueueMessageEventType(It.IsAny <string>()))
            .Returns((string subscriberName) => string.Concat("deadletter.", subscriberName));
            mockModelNamingConventionController.Setup(x => x.GetTrackingMessageEventType(It.IsAny <string>()))
            .Returns((string originalEventType) => string.Concat("ok.", originalEventType));
            IModelNamingConventionController defaultNamingConvensionController = mockModelNamingConventionController.Object;

            DefaultTracker tracker = new DefaultTracker(mockSubscriber.Object, defaultNamingConvensionController);

            //act
            IDictionary <string, ISubscription> successfulProcessingSubscriptions = new Dictionary <string, ISubscription>();
            IDictionary <string, ISubscription> failedProcessingSubscriptions     = new Dictionary <string, ISubscription>();

            string eventType1 = "eventType1";
            string eventType2 = "eventType2";

            var mockEventType1SuccessfulSubscription = new Mock <ISubscription>();
            var mockEventType2SuccessfulSubscription = new Mock <ISubscription>();
            var mockEventType1FailedSubscription     = new Mock <ISubscription>();
            var mockEventType2FailedfulSubscription  = new Mock <ISubscription>();

            successfulProcessingSubscriptions.Add(eventType1, mockEventType1SuccessfulSubscription.Object);
            successfulProcessingSubscriptions.Add(eventType2, mockEventType2SuccessfulSubscription.Object);

            failedProcessingSubscriptions.Add(eventType1, mockEventType1FailedSubscription.Object);
            failedProcessingSubscriptions.Add(eventType2, mockEventType2FailedfulSubscription.Object);

            tracker.Subscribe(successfulProcessingSubscriptions, failedProcessingSubscriptions);

            //check
            IDictionary <string, ISubscription> expecteEffectiveSubscriptions = new Dictionary <string, ISubscription>();

            expecteEffectiveSubscriptions.Add(defaultNamingConvensionController.GetTrackingMessageEventType(eventType1),
                                              mockEventType1SuccessfulSubscription.Object);
            expecteEffectiveSubscriptions.Add(defaultNamingConvensionController.GetTrackingMessageEventType(eventType2),
                                              mockEventType2SuccessfulSubscription.Object);

            expecteEffectiveSubscriptions.Add(defaultNamingConvensionController.GetDeadLetterQueueMessageEventType(eventType1),
                                              mockEventType1FailedSubscription.Object);
            expecteEffectiveSubscriptions.Add(defaultNamingConvensionController.GetDeadLetterQueueMessageEventType(eventType2),
                                              mockEventType2FailedfulSubscription.Object);

            expecteEffectiveSubscriptions.ShouldBeEquivalentTo(actualSubscriptions);
        }
Example #7
0
        public void UnSubscribe_UnSubscribeFromInternalSubscriber()
        {
            //prepare

            var mockSubscriber = new Mock <ISubscriber>();

            var mockModelNamingConventionController = new Mock <IModelNamingConventionController>();
            IModelNamingConventionController defaultModelNamingConventionController = mockModelNamingConventionController.Object;

            DefaultTracker tracker = new DefaultTracker(mockSubscriber.Object, defaultModelNamingConventionController);

            //act

            tracker.Dispose();

            //check
            mockSubscriber.Verify(v => v.Dispose(), Times.Once);
        }
Example #8
0
 public ExecutionHandlingStrategy(string name, EasyNetQPublisher waitEasyNetQPublisher, int maxRetry,
                                  IModelNamingConventionController modelNamingConventionController, bool explicitAcknowledgments, IPublisher publisher, bool storedeadletter)
 {
     _name = name;
     _waitEasyNetQPublisher = waitEasyNetQPublisher;
     _maxRetry = maxRetry;
     _modelNamingConventionController = modelNamingConventionController;
     _publisher       = publisher;
     _storedeadletter = storedeadletter;
     if (explicitAcknowledgments)
     {
         _successExecutionHandler = HandleTrackingAsync;
         _failedExecutionHandler  = HandleDeadletterQueueAndTrackingAsync;
     }
     else
     {
         _failedExecutionHandler = HandleDeadletterQueueWithoutTrackingAsync;
     }
 }
Example #9
0
 public DefaultTracker(ISubscriber subscriber, IModelNamingConventionController modelNamingConventionController)
 {
     _subscriber = subscriber;
     _modelNamingConventionController = modelNamingConventionController;
 }
Example #10
0
 public DefaultTrackerNamingConventionController(IModelNamingConventionController modelNamingConventionController)
 {
     _trackerNamingConventionController = modelNamingConventionController;
 }