public DefaultMessageHandler(string subscriptionName, Action <T, MessageDeliverEventArgs> msgHandlingAction, IConsumerErrorHandler consumerErrorHandler, ISerializer messageSerializer, IRabbitWatcher watcher) { if (msgHandlingAction == null) { throw new ArgumentNullException("msgHandlingAction"); } if (consumerErrorHandler == null) { throw new ArgumentNullException("consumerErrorHandler"); } if (messageSerializer == null) { throw new ArgumentNullException("messageSerializer"); } if (watcher == null) { throw new ArgumentNullException("watcher"); } _subscriptionName = subscriptionName; _watcher = watcher; _consumerErrorHandler = consumerErrorHandler; _messageSerializer = messageSerializer; _msgHandlingAction = msgHandlingAction; }
/// <summary> /// Initialize a DefaultMessageHandler /// </summary> /// <param name="subscriptionName"></param> /// <param name="msgHandlingAction"></param> /// <param name="consumerErrorHandler"></param> /// <param name="messageSerializer"></param> /// <param name="watcher"></param> public DefaultMessageHandler(string subscriptionName, Action <T, MessageDeliverEventArgs> msgHandlingAction, IConsumerErrorHandler consumerErrorHandler, ISerializer messageSerializer, IRabbitWatcher watcher) { if (msgHandlingAction == null) { throw new ArgumentNullException(nameof(msgHandlingAction)); } if (consumerErrorHandler == null) { throw new ArgumentNullException(nameof(consumerErrorHandler)); } if (messageSerializer == null) { throw new ArgumentNullException(nameof(messageSerializer)); } if (watcher == null) { throw new ArgumentNullException(nameof(watcher)); } _subscriptionName = subscriptionName; _watcher = watcher; _consumerErrorHandler = consumerErrorHandler; _messageSerializer = messageSerializer; _msgHandlingAction = msgHandlingAction; _typeName = Global.DefaultTypeNameSerializer.Serialize(typeof(T)); }
public DefaultMessageHandlerFactory(IConsumerErrorHandler consumerErrorHandler, IRabbitWatcher watcher) { if (consumerErrorHandler == null) { throw new ArgumentNullException("consumerErrorHandler"); } if (watcher == null) { throw new ArgumentNullException("watcher"); } _consumerErrorHandler = consumerErrorHandler; _watcher = watcher; }
public DefaultMessageHandlerFactory(IConsumerErrorHandler consumerErrorHandler, ISerializer messageSerializer, IRabbitWatcher watcher) { if (consumerErrorHandler == null) { throw new ArgumentNullException("consumerErrorHandler"); } if (messageSerializer == null) { throw new ArgumentNullException("messageSerializer"); } if (watcher == null) { throw new ArgumentNullException("watcher"); } _consumerErrorHandler = consumerErrorHandler; _messageSerializer = messageSerializer; _watcher = watcher; }
public DefaultMessageHandler(IConsumerErrorHandler consumerErrorHandler, Func<BasicDeliverEventArgs, Task> jobFactory, IRabbitWatcher watcher) { if (consumerErrorHandler == null) { throw new ArgumentNullException("consumerErrorHandler"); } if (jobFactory == null) { throw new ArgumentNullException("jobFactory"); } if (watcher == null) { throw new ArgumentNullException("watcher"); } _watcher = watcher; _consumerErrorHandler = consumerErrorHandler; _jobFactory = jobFactory; }
public PriorityMessageHandlerFactory(IConsumerErrorHandler consumerErrorHandler, IRabbitWatcher watcher) : base(consumerErrorHandler, watcher) { }
public PriorityMessageHandlerFactory(IConsumerErrorHandler consumerErrorHandler, ISerializer messageSerializer, IRabbitWatcher watcher) : base(consumerErrorHandler, messageSerializer, watcher) { }
public PriorityMessageHandlerForTest(string subscriptionName, Action <T, MessageDeliverEventArgs> msgHandlingAction, IConsumerErrorHandler consumerErrorHandler, ISerializer messageSerializer, IRabbitWatcher watcher) : base(subscriptionName, msgHandlingAction, consumerErrorHandler, messageSerializer, watcher) { }
public DefaultMessageHandlerForTest(string subscriptionName, Action <T, MessageDeliverEventArgs> msgHandlingAction, IConsumerErrorHandler consumerErrorHandler, ISerializer messageSerializer, IRabbitWatcher watcher) : base(subscriptionName, msgHandlingAction, consumerErrorHandler, messageSerializer, watcher) { HandlingComplete += x => { throw new Exception("HandlingCompleteException"); }; }
public PriorityMessageHandler(IConsumerErrorHandler consumerErrorHandler, Func<BasicDeliverEventArgs, Task> jobFactory, IRabbitWatcher watcher) : base(consumerErrorHandler, jobFactory, watcher) { }
public SequenceConsumer(IRabbitWatcher watcher, IConsumerErrorHandler consumerErrorHandler, ISerializer serializer, IModel channel, string consumerTag, Func<BasicDeliverEventArgs, Task> jobFactory, bool autoAck) : base(watcher, consumerErrorHandler, serializer, channel, consumerTag, jobFactory, 1) { _autoAck = autoAck; }
protected BurrowConsummer(IRabbitWatcher watcher, IConsumerErrorHandler consumerErrorHandler, ISerializer serializer, IModel channel, string consumerTag, Func<BasicDeliverEventArgs, Task> jobFactory, int batchSize) : base(channel, new SharedQueue()) { if (consumerErrorHandler == null) { throw new ArgumentNullException("consumerErrorHandler"); } if (watcher == null) { throw new ArgumentNullException("watcher"); } if (serializer == null) { throw new ArgumentNullException("serializer"); } if (jobFactory == null) { throw new ArgumentNullException("jobFactory"); } if (channel == null) { throw new ArgumentNullException("channel"); } if (batchSize < 1) { throw new ArgumentNullException("batchSize", "batchSize must be greter than or equal 1"); } if (string.IsNullOrEmpty(consumerTag)) { throw new ArgumentNullException("consumerTag", "consumerTag cannot be null or empty"); } Model.ModelShutdown += WhenChannelShutdown; Model.BasicRecoverAsync(true); BatchSize = batchSize; ConsumerTag = consumerTag; JobFactory = jobFactory; _pool = new Semaphore(BatchSize, BatchSize); Watcher = watcher; ConsumerErrorHandler = consumerErrorHandler; Serializer = serializer; _subscriptionCallbackThread = new Thread(_ => { while (!_disposed) { try { BasicDeliverEventArgs deliverEventArgs; lock (_sharedQueueLock) { _pool.WaitOne(); deliverEventArgs = (BasicDeliverEventArgs)Queue.Dequeue(); } if (deliverEventArgs != null) { HandleMessageDelivery(deliverEventArgs); } } catch (EndOfStreamException) { // do nothing here, EOS fired when queue is closed // Looks like the connection has gone away, so wait a little while // before continuing to poll the queue Thread.Sleep(10); } } }); _subscriptionCallbackThread.Start(); }