public async Task Should_fan_out_published_messages() { var endpointSettings = new EndpointSettings <IEndpointDefinition <EventConsumer> > { InstanceId = "27" }; var endpointDefinition = new ConsumerEndpointDefinition <EventConsumer>(endpointSettings); var firstHarness = new RabbitMqTestHarness(); var firstConsumer = new EventConsumer(firstHarness.GetTask <ConsumeContext <SomeEvent> >()); firstHarness.OnConfigureRabbitMqBus += configurator => { configurator.ReceiveEndpoint(endpointDefinition, KebabCaseEndpointNameFormatter.Instance, e => { e.Consumer(() => firstConsumer); }); }; await firstHarness.Start(); try { endpointSettings = new EndpointSettings <IEndpointDefinition <EventConsumer> > { InstanceId = "42" }; endpointDefinition = new ConsumerEndpointDefinition <EventConsumer>(endpointSettings); var secondHarness = new RabbitMqTestHarness(); var secondConsumer = new EventConsumer(secondHarness.GetTask <ConsumeContext <SomeEvent> >()); secondHarness.OnConfigureRabbitMqBus += configurator => { configurator.ReceiveEndpoint(endpointDefinition, KebabCaseEndpointNameFormatter.Instance, e => { e.Consumer(() => secondConsumer); }); }; await secondHarness.Start(); try { await firstHarness.Bus.Publish(new SomeEvent()); await firstConsumer.Completed; await secondConsumer.Completed; } finally { await secondHarness.Stop(); } } finally { await firstHarness.Stop(); } }
public void Should_format_instance_id_properly() { var endpointSettings = new EndpointSettings <IEndpointDefinition <SomeReallyCoolConsumer> > { InstanceId = "TopShelf" }; var endpointDefinition = new ConsumerEndpointDefinition <SomeReallyCoolConsumer>(endpointSettings); var name = endpointDefinition.GetEndpointName(KebabCaseEndpointNameFormatter.Instance); Assert.That(name, Is.EqualTo("some-really-cool-top-shelf")); }
public CustomerChangedConsumerDefinition() { EndpointDefinition = new ConsumerEndpointDefinition <CustomerChangedConsumer>( new EndpointSettings <IEndpointDefinition <CustomerChangedConsumer> > { Name = $"sbs-sample", IsTemporary = false, PrefetchCount = 1, ConcurrentMessageLimit = 1 }); this.ConcurrentMessageLimit = 1; }