public Given_a_PersistentConsumer() { eventBus = new EventBus(); internalConsumers = new List <IInternalConsumer>(); createConsumerCalled = 0; mockBuilder = new MockBuilder(); queue = new Queue(queueName, false); onMessage = (body, properties, info) => Task.Factory.StartNew(() => { }); persistentConnection = Substitute.For <IPersistentConnection>(); internalConsumerFactory = Substitute.For <IInternalConsumerFactory>(); internalConsumerFactory.CreateConsumer().Returns(x => { var internalConsumer = Substitute.For <IInternalConsumer>(); internalConsumers.Add(internalConsumer); createConsumerCalled++; return(internalConsumer); }); configuration = new ConsumerConfiguration(0); consumer = new PersistentConsumer( queue, onMessage, persistentConnection, configuration, internalConsumerFactory, eventBus); AdditionalSetup(); }
public ConsumerFactory(IInternalConsumerFactory internalConsumerFactory, IEventBus eventBus) { Preconditions.CheckNotNull(internalConsumerFactory, "internalConsumerFactory"); this.internalConsumerFactory = internalConsumerFactory; this.eventBus = eventBus; }
public void SetUp() { eventBus = new EventBus(); internalConsumers = new List <IInternalConsumer>(); createConsumerCalled = 0; mockBuilder = new MockBuilder(); queue = new Queue(queueName, false); onMessage = (body, properties, info) => Task.Factory.StartNew(() => { }); persistentConnection = MockRepository.GenerateStub <IPersistentConnection>(); internalConsumerFactory = MockRepository.GenerateStub <IInternalConsumerFactory>(); internalConsumerFactory.Stub(x => x.CreateConsumer()).WhenCalled(x => { var internalConsumer = MockRepository.GenerateStub <IInternalConsumer>(); internalConsumers.Add(internalConsumer); createConsumerCalled++; x.ReturnValue = internalConsumer; }).Repeat.Any(); consumer = new PersistentConsumer( queue, onMessage, persistentConnection, internalConsumerFactory, eventBus); AdditionalSetup(); }
public ExclusiveConsumer( IQueue queue, Func <byte[], MessageProperties, MessageReceivedInfo, Task> onMessage, IPersistentConnection connection, IConsumerConfiguration configuration, IInternalConsumerFactory internalConsumerFactory, IEventBus eventBus ) { Preconditions.CheckNotNull(queue, "queue"); Preconditions.CheckNotNull(onMessage, "onMessage"); Preconditions.CheckNotNull(connection, "connection"); Preconditions.CheckNotNull(internalConsumerFactory, "internalConsumerFactory"); Preconditions.CheckNotNull(eventBus, "eventBus"); Preconditions.CheckNotNull(configuration, "configuration"); this.queue = queue; this.onMessage = onMessage; this.connection = connection; this.configuration = configuration; this.internalConsumerFactory = internalConsumerFactory; this.eventBus = eventBus; timer = new Timer(s => { StartConsumer(); ((Timer)s).Change(10000, -1); }); timer.Change(10000, -1); }
public void SetUp() { eventBus = new EventBus(); internalConsumers = new List<IInternalConsumer>(); createConsumerCalled = 0; mockBuilder = new MockBuilder(); queue = new Queue(queueName, false); onMessage = (body, properties, info) => Task.Factory.StartNew(() => { }); persistentConnection = MockRepository.GenerateStub<IPersistentConnection>(); internalConsumerFactory = MockRepository.GenerateStub<IInternalConsumerFactory>(); internalConsumerFactory.Stub(x => x.CreateConsumer()).WhenCalled(x => { var internalConsumer = MockRepository.GenerateStub<IInternalConsumer>(); internalConsumers.Add(internalConsumer); createConsumerCalled++; x.ReturnValue = internalConsumer; }).Repeat.Any(); consumer = new PersistentConsumer( queue, onMessage, persistentConnection, internalConsumerFactory, eventBus); AdditionalSetup(); }
public ExclusiveConsumer( IQueue queue, Func<byte[], MessageProperties, MessageReceivedInfo, Task> onMessage, IPersistentConnection connection, IConsumerConfiguration configuration, IInternalConsumerFactory internalConsumerFactory, IEventBus eventBus ) { Preconditions.CheckNotNull(queue, "queue"); Preconditions.CheckNotNull(onMessage, "onMessage"); Preconditions.CheckNotNull(connection, "connection"); Preconditions.CheckNotNull(internalConsumerFactory, "internalConsumerFactory"); Preconditions.CheckNotNull(eventBus, "eventBus"); Preconditions.CheckNotNull(configuration, "configuration"); this.queue = queue; this.onMessage = onMessage; this.connection = connection; this.configuration = configuration; this.internalConsumerFactory = internalConsumerFactory; this.eventBus = eventBus; timer = new Timer(s => { StartConsumer(); ((Timer)s).Change(10000, -1); }); timer.Change(10000, -1); }
public ConsumerFactory(IInternalConsumerFactory internalConsumerFactory, IEventBus eventBus) { this.internalConsumerFactory = internalConsumerFactory; this.eventBus = eventBus; consumers = new ConcurrentDictionary <IConsumer, object>(); eventBus.Subscribe <StoppedConsumingEvent>(stoppedConsumingEvent => { object value; consumers.TryRemove(stoppedConsumingEvent.Consumer, out value); }); }
public ConsumerFactory(IInternalConsumerFactory internalConsumerFactory, IEventBus eventBus) { Preconditions.CheckNotNull(internalConsumerFactory, "internalConsumerFactory"); this.internalConsumerFactory = internalConsumerFactory; this.eventBus = eventBus; eventBus.Subscribe<StoppedConsumingEvent>(stoppedConsumingEvent => { object value; consumers.TryRemove(stoppedConsumingEvent.Consumer, out value); }); }
public ConsumerFactory(IInternalConsumerFactory internalConsumerFactory, IEventBus eventBus) { Preconditions.CheckNotNull(internalConsumerFactory, "internalConsumerFactory"); this.internalConsumerFactory = internalConsumerFactory; this.eventBus = eventBus; eventBus.Subscribe <StoppedConsumingEvent>(stoppedConsumingEvent => { object value; consumers.TryRemove(stoppedConsumingEvent.Consumer, out value); }); }
public ConsumerFactory(IInternalConsumerFactory internalConsumerFactory, IEventBus eventBus) { Preconditions.CheckNotNull(internalConsumerFactory, "internalConsumerFactory"); Preconditions.CheckNotNull(eventBus, "eventBus"); this.internalConsumerFactory = internalConsumerFactory; this.eventBus = eventBus; eventBus.Subscribe <StoppedConsumingEvent>(e => { object value; consumers.TryRemove(e.Consumer, out value); Console.WriteLine("StoppedConsumingEvent Subscribe : " + e.Consumer.ToString()); }); }
public TransientConsumer( IQueue queue, Func <byte[], MessageProperties, MessageReceivedInfo, Task> onMessage, IPersistentConnection connection, IConsumerConfiguration configuration, IInternalConsumerFactory internalConsumerFactory, IEventBus eventBus) { this.queue = queue; this.onMessage = onMessage; this.connection = connection; this.configuration = configuration; this.internalConsumerFactory = internalConsumerFactory; this.eventBus = eventBus; }
/// <summary> /// Creates ConsumerFactory /// </summary> /// <param name="connection">The connection</param> /// <param name="internalConsumerFactory">The internal consumer factory</param> /// <param name="eventBus">The event bus</param> public ConsumerFactory( IPersistentConnection connection, IInternalConsumerFactory internalConsumerFactory, IEventBus eventBus ) { Preconditions.CheckNotNull(internalConsumerFactory, "internalConsumerFactory"); Preconditions.CheckNotNull(eventBus, "eventBus"); this.connection = connection; this.internalConsumerFactory = internalConsumerFactory; this.eventBus = eventBus; eventBus.Subscribe <StoppedConsumingEvent>(@event => consumers.Remove(@event.Consumer)); }
public TransientConsumer( IQueue queue, Func <byte[], MessageProperties, MessageReceivedInfo, Task> onMessage, IPersistentConnection connection, IInternalConsumerFactory internalConsumerFactory) { Preconditions.CheckNotNull(queue, "queue"); Preconditions.CheckNotNull(onMessage, "onMessage"); Preconditions.CheckNotNull(connection, "connection"); Preconditions.CheckNotNull(internalConsumerFactory, "internalConsumerFactory"); this.queue = queue; this.onMessage = onMessage; this.connection = connection; this.internalConsumerFactory = internalConsumerFactory; }
public PersistentConsumer( IQueue queue, Func<byte[], MessageProperties, MessageReceivedInfo, Task> onMessage, IPersistentConnection connection, IInternalConsumerFactory internalConsumerFactory) { Preconditions.CheckNotNull(queue, "queue"); Preconditions.CheckNotNull(onMessage, "onMessage"); Preconditions.CheckNotNull(connection, "connection"); Preconditions.CheckNotNull(internalConsumerFactory, "internalConsumerFactory"); this.queue = queue; this.onMessage = onMessage; this.connection = connection; this.internalConsumerFactory = internalConsumerFactory; }
public PersistentMultipleConsumer( ICollection <Tuple <IQueue, Func <byte[], MessageProperties, MessageReceivedInfo, Task> > > queueConsumerPairs, IPersistentConnection connection, IConsumerConfiguration configuration, IInternalConsumerFactory internalConsumerFactory, IEventBus eventBus) { Preconditions.CheckNotNull(queueConsumerPairs, nameof(queueConsumerPairs)); Preconditions.CheckNotNull(connection, nameof(connection)); Preconditions.CheckNotNull(internalConsumerFactory, nameof(internalConsumerFactory)); Preconditions.CheckNotNull(eventBus, nameof(eventBus)); Preconditions.CheckNotNull(configuration, nameof(configuration)); this.queueConsumerPairs = queueConsumerPairs; this.connection = connection; this.configuration = configuration; this.internalConsumerFactory = internalConsumerFactory; this.eventBus = eventBus; }
public PersistentMultipleConsumer( IReadOnlyCollection <Tuple <IQueue, MessageHandler> > queueConsumerPairs, IPersistentConnection connection, ConsumerConfiguration configuration, IInternalConsumerFactory internalConsumerFactory, IEventBus eventBus ) { Preconditions.CheckNotNull(queueConsumerPairs, nameof(queueConsumerPairs)); Preconditions.CheckNotNull(connection, nameof(connection)); Preconditions.CheckNotNull(internalConsumerFactory, nameof(internalConsumerFactory)); Preconditions.CheckNotNull(eventBus, nameof(eventBus)); Preconditions.CheckNotNull(configuration, nameof(configuration)); this.queueConsumerPairs = queueConsumerPairs; this.connection = connection; this.configuration = configuration; this.internalConsumerFactory = internalConsumerFactory; this.eventBus = eventBus; }
public PersistentConsumer( IQueue queue, MessageHandler onMessage, ConsumerConfiguration configuration, IInternalConsumerFactory internalConsumerFactory, IEventBus eventBus ) { Preconditions.CheckNotNull(queue, "queue"); Preconditions.CheckNotNull(onMessage, "onMessage"); Preconditions.CheckNotNull(internalConsumerFactory, "internalConsumerFactory"); Preconditions.CheckNotNull(eventBus, "eventBus"); Preconditions.CheckNotNull(configuration, "configuration"); this.queue = queue; this.onMessage = onMessage; this.configuration = configuration; this.internalConsumerFactory = internalConsumerFactory; this.eventBus = eventBus; }
public PersistentConsumer( IQueue queue, Func <byte[], MessageProperties, MessageReceivedInfo, Task> onMessage, IPersistentConnection connection, IConsumerConfiguration configuration, IInternalConsumerFactory internalConsumerFactory, IEventBus eventBus) { Preconditions.CheckNotNull(queue, "queue"); Preconditions.CheckNotNull(onMessage, "onMessage"); Preconditions.CheckNotNull(connection, "connection"); Preconditions.CheckNotNull(internalConsumerFactory, "internalConsumerFactory"); Preconditions.CheckNotNull(eventBus, "eventBus"); Preconditions.CheckNotNull(configuration, "configuration"); this.queue = queue; this.onMessage = onMessage; this.connection = connection; this.configuration = configuration; this.internalConsumerFactory = internalConsumerFactory; this.eventBus = eventBus; }
public TransientConsumer( IQueue queue, Func<byte[], MessageProperties, MessageReceivedInfo, Task> onMessage, IPersistentConnection connection, IConsumerConfiguration configuration, IInternalConsumerFactory internalConsumerFactory, IEventBus eventBus) { Preconditions.CheckNotNull(queue, "queue"); Preconditions.CheckNotNull(onMessage, "onMessage"); Preconditions.CheckNotNull(connection, "connection"); Preconditions.CheckNotNull(internalConsumerFactory, "internalConsumerFactory"); Preconditions.CheckNotNull(eventBus, "eventBus"); Preconditions.CheckNotNull(configuration, "configuration"); this.queue = queue; this.onMessage = onMessage; this.connection = connection; this.configuration = configuration; this.internalConsumerFactory = internalConsumerFactory; this.eventBus = eventBus; }
public ConsumerFactory(IInternalConsumerFactory internalConsumerFactory) { Preconditions.CheckNotNull(internalConsumerFactory, "internalConsumerFactory"); this.internalConsumerFactory = internalConsumerFactory; }