protected void AddConsumer(AbstractConsumerSettings consumerSettings, IMessageProcessor <Message> messageProcessor)
        {
            var consumer = consumerSettings.GetKind() == PathKind.Topic
                ? new TopicSubscriptionConsumer(this, consumerSettings, messageProcessor) as BaseConsumer
                : new QueueConsumer(this, consumerSettings, messageProcessor);

            _consumers.Add(consumer);
        }
예제 #2
0
        private static void AssertIsTopicForSubscriptionName(AbstractConsumerSettings settings)
        {
            if (settings.GetKind() == PathKind.Queue)
            {
                var methodName = $".{nameof(SubscriptionName)}(...)";

                var messageType = settings is ConsumerSettings consumerSettings
                    ? consumerSettings.MessageType.FullName
                    : string.Empty;
                throw new ConfigurationMessageBusException($"The subscription name configuration ({methodName}) does not apply to Azure ServiceBus queues (it only applies to topic consumers). Remove the {methodName} configuration for type {messageType} and queue {settings.Topic} or change the consumer configuration to consume from topic {settings.Topic} instead.");
            }
        }
        public static string FormatIf(this AbstractConsumerSettings settings, bool logLevel)
        {
            if (!logLevel)
            {
                return(string.Empty);
            }

            if (settings.GetKind() == PathKind.Queue)
            {
                return($"Queue: {settings.Topic}");
            }
            return($"Topic: {settings.Topic}, SubscriptionName: {settings.GetSubscriptionName()}");
        }
예제 #4
0
        protected void AddConsumer(AbstractConsumerSettings consumerSettings, IMessageProcessor <Message> messageProcessor)
        {
            if (consumerSettings is null)
            {
                throw new ArgumentNullException(nameof(consumerSettings));
            }

            var consumer = consumerSettings.GetKind() == PathKind.Topic
                ? new TopicSubscriptionConsumer(this, consumerSettings, messageProcessor) as BaseConsumer
                : new QueueConsumer(this, consumerSettings, messageProcessor);

            _consumers.Add(consumer);
        }
        public static string FormatIf(this AbstractConsumerSettings consumerSettings, Message msg, bool logLevel)
        {
            if (!logLevel)
            {
                return(string.Empty);
            }

            if (consumerSettings.GetKind() == PathKind.Queue)
            {
                return($"Queue: {consumerSettings.Topic}, SequenceNumber: {msg.SystemProperties.SequenceNumber}, DeliveryCount: {msg.SystemProperties.DeliveryCount}");
            }

            return($"Topic: {consumerSettings.Topic}, SubscriptionName: {consumerSettings.GetSubscriptionName()}, SequenceNumber: {msg.SystemProperties.SequenceNumber}, DeliveryCount: {msg.SystemProperties.DeliveryCount}");
        }