public static void SendRequestStartedNotification(String clientId, Guid requestId, String requestPath, Uri requestUri, Byte tileSize, DateTime submissionTime)
        {
            ChannelFactory <INotificationChannel> channelFactory = null;
            INotificationChannel channel = null;

            try
            {
                channelFactory = GetChannelFactory(clientId);
                channel        = channelFactory.CreateChannel();

                channel.Open();

                channel.NotifyRequestStarted(requestId, requestPath, requestUri, tileSize, submissionTime);
            }
            catch (Exception e)
            {
                Trace.TraceError("Client: {0}{4}Exception: {1}{4}Message: {2}{4}Trace: {3}",
                                 clientId,
                                 e.GetType(),
                                 e.Message,
                                 e.StackTrace,
                                 Environment.NewLine);
            }
            finally
            {
                if ((channel != null) && (channel.State == CommunicationState.Opened))
                {
                    channel.Close();
                }
                if ((channelFactory != null) && (channelFactory.State == CommunicationState.Opened))
                {
                    channelFactory.Close();
                }
            }
        }
示例#2
0
 public InAppNotificationsAdminController(INotificationChannel notificationChannel, IUserSessions sessions, InAppNotificationRepository repository, ILogger logger)
 {
     _notificationChannel = notificationChannel;
     _sessions            = sessions;
     _repository          = repository;
     _logger = logger;
 }
示例#3
0
 public NotifyReceiptChannelModule(INotificationChannel notificationChannel)
 {
     if (notificationChannel == null)
     {
         throw new ArgumentNullException(nameof(notificationChannel));
     }
     _notificationChannel = notificationChannel;
 }
示例#4
0
 public NotificationBusTests()
 {
     notificationChannel1 = Substitute.For <INotificationChannel>();
     notificationChannel1.NotificationTypes.Returns(new[] { typeof(Notification1) });
     notificationChannel2 = Substitute.For <INotificationChannel>();
     notificationChannel2.NotificationTypes.Returns(new[] { typeof(Notification2) });
     sut = new NotificationBus(new[] { notificationChannel1, notificationChannel2 });
 }
 public static SurrogateForINotificationChannel Convert(INotificationChannel value)
 {
     if (value == null)
     {
         return(null);
     }
     return(new SurrogateForINotificationChannel());
 }
示例#6
0
        public GameFinderConfigService(
            IConfiguration config,
            INotificationChannel notificationChannel)
        {
            _notificationChannel = notificationChannel;

            config.SettingsChanged += (s, c) => ApplyConfig(c);
            ApplyConfig(config.Settings);
        }
示例#7
0
        /// <summary>
        /// Asynchronously sends a notification to the queue.
        /// </summary>
        /// <param name="account">The account to send the notification to.</param>
        /// <param name="notification">A notification to send.</param>
        /// <returns>The task.</returns>
        public Task SendAsync <TAccountKey>(NotificationAccount <TAccountKey> account, Notification notification)
        {
            Throw.IfArgumentNull(account, nameof(account));
            Throw.IfArgumentNull(notification, nameof(notification));

            INotificationChannel channel = this.channelFactory.GetChannel(notification);

            return(channel.SendAsync(account, notification));
        }
 public static bool OverrideReceiver(INotificationChannel channel, ICanTell receiver)
 {
     var akkaChannel = channel as AkkaReceiverNotificationChannel;
     if (akkaChannel != null)
     {
         akkaChannel.Receiver = receiver;
         return true;
     }
     else
     {
         return false;
     }
 }
示例#9
0
            public static SurrogateForINotificationChannel Convert(INotificationChannel value)
            {
                if (value == null)
                {
                    return(null);
                }

                var actor = (IActorRef)(((AkkaReceiverNotificationChannel)value).Receiver);

                return(new SurrogateForINotificationChannel {
                    Actor = actor
                });
            }
