public void a_rat_is_sent_to_a_hungry_cat()
        {
            rat_id       = CombGuid.Generate();
            received_rat = new Future <Rat>();
            cat          = new ConsumerOf <Rat>(a_large_rat_actually =>
            {
                Console.WriteLine("Miaooo!!!");
                Console.WriteLine(a_large_rat_actually.Sound + "!!!");
                Console.WriteLine("Cat: chase! ...");
                Console.WriteLine("*silence*");
                Console.WriteLine("Cat: *Crunch chrunch*");
                received_rat.Complete(a_large_rat_actually);
            });

            cat_nap_unsubscribes = RemoteBus.SubscribeInstance(cat);

            // we need to make sure this bus is up before sending to it
            RemoteBus.Endpoint.InboundTransport.Receive(ctx => c => { }, 4.Seconds());

            LocalBus.GetEndpoint(RemoteUri).Send <Rat>(new
            {
                Sound         = "Eeeek",
                CorrelationId = rat_id
            });
        }
Esempio n. 2
0
        public void Should_respond_properly()
        {
            bool result = LocalBus.GetEndpoint(LocalBus.Endpoint.Address.Uri)
                          .SendRequest <IPingMessage>(new Ping(), LocalBus, req =>
            {
                req.Handle <IPongMessage>(x => { });
                req.SetTimeout(10.Seconds());
            });

            result.ShouldBeTrue("No response was received.");
        }
Esempio n. 3
0
        public void Should_be_able_to_request_response()
        {
            var responseReceived = new ManualResetEvent(false);

            LocalBus.GetEndpoint(RemoteUri).SendRequest(new Request(), LocalBus, x =>
            {
                x.Handle <Response>((context, message) => responseReceived.Set());
                x.SetTimeout(8.Seconds());
            });

            Assert.IsTrue(responseReceived.WaitOne(8.Seconds()), "No Response");
        }
Esempio n. 4
0
 public void Should_timeout_for_unhandled_request()
 {
     Assert.Throws <RequestTimeoutException>(() =>
     {
         LocalBus.GetEndpoint(LocalBus.Endpoint.Address.Uri)
         .SendRequest <IPlinkMessage>(new PlinkMessage(), LocalBus, req =>
         {
             req.Handle <IPongMessage>(x => { });
             req.SetTimeout(8.Seconds());
         });
     });
 }
Esempio n. 5
0
        public void Should_be_able_to_read_xml_when_using_json()
        {
            Assert.IsTrue(RemoteBus.ShouldHaveSubscriptionFor <B>().Any());
            Assert.IsTrue(LocalBus.ShouldHaveSubscriptionFor <A>().Any());

            LocalBus.GetEndpoint(RemoteUri).Send(new A {
                Key = "Hello"
            });

            _requestReceived.WaitUntilCompleted(8.Seconds()).ShouldBeTrue();

            _responseReceived.WaitUntilCompleted(8.Seconds()).ShouldBeTrue();
        }
Esempio n. 6
0
        public void Should_respond_after_changing_qos()
        {
            LocalBus.SetPrefetchCount(197);

            bool result = LocalBus.GetEndpoint(LocalBus.Endpoint.Address.Uri)
                          .SendRequest <PingMessage>(new PingImpl(), LocalBus, req =>
            {
                req.Handle <PongMessage>(x => { });
                req.SetTimeout(10.Seconds());
            });

            result.ShouldBeTrue("No response was received.");
        }
        public void Should_put_message_in_error_queue()
        {
            LocalBus.Endpoint.Send(new BadMessage("Good"));

            IEndpoint errorEndpoint =
                LocalBus.GetEndpoint(LocalBus.Endpoint.InboundTransport.Address.Uri.AppendToPath("_error"));

            errorEndpoint.InboundTransport.ShouldContain(errorEndpoint.Serializer, typeof(BadMessage));

            LocalBus.Endpoint.ShouldNotContain <BadMessage>();

            var errorTransport = LocalBus.Endpoint.ErrorTransport as LoopbackTransport;

            errorTransport.ShouldNotBeNull();

            errorTransport.Count.ShouldEqual(1);
        }
Esempio n. 8
0
        public void ActivityTextFixtureSetup()
        {
            if (_endpointFactoryConfigurator != null)
            {
                ConfigurationResult result =
                    ConfigurationResultImpl.CompileResults(_endpointFactoryConfigurator.Validate());

                try
                {
                    EndpointFactory = _endpointFactoryConfigurator.CreateEndpointFactory();

                    _endpointCache = new EndpointCache(EndpointFactory);

                    EndpointCache = new EndpointCacheProxy(_endpointCache);
                }
                catch (Exception ex)
                {
                    throw new ConfigurationException(result, "An exception was thrown during endpoint cache creation",
                                                     ex);
                }
            }

            ServiceBusFactory.ConfigureDefaultSettings(x =>
            {
                x.SetEndpointCache(EndpointCache);
                x.SetConcurrentConsumerLimit(4);
                x.SetReceiveTimeout(50.Milliseconds());
                x.EnableAutoStart();
            });

            LocalUri = new Uri(BaseUri, "local");

            AddCommandContext <DispatchMessageConsumer, DispatchMessage>(() =>
            {
                var agent = new MessageDispatchAgent(LocalBus);

                return(new DispatchMessageConsumer(agent));
            });

            SetupCommands();

            LocalBus = CreateServiceBus(ConfigureLocalBus);

            DispatchEndpoint = LocalBus.GetEndpoint(GetActivityContext <DispatchMessage>().ExecuteUri);
        }
        public void Should_have_a_copy_of_the_error_in_the_error_queue()
        {
            _received.WaitUntilCompleted(8.Seconds());

            LocalBus.GetEndpoint(LocalErrorUri).ShouldContain(_message, 8.Seconds());
        }
Esempio n. 10
0
 public void Sending_command_in_another_format()
 {
     LocalBus.GetEndpoint(RemoteUri).Send(new A {
         Key = "Hello"
     });
 }
 public void Should_have_a_copy_of_the_error_in_the_error_queue()
 {
     _received.WaitUntilCompleted(Debugger.IsAttached ? 5.Minutes() : 8.Seconds());
     LocalBus.GetEndpoint(LocalErrorUri).ShouldContain(_message, Debugger.IsAttached ? 5.Minutes() : 8.Seconds());
 }