public async Task CanMoveMessageToErrorQueueEvenThoughExceptionIsNotSerializable() { using (var activator = new BuiltinHandlerActivator()) { activator.Handle<string>(async str => { throw new ThisOneCannotBeSerialized("BAM!!!!!!!!!!!11111111111111111"); }); var network = new InMemNetwork(); var bus = Configure.With(activator) .Transport(t => t.UseInMemoryTransport(network, "unserializable exceptions")) .Options(o => o.SimpleRetryStrategy(maxDeliveryAttempts: 1)) .Start(); const string knownString = "JUST SOME LISP!!!!11((((((((((((((((((()))))))))))))))))))))))"; await bus.SendLocal(knownString); var failedMessage = await network.WaitForNextMessageFrom("error"); Assert.That(Encoding.UTF8.GetString(failedMessage.Body), Is.EqualTo(JsonConvert.SerializeObject(knownString))); } }
public async Task CanForwardToMultipleRecipients() { var network = new InMemNetwork(); var activator = new BuiltinHandlerActivator(); Using(activator); var recipients = new[] { "recipient-A", "recipient-B" }.ToList(); recipients.ForEach(network.CreateQueue); Configure.With(activator) .Transport(t => t.UseInMemoryTransport(network, "forwarder")) .Routing(t => { t.AddTransportMessageForwarder(async transportMessage => ForwardAction.ForwardTo(recipients)); }) .Start(); await activator.Bus.SendLocal("HEJ MED DIG!!!"); var transportMessages = await Task.WhenAll(recipients.Select(async queue => { var message = await network.WaitForNextMessageFrom(queue); return message; })); Assert.That(transportMessages.Length, Is.EqualTo(2)); }