示例#10
0
 public AbstractMessageProcessor(
     INotificationChannel <T> notificationChannel,
     IStorageProvider <T> storageProvider,
     IStorageMessageSerializer messageSerializer,
     ITransactionTracker <T> transactionTracker,
     IAsbtractMqFactory <T> mqFactory)
 {
     _notificationChannel = notificationChannel ?? throw new ArgumentNullException(nameof(notificationChannel));
     _storageProvider     = storageProvider ?? throw new ArgumentNullException(nameof(storageProvider));
     _messageSerializer   = messageSerializer ?? throw new ArgumentNullException(nameof(messageSerializer));
     _transactionTracker  = transactionTracker ?? throw new ArgumentNullException(nameof(transactionTracker));
     _mqFactory           = mqFactory ?? throw new ArgumentNullException(nameof(mqFactory));
 }
        public static bool OverrideReceiver(INotificationChannel channel, ICanTell receiver)
        {
            var akkaChannel = channel as AkkaReceiverNotificationChannel;

            if (akkaChannel != null)
            {
                akkaChannel.Receiver = receiver;
                return(true);
            }
            else
            {
                return(false);
            }
        }
        public async Task ItShouldNotCommitNotificationsIfReceivedAnEmptyCollectionOfNotifications(
            INotificationChannel <long> channel,
            AbstractMessageProcessor <long> sut)
        {
            // Arrange
            A.CallTo(() => channel.Receive(A <CancellationToken> ._))
            .Returns(Enumerable.Empty <INotification <long> >().ToArray());

            // Act
            await sut.GetMessages(CancellationToken.None);

            // Assert
            A.CallTo(() => channel.Commit(A <INotification <long>[]> ._, A <NotificationTransaction> ._))
            .MustNotHaveHappened();
        }
示例#13
0
        private NotificationScheduler <Guid> CreateScheduler(NotificationTest test, out INotificationChannel channel)
        {
            channel = Substitute.For <INotificationChannel>();

            NotificationChannelFactory factory = new NotificationChannelFactory();

            factory.RegisterChannel <PushNotification>(channel);

            return
                (new NotificationScheduler <Guid>(
                     new NotificationQueue(factory),
                     new NotificationAccountManager <Guid>(test.NotificationAccountRepository),
                     test.NotificationRepository,
                     test.EventPublisher));
        }
        public async Task ItShouldStoreTheExpectedMessagesWhenNoExceptionIsThrown(
            [Frozen] IStorageProvider <long> storageProvider,
            [Frozen] IStorageMessageSerializer serializer,
            CancellationToken cancellation,
            NotificationTransaction expectedTransaction,
            INotification <long>[] expectedNotifications,
            INotificationChannel <long> channel,
            AbstractMessageProcessor <long> sut)
        {
            // Arrange

            // Act
            await sut.GetMessages(cancellation);

            // Assert
            A.CallTo(() => storageProvider.Store(serializer, expectedNotifications)).MustHaveHappened(Repeated.Exactly.Once)
            .Then(A.CallTo(() => channel.Commit(expectedNotifications, expectedTransaction)).MustHaveHappened(Repeated.Exactly.Once));
        }
        public async Task ItShouldReturnTheExpectedResultsIfReceivedAnEmptyCollectionOfNotifications(
            INotificationChannel <long> channel,
            AbstractMessageProcessor <long> sut)
        {
            // Arrange
            A.CallTo(() => channel.Receive(A <CancellationToken> ._))
            .Returns(Enumerable.Empty <INotification <long> >().ToArray());

            var likeness =
                new MessageEnvelope(null, null)
                .AsSource()
                .OfLikeness <MessageEnvelope>();

            // Act
            var actual = await sut.GetMessages(CancellationToken.None);

            // Assert
            likeness.ShouldEqual(actual);
        }
        public async Task ItShouldRollbackTheExpectedMessagesWhenAnExceptionIsThrown(
            [Frozen] IStorageProvider <long> storageProvider,
            NotificationTransaction expectedTransaction,
            INotification <long>[] expectedNotifications,
            INotificationChannel <long> channel,
            AbstractMessageProcessor <long> sut)
        {
            // Arrange
            A.CallTo(() => storageProvider.Store(
                         A <IStorageMessageSerializer> ._,
                         A <INotification <long>[]> ._))
            .Throws <Exception>();

            // Act
            await sut.GetMessages(CancellationToken.None);

            // Assert
            A.CallTo(() => channel.Commit(A <INotification <long>[]> ._, A <NotificationTransaction> ._)).MustNotHaveHappened();
            A.CallTo(() => channel.Rollback(expectedNotifications, expectedTransaction)).MustHaveHappened(Repeated.Exactly.Once);
        }
示例#17
0
 public void RegisterNotificationChannel(INotificationChannel channel)
 // a public method to provide access to the _notificationChannels private field
 {
     _notificationChannels.Add(channel);
 }
示例#18
0
 public void RegistorNotificationChannel(INotificationChannel notificationChannel)
 {
     _notificationChannels.Add(notificationChannel);
 }
 public UserPairingObserver(INotificationChannel channel, int observerId = 0)
     : base(channel, observerId)
 {
 }
 public static void Notify(INotificationChannel channel, INotificationReceiver receiver, NotificationContent content)
 {
     channel.Notify(receiver, content);
 }
 public NotificationChannelController(INotificationChannel channel)
 {
     this.channel = channel;
 }
 public ActorBoundChannelObserver(INotificationChannel channel, int observerId = 0)
     : base(channel, observerId)
 {
 }
示例#23
0
 public void RegisterNotificationService(INotificationChannel channel)
 {
     _lstNotifications.Add(channel);
 }
 public SubscriptionMessage(INotificationChannel notificationChannel, SubscriptionId subscriptionId, IEventMatcher eventMatcher)
 {
     NotificationChannel = notificationChannel;
     SubscriptionId = subscriptionId;
     EventMatcher = eventMatcher;
 }
示例#25
0
            public static SurrogateForINotificationChannel Convert(INotificationChannel value)
            {
                if (value == null)
                    return null;

                var actor = (IActorRef)(((AkkaReceiverNotificationChannel)value).Receiver);
                return new SurrogateForINotificationChannel { Actor = actor };
            }
 public HomeController(ILogger <HomeController> logger, INotificationChannel notificationChannel)
 {
     _logger = logger;
     _notificationChannel = notificationChannel;
 }
示例#27
0
 public void RegistrationNotification(INotificationChannel channel)
 {
     _notificationChannel.Add(channel);
 }
 protected InterfacedObserver(INotificationChannel channel, int observerId)
 {
     Channel    = channel;
     ObserverId = observerId;
 }
 public UserPairingObserver(INotificationChannel channel, int observerId = 0)
     : base(channel, observerId)
 {
 }
 public GreetObserver(INotificationChannel channel, int observerId = 0)
     : base(channel, observerId)
 {
 }
 public ActorBoundChannelObserver(INotificationChannel channel, int observerId = 0)
     : base(channel, observerId)
 {
 }
 protected InterfacedObserver(INotificationChannel channel, int observerId)
 {
     Channel = channel;
     ObserverId = observerId;
 }
示例#33
0
 public void RegisterNotificationChannels(INotificationChannel notificationChannel)
 {
     _inotificationChannels.Add(notificationChannel);
 }
示例#34
0
 public void RegisterNotificationChannel(INotificationChannel channel)
 {
     _notificationChannels.Add(channel);
 }
示例#35
0
 public GreetObserver(INotificationChannel channel, int observerId = 0)
     : base(channel, observerId)
 {
 }
示例#36
0
 /// <summary>
 /// Registers a channel for a specific type of notification.
 /// </summary>
 /// <param name="channel">A channel to register.</param>
 public void RegisterChannel <TNotification>(INotificationChannel channel)
     where TNotification : Notification
 {
     this.RegisterChannel <TNotification>(() => channel);
 }
 public static SurrogateForINotificationChannel Convert(INotificationChannel value)
 {
     if (value == null) return null;
     return new SurrogateForINotificationChannel();
 }
示例#38
0
 public ProductionStepsChangedUseCase(INotificationChannel channel)
 {
     _channel = channel;
 }
示例#39
0
 public void RegisterNotificationChannel(INotificationChannel channel)
 {
     _notificationChannels.Add(channel);
 }
 public SubscriptionMessage(INotificationChannel notificationChannel, SubscriptionId subscriptionId, IEventMatcher eventMatcher)
 {
     NotificationChannel = notificationChannel;
     SubscriptionId      = subscriptionId;
     EventMatcher        = eventMatcher;
 }