Пример #1
0
        public async Task SubscribeAsync <T, H>()
            where T : EventBase
            where H : IEventHandler <T>
        {
            var eventName = typeof(T).Name;

            var containsKey = _subscriptionManager.HasSubscriptionsForEvent <T>();

            if (!containsKey)
            {
                try
                {
                    await _subscriptionClient.AddRuleAsync(new RuleDescription
                    {
                        Filter = new CorrelationFilter {
                            Label = eventName
                        },
                        Name = eventName
                    });
                }
                catch (ServiceBusException ex)
                {
                    //TODO: Logging
                }
            }

            _subscriptionManager.AddSubscriptionForEvent <T, H>();
        }