public InternalConsumer( IHandlerRunner handlerRunner, IConsumerDispatcher consumerDispatcher) { this.handlerRunner = handlerRunner; this.consumerDispatcher = consumerDispatcher; }
public static void PartitionsRevoked(ILogger logger, IReadOnlyList <TopicPartitionOffset> partitions, IConsumerDispatcher consumerDispatcher, Func <ConsumerContext, IEnumerable <TopicPartition>, Task> partitionsRevokedHandler, ConsumerContext context) { if (!partitions.Any()) { return; } AsyncHelpers.RunSync(async() => { var partitionsByTopic = partitions .GroupBy(p => p.Topic) .Select(g => new { Topic = g.Key, Partitions = g.Select(p => p.Partition.Value) }) .ToList(); logger.Info("Revocation: {@partitions}", partitionsByTopic); if (partitionsRevokedHandler != null) { await partitionsRevokedHandler(context, partitions.Select(p => p.TopicPartition)); } foreach (var revocation in partitionsByTopic) { await consumerDispatcher.Revoke(revocation.Topic, revocation.Partitions); } }); }
public InMemConsumerImplementation(InMemEventBroker eventBroker, ILoggerFactory loggerFactory, Topics topics, IConsumerDispatcher consumerDispatcher, ConsumerContext consumerContext) { if (loggerFactory == null) { throw new ArgumentNullException(nameof(loggerFactory)); } _eventBroker = eventBroker ?? throw new ArgumentNullException(nameof(eventBroker)); _logger = loggerFactory.GetLogger(typeof(InMemConsumerImplementation)); }
public BasicConsumer(Action <BasicConsumer> cancelled, IConsumerDispatcher consumerDispatcher, IQueue queue, IEventBus eventBus, IHandlerRunner handlerRunner, Func <byte[], MessageProperties, MessageReceivedInfo, Task> onMessage, IEasyNetQLogger logger, IModel model) { Queue = queue; OnMessage = onMessage; this.cancelled = cancelled; this.consumerDispatcher = consumerDispatcher; this.eventBus = eventBus; this.handlerRunner = handlerRunner; this.logger = logger; Model = model; }
public BasicConsumer(Action <BasicConsumer> cancelled, IConsumerDispatcher consumerDispatcher, IQueue queue, IEventBus eventBus, IHandlerRunner handlerRunner, Func <byte[], MessageProperties, MessageReceivedInfo, Task> onMessage, IModel model) { Preconditions.CheckNotNull(onMessage, "onMessage"); Queue = queue; OnMessage = onMessage; this.cancelled = cancelled; this.consumerDispatcher = consumerDispatcher; this.eventBus = eventBus; this.handlerRunner = handlerRunner; Model = model; }
public InternalConsumer( IHandlerRunner handlerRunner, IConsumerDispatcher consumerDispatcher, IConventions conventions, IEventBus eventBus) { Preconditions.CheckNotNull(handlerRunner, "handlerRunner"); Preconditions.CheckNotNull(consumerDispatcher, "consumerDispatcher"); Preconditions.CheckNotNull(conventions, "conventions"); Preconditions.CheckNotNull(eventBus, "eventBus"); this.handlerRunner = handlerRunner; this.consumerDispatcher = consumerDispatcher; this.conventions = conventions; this.eventBus = eventBus; }
public InternalConsumer( IHandlerRunner handlerRunner, IEasyNetQLogger logger, IConsumerDispatcher consumerDispatcher, IConventions conventions, IConnectionConfiguration connectionConfiguration) { Preconditions.CheckNotNull(handlerRunner, "handlerRunner"); Preconditions.CheckNotNull(logger, "logger"); Preconditions.CheckNotNull(consumerDispatcher, "consumerDispatcher"); Preconditions.CheckNotNull(conventions, "conventions"); Preconditions.CheckNotNull(connectionConfiguration, "connectionConfiguration"); this.handlerRunner = handlerRunner; this.logger = logger; this.consumerDispatcher = consumerDispatcher; this.conventions = conventions; this.connectionConfiguration = connectionConfiguration; }
public BasicConsumer( Action <BasicConsumer> cancelled, IConsumerDispatcher consumerDispatcher, IQueue queue, IEventBus eventBus, IHandlerRunner handlerRunner, MessageHandler onMessage, IModel model ) { Preconditions.CheckNotNull(onMessage, "onMessage"); Queue = queue; OnMessage = onMessage; this.cancelled = cancelled; this.consumerDispatcher = consumerDispatcher; this.eventBus = eventBus; this.handlerRunner = handlerRunner; Model = model; }
protected ModelBase(bool dispatchAsync, int concurrency, ISession session) { ConsumerDispatcher = dispatchAsync ? (IConsumerDispatcher) new AsyncConsumerDispatcher(this, concurrency) : new ConsumerDispatcher(this, concurrency); _emptyBasicProperties = CreateBasicProperties(); Action <Exception, string> onException = (exception, context) => OnCallbackException(CallbackExceptionEventArgs.Build(exception, context)); _basicAcksWrapper = new EventingWrapper <BasicAckEventArgs>("OnBasicAck", onException); _basicNacksWrapper = new EventingWrapper <BasicNackEventArgs>("OnBasicNack", onException); _basicRecoverOkWrapper = new EventingWrapper <EventArgs>("OnBasicRecover", onException); _basicReturnWrapper = new EventingWrapper <BasicReturnEventArgs>("OnBasicReturn", onException); _callbackExceptionWrapper = new EventingWrapper <CallbackExceptionEventArgs>(string.Empty, (exception, context) => { }); _flowControlWrapper = new EventingWrapper <FlowControlEventArgs>("OnFlowControl", onException); _modelShutdownWrapper = new EventingWrapper <ShutdownEventArgs>("OnModelShutdown", onException); _recoveryWrapper = new EventingWrapper <EventArgs>("OnModelRecovery", onException); session.CommandReceived = HandleCommand; session.SessionShutdown += OnSessionShutdown; Session = session; }
protected ModelBase(ConnectionConfig config, ISession session) { ContinuationTimeout = config.ContinuationTimeout; ConsumerDispatcher = config.DispatchConsumersAsync ? (IConsumerDispatcher) new AsyncConsumerDispatcher(this, config.DispatchConsumerConcurrency) : new ConsumerDispatcher(this, config.DispatchConsumerConcurrency); Action <Exception, string> onException = (exception, context) => OnCallbackException(CallbackExceptionEventArgs.Build(exception, context)); _basicAcksWrapper = new EventingWrapper <BasicAckEventArgs>("OnBasicAck", onException); _basicNacksWrapper = new EventingWrapper <BasicNackEventArgs>("OnBasicNack", onException); _basicRecoverOkWrapper = new EventingWrapper <EventArgs>("OnBasicRecover", onException); _basicReturnWrapper = new EventingWrapper <BasicReturnEventArgs>("OnBasicReturn", onException); _callbackExceptionWrapper = new EventingWrapper <CallbackExceptionEventArgs>(string.Empty, (exception, context) => { }); _flowControlWrapper = new EventingWrapper <FlowControlEventArgs>("OnFlowControl", onException); _modelShutdownWrapper = new EventingWrapper <ShutdownEventArgs>("OnModelShutdown", onException); _recoveryWrapper = new EventingWrapper <EventArgs>("OnModelRecovery", onException); session.CommandReceived = HandleCommand; session.SessionShutdown += OnSessionShutdown; Session = session; }
public KafkaConsumerImplementation(ILoggerFactory loggerFactory, string address, IEnumerable <string> topics, string group, IConsumerDispatcher consumerDispatcher, IPositionManager positionManager) { if (loggerFactory == null) { throw new ArgumentNullException(nameof(loggerFactory)); } if (topics == null) { throw new ArgumentNullException(nameof(topics)); } _logger = loggerFactory.GetLogger(typeof(KafkaConsumerImplementation)); _address = address ?? throw new ArgumentNullException(nameof(address)); _group = group ?? throw new ArgumentNullException(nameof(group)); _consumerDispatcher = consumerDispatcher ?? throw new ArgumentNullException(nameof(consumerDispatcher)); _topics = topics.ToArray(); _positionManager = positionManager; _worker = new Thread(Run) { IsBackground = true }; }
public InternalConsumer( IHandlerRunner handlerRunner, ILogger logger, IConsumerDispatcher consumerDispatcher, IConventions conventions, ConnectionConfiguration connectionConfiguration, IEventBus eventBus) { Preconditions.CheckNotNull(handlerRunner, "handlerRunner"); Preconditions.CheckNotNull(logger, "logger"); Preconditions.CheckNotNull(consumerDispatcher, "consumerDispatcher"); Preconditions.CheckNotNull(conventions, "conventions"); Preconditions.CheckNotNull(connectionConfiguration, "connectionConfiguration"); Preconditions.CheckNotNull(eventBus, "eventBus"); this.handlerRunner = handlerRunner; this.logger = logger; this.consumerDispatcher = consumerDispatcher; this.conventions = conventions; this.connectionConfiguration = connectionConfiguration; this.eventBus = eventBus; }
public FileSystemConsumerImplementation(string directoryPath, ILoggerFactory loggerFactory, IEnumerable <string> topics, string group, IConsumerDispatcher consumerDispatcher, IPositionManager positionManager) { if (topics == null) { throw new ArgumentNullException(nameof(topics)); } if (loggerFactory == null) { throw new ArgumentNullException(nameof(loggerFactory)); } _directoryPath = directoryPath; _consumerDispatcher = consumerDispatcher ?? throw new ArgumentNullException(nameof(consumerDispatcher)); _positionManager = positionManager ?? throw new ArgumentNullException(nameof(positionManager)); _logger = loggerFactory.GetLogger(typeof(FileSystemConsumerImplementation)); _workers = topics .Select(topic => new Thread(() => PumpTopic(topic)) { Name = $"Kafkaesque worker for topic '{topic}'" }) .ToList(); }
protected ModelBase(ISession session, ConsumerWorkService workService) { if (workService is AsyncConsumerWorkService asyncConsumerWorkService) { ConsumerDispatcher = new AsyncConsumerDispatcher(this, asyncConsumerWorkService); } else { ConsumerDispatcher = new ConcurrentConsumerDispatcher(this, workService); } _emptyBasicProperties = CreateBasicProperties(); Action <Exception, string> onException = (exception, context) => OnCallbackException(CallbackExceptionEventArgs.Build(exception, context)); _basicAcksWrapper = new EventingWrapper <BasicAckEventArgs>("OnBasicAck", onException); _basicNacksWrapper = new EventingWrapper <BasicNackEventArgs>("OnBasicNack", onException); _basicRecoverOkWrapper = new EventingWrapper <EventArgs>("OnBasicRecover", onException); _basicReturnWrapper = new EventingWrapper <BasicReturnEventArgs>("OnBasicReturn", onException); _callbackExceptionWrapper = new EventingWrapper <CallbackExceptionEventArgs>(string.Empty, (exception, context) => { }); _flowControlWrapper = new EventingWrapper <FlowControlEventArgs>("OnFlowControl", onException); _modelShutdownWrapper = new EventingWrapper <ShutdownEventArgs>("OnModelShutdown", onException); _recoveryWrapper = new EventingWrapper <EventArgs>("OnModelRecovery", onException); Initialise(session); }
public ModelBase(ISession session, ConsumerWorkService workService) { Initialise(session); ConsumerDispatcher = new ConcurrentConsumerDispatcher(this, workService); }