Ejemplo n.º 1
0
        public Subscription Subscribe <T>(SubscriptionOption <T> subscriptionOption)
        {
            TryConnectBeforeSubscribing();
            Func <IModel, IBasicConsumer> createConsumer = channel =>
                                                           _consumerManager.CreateConsumer(channel,
                                                                                           subscriptionOption.SubscriptionName,
                                                                                           subscriptionOption.MessageHandler,
                                                                                           subscriptionOption.BatchSize <= 0
                                                                             ? (ushort)1
                                                                             : subscriptionOption.BatchSize);

            var queueName    = (subscriptionOption.RouteFinder ?? _routeFinder).FindQueueName <T>(subscriptionOption.SubscriptionName);
            var prefetchSize = GetProperPrefetchSize(subscriptionOption.QueuePrefetchSize);

            return(CreateSubscription(subscriptionOption.SubscriptionName, queueName, createConsumer, prefetchSize));
        }
Ejemplo n.º 2
0
        public void Subscribe <T>(string subscriptionName, Action <T> onReceiveMessage)
        {
            TryConnectBeforeSubscribing();
            Func <IModel, string, IBasicConsumer> createConsumer = (channel, consumerTag) => _consumerManager.CreateConsumer(channel, subscriptionName, onReceiveMessage);

            CreateSubscription <T>(subscriptionName, createConsumer);
        }