Ejemplo n.º 1
0
        public async Task <MessageSubscriber <T> > CreateSubscriberAsync <T>(IMessageHandler <T> messageHandler)
            where T : Message
        {
            var exchangeName = exchangeNameResolver.GetExchangeName <T>();
            var subscriber   = new MessageSubscriber <T>(exchangeSubscriberService)
            {
                MessageSubscriberInfo = new MessageSubscriberInfo
                {
                    ExchangeName = exchangeName,
                    QueueName    = FormatQueueName(exchangeName)
                },
                MessageHandler = messageHandler
            };

            return(await Task.FromResult(subscriber));
        }
Ejemplo n.º 2
0
        public async Task <Subscriber <T> > CreateSubscriberAsync <T>(string subscriberId, Func <T, Task> onMessageAsync) where T : class
        {
            var exchangeName = _exchangeNameResolver.GetExchangeName <T>();
            var queueName    = _queueNameResolver.GetQueueName(exchangeName, subscriberId);
            var subscriber   = new Subscriber <T>(_cacheClient, _exchangeSubscriberService)
            {
                SubscriberInfo = new SubscriberInfo
                {
                    SubscriberId = subscriberId,
                    ExchangeName = exchangeName,
                    QueueName    = queueName
                },
                OnMessageAsync = onMessageAsync
            };

            await subscriber.InitializeAsync();

            return(subscriber);
        }
Ejemplo n.º 3
0
        public string GetSubscriberKey(object message)
        {
            var exchangeName = _exchangeNameResolver.GetExchangeName(message);

            return(GetSubscriberKey(exchangeName));
        }
Ejemplo n.º 4
0
 public async Task NotifyOfNewMessagesAsync(object message)
 {
     var exchangeName = _exchangeNameResolver.GetExchangeName(message);
     await _cacheClient.PublishAsync(exchangeName, exchangeName);
 }