public ITransport Create(string inputQueueAddress) { var transport = new InMemTransport(_network, inputQueueAddress); transport.Initialize(); return(transport); }
public async Task VeryBasicTransactionThing() { const string destinationQueueName = "another-queue"; var network = new InMemNetwork(); network.CreateQueue(destinationQueueName); var transport = new InMemTransport(network, "test-queue"); transport.Initialize(); using (var scope = new RebusTransactionScope()) { var headers = new Dictionary <string, string> { { Headers.MessageId, Guid.NewGuid().ToString() } }; await transport.Send( destinationAddress : destinationQueueName, message : new TransportMessage(headers, new byte[] { 1, 2, 3 }), context : scope.TransactionContext ); Assert.That(network.Count(destinationQueueName), Is.EqualTo(0), $"Expected ZERO messages in queue '{destinationQueueName}' at this point, because the scope was not completed"); await scope.CompleteAsync(); } Assert.That(network.Count(destinationQueueName), Is.EqualTo(1), $"Expected 1 message in queue '{destinationQueueName}' at this point, because the scope is completed now"); }
public TransportAndInspector Create(string address) { _network.CreateQueue(address); var transport = new InMemTransport(_network, address); return(new TransportAndInspector(transport, transport)); }
public void TestInmemTransportImpl() { var t = new InMemTransport("test"); Assert.True(t is ITransport); Assert.True(t is ILoopbackTransport); Assert.True(t is IWithPeers); }
protected override void SetUp() { _network.Reset(); _simpleRetryStrategySettings = new SimpleRetryStrategySettings(); _transport = new InMemTransport(_network, "whatever"); _handler = new PoisonQueueErrorHandler(_simpleRetryStrategySettings, _transport, new ConsoleLoggerFactory(false)); _handler.Initialize(); }
public static IServiceCollection WithDefaultPipeline( this IServiceCollection services, string queueName = "defaultQueue" ) { // handler activator services.AddSingleton <IHandlerActivator>(provider => new DependencyInjectionHandlerActivator(provider)); // settings, error tracker + handler, logging, serializer services.TryAddSingleton <SimpleRetryStrategySettings>(new SimpleRetryStrategySettings { MaxDeliveryAttempts = 2, SecondLevelRetriesEnabled = true }); services.AddSingleton <IErrorHandler, FakeErrorHandler>(); services.AddSingleton <IErrorTracker, FakeErrorTracker>(); services.AddSingleton <IRebusLoggerFactory, NullLoggerFactory>(); services.AddSingleton <ISerializer, JsonSerializer>(); // in-memory transport var transport = new InMemTransport(new InMemNetwork(true), queueName); services.AddSingleton <ITransport>(transport); // steps services.AddSingleton <IRetryStrategyStep, SimpleRetryStrategyStep>(); // pipeline IPipeline PipelineFactory(IServiceProvider provider) { var pipeline = new DefaultPipeline() .OnReceive(provider.GetRequiredService <IRetryStrategyStep>()) .OnReceive(new DeserializeIncomingMessageStep(provider.GetRequiredService <ISerializer>())) .OnReceive(new ActivateHandlersStep(provider.GetRequiredService <IHandlerActivator>())) .OnReceive(new DispatchIncomingMessageStep(provider.GetRequiredService <IRebusLoggerFactory>())) .OnSend(new AssignDefaultHeadersStep(provider.GetRequiredService <ITransport>())) .OnSend(new AutoHeadersOutgoingStep()) .OnSend(new SerializeOutgoingMessageStep(provider.GetRequiredService <ISerializer>())) .OnSend(new SendOutgoingMessageStep(provider.GetRequiredService <ITransport>(), provider.GetRequiredService <IRebusLoggerFactory>())); return(pipeline); } services.AddSingleton <IPipeline>(PipelineFactory); // invoker services.AddSingleton <IPipelineInvoker>(provider => new DefaultPipelineInvoker(provider.GetRequiredService <IPipeline>())); return(services); }