当前位置: 首页>>代码示例>>C#>>正文


C# FutureMessage.IsAvailable方法代码示例

本文整理汇总了C#中FutureMessage.IsAvailable方法的典型用法代码示例。如果您正苦于以下问题:C# FutureMessage.IsAvailable方法的具体用法?C# FutureMessage.IsAvailable怎么用?C# FutureMessage.IsAvailable使用的例子?那么, 这里精选的方法代码示例或许可以为您提供帮助。您也可以进一步了解该方法所在FutureMessage的用法示例。


在下文中一共展示了FutureMessage.IsAvailable方法的15个代码示例,这些例子默认根据受欢迎程度排序。您可以为喜欢或者感觉有用的代码点赞,您的评价将有助于系统推荐出更棒的C#代码示例。

示例1: Should_support_send_as_well

        public void Should_support_send_as_well()
        {
            var pongReceived = new FutureMessage<PongMessage>();
            var pingReceived = new FutureMessage<PingMessage>();

            RemoteBus.SubscribeContextHandler<PingMessage>(x =>
                {
                    pingReceived.Set(x.Message);
                    x.Respond(new PongMessage {TransactionId = x.Message.TransactionId});
                });
            LocalBus.ShouldHaveSubscriptionFor<PingMessage>();

            var ping = new PingMessage();

            TimeSpan timeout = 8.Seconds();

            RemoteBus.Endpoint.SendRequest(ping, LocalBus, x =>
                {
                    x.Handle<PongMessage>(message =>
                        {
                            message.TransactionId.ShouldEqual(ping.TransactionId,
                                "The response correlationId did not match");
                            pongReceived.Set(message);
                        });

                    x.SetTimeout(timeout);
                });

            pingReceived.IsAvailable(timeout).ShouldBeTrue("The ping was not received");
            pongReceived.IsAvailable(timeout).ShouldBeTrue("The pong was not received");
        }
开发者ID:andreialecu,项目名称:MassTransit,代码行数:31,代码来源:PublishRequest_Specs.cs

示例2: A_consumer_is_being_tested

		public void A_consumer_is_being_tested()
		{
			_test = TestFactory.ForHandler<InputMessage>()
				.New(x =>
					{
						x.Handler((bus,message) =>
							{
								bus.MessageContext<InputMessage>().Respond(new OutputMessage());
							});

					x.Send(new InputMessage(), c => c.SendResponseTo(_test.Scenario.Bus));
					x.Send(new InputMessage(), c => c.SendResponseTo(_test.Scenario.Bus));
				});

			_test.Execute();

			_test.Received.Any<InputMessage>().ShouldBeTrue();
			_test.Sent.Any<OutputMessage>().ShouldBeTrue();

			_future = new FutureMessage<ReceivedMessageTraceList>();
			_test.Scenario.Bus.GetMessageTrace(_test.Scenario.Bus.ControlBus.Endpoint, _future.Set);

			_future.IsAvailable(8.Seconds()).ShouldBeTrue();
			_list = _future.Message;
		}
开发者ID:jimitndiaye,项目名称:MassTransit,代码行数:25,代码来源:Trace_Specs.cs

示例3: A_response_should_be_sent_directly_if_a_reply_address_is_specified

		public void A_response_should_be_sent_directly_if_a_reply_address_is_specified()
		{
			PingMessage ping = new PingMessage();

			TestMessageConsumer<PongMessage> otherConsumer = new TestMessageConsumer<PongMessage>();
			RemoteBus.Subscribe(otherConsumer);

			TestCorrelatedConsumer<PongMessage, Guid> consumer = new TestCorrelatedConsumer<PongMessage, Guid>(ping.CorrelationId);
			LocalBus.Subscribe(consumer);

			FutureMessage<PongMessage> pong = new FutureMessage<PongMessage>();

			RemoteBus.Subscribe<PingMessage>(message =>
				{
					pong.Set(new PongMessage(message.CorrelationId));

					CurrentMessage.Respond(pong.Message);
				});

			LocalBus.Publish(ping, context => context.SendResponseTo(LocalBus));

			Assert.IsTrue(pong.IsAvailable(3.Seconds()), "No pong generated");

			consumer.ShouldHaveReceivedMessage(pong.Message, 3.Seconds());
			otherConsumer.ShouldNotHaveReceivedMessage(pong.Message, 1.Seconds());
		}
开发者ID:hakeemsm,项目名称:MassTransit,代码行数:26,代码来源:MessageContext_Specs.cs

示例4: The_retry_count_should_be_set_on_the_message

		public void The_retry_count_should_be_set_on_the_message()
		{
			var future = new FutureMessage<PingMessage>();

			bool first = true;

			LocalBus.SubscribeHandler<PingMessage>(message =>
				{
					if (first)
					{
						Assert.AreEqual(0, LocalBus.Context().RetryCount);

						LocalBus.MessageContext<PingMessage>().RetryLater();

						first = false;
					}
					else
					{
						Assert.AreEqual(1, LocalBus.Context().RetryCount);

						future.Set(message);
					}
				});

			LocalBus.ShouldHaveRemoteSubscriptionFor<PingMessage>();

			LocalBus.Publish(new PingMessage());

			Assert.IsTrue(future.IsAvailable(20.Seconds()));
		}
开发者ID:cstick,项目名称:MassTransit,代码行数:30,代码来源:Retry_Specs.cs

示例5: The_retry_count_should_be_set_on_the_message

		public void The_retry_count_should_be_set_on_the_message()
		{
			FutureMessage<PingMessage> future = new FutureMessage<PingMessage>();

			bool first = true;

			LocalBus.Subscribe<PingMessage>(message =>
				{
					if(first)
					{
						Assert.AreEqual(0, CurrentMessage.Headers.RetryCount);

						CurrentMessage.RetryLater();

						first = false;
					}
					else
					{
						Assert.AreEqual(1, CurrentMessage.Headers.RetryCount);

						future.Set(message);
					}
				});

			LocalBus.Publish(new PingMessage());

			Assert.IsTrue(future.IsAvailable(5.Seconds()));
		}
开发者ID:KevM,项目名称:MassTransit,代码行数:28,代码来源:Retry_Specs.cs

示例6: A_clean_method_of_a_request_reply_should_be_possible

		public void A_clean_method_of_a_request_reply_should_be_possible()
		{
			var ponged = new FutureMessage<PongMessage>();

			RemoteBus.SubscribeHandler<PingMessage>(x =>
				{
					// timing issue here it seems, but that's what Respond() is for, to RESPOND to messages
					// and not publish responses
					RemoteBus.ShouldHaveSubscriptionFor<PongMessage>();

					RemoteBus.Publish(new PongMessage(x.CorrelationId));
				});

			LocalBus.ShouldHaveSubscriptionFor<PingMessage>();

			var ping = new PingMessage();


			LocalBus.PublishRequest(ping, x =>
				{
					x.Handle<PongMessage>(message =>
						{
							message.CorrelationId.ShouldEqual(ping.CorrelationId);
							ponged.Set(message);
						});

					x.HandleTimeout(8.Seconds(), () => { });
				});

			ponged.IsAvailable(8.Seconds()).ShouldBeTrue("No ping response received");
		}
开发者ID:ahjohannessen,项目名称:MassTransit,代码行数:31,代码来源:RequestResponseScope_Specs.cs

示例7: A_response_should_be_published_if_no_reply_address_is_specified

        public void A_response_should_be_published_if_no_reply_address_is_specified()
        {
            var ping = new PingMessage();

            var otherConsumer = new TestMessageConsumer<PongMessage>();
            RemoteBus.SubscribeInstance(otherConsumer);

            LocalBus.ShouldHaveRemoteSubscriptionFor<PongMessage>();
            
            var consumer = new TestCorrelatedConsumer<PongMessage, Guid>(ping.CorrelationId);
            LocalBus.SubscribeInstance(consumer);

            var pong = new FutureMessage<PongMessage>();

            RemoteBus.SubscribeHandler<PingMessage>(message =>
                {
                    pong.Set(new PongMessage(message.CorrelationId));

                    RemoteBus.Context().Respond(pong.Message);
                });

            RemoteBus.ShouldHaveRemoteSubscriptionFor<PongMessage>();
            LocalBus.ShouldHaveRemoteSubscriptionFor<PingMessage>();

            LocalBus.Publish(ping);

            pong.IsAvailable(8.Seconds()).ShouldBeTrue("No pong generated");

            consumer.ShouldHaveReceivedMessage(pong.Message, 8.Seconds());
            otherConsumer.ShouldHaveReceivedMessage(pong.Message, 8.Seconds());
        }
开发者ID:cstick,项目名称:MassTransit,代码行数:31,代码来源:MessageContext_Specs.cs

示例8: Should_support_the_asynchronous_programming_model

		public void Should_support_the_asynchronous_programming_model()
		{
			var pongReceived = new FutureMessage<PongMessage>();
			var pingReceived = new FutureMessage<PingMessage>();
			var callbackCalled = new FutureMessage<IAsyncResult>();

			RemoteBus.SubscribeHandler<PingMessage>(x =>
				{
					pingReceived.Set(x);
					RemoteBus.MessageContext<PingMessage>().Respond(new PongMessage(x.CorrelationId));
				});

			var ping = new PingMessage();

			var timeout = 8.Seconds();

			LocalBus.BeginPublishRequest(ping, callbackCalled.Set, null, x =>
				{
					x.Handle<PongMessage>(message =>
						{
							message.CorrelationId.ShouldEqual(ping.CorrelationId, "The response correlationId did not match");
							pongReceived.Set(message);
						});

					x.SetTimeout(timeout);
				});

			callbackCalled.IsAvailable(timeout).ShouldBeTrue("The callback was not called");

			LocalBus.EndRequest(callbackCalled.Message);

			pingReceived.IsAvailable(timeout).ShouldBeTrue("The ping was not received");
			pongReceived.IsAvailable(timeout).ShouldBeTrue("The pong was not received");
		}
开发者ID:jimitndiaye,项目名称:MassTransit,代码行数:34,代码来源:PublishRequest_Specs.cs

示例9: Should_use_a_clean_syntax_following_standard_conventions

		public void Should_use_a_clean_syntax_following_standard_conventions()
		{
			var pongReceived = new FutureMessage<PongMessage>();
			var pingReceived = new FutureMessage<PingMessage>();

			RemoteBus.SubscribeHandler<PingMessage>(x =>
				{
					pingReceived.Set(x);
					RemoteBus.MessageContext<PingMessage>().Respond(new PongMessage(x.CorrelationId));
				});

			var ping = new PingMessage();

			var timeout = 8.Seconds();

			LocalBus.PublishRequest(ping, x =>
				{
					x.Handle<PongMessage>(message =>
						{
							message.CorrelationId.ShouldEqual(ping.CorrelationId, "The response correlationId did not match");
							pongReceived.Set(message);
						});

					x.SetTimeout(timeout);
				});

			pingReceived.IsAvailable(timeout).ShouldBeTrue("The ping was not received");
			pongReceived.IsAvailable(timeout).ShouldBeTrue("The pong was not received");
		}
开发者ID:jimitndiaye,项目名称:MassTransit,代码行数:29,代码来源:PublishRequest_Specs.cs

示例10: MakeSagaDown

		private void MakeSagaDown()
		{
			MakeSagaSuspect();
			var fm = new FutureMessage<TimeoutExpired>();
			RemoteBus.Subscribe<TimeoutExpired>(fm.Set);
			Thread.Sleep(500);
			LocalBus.Publish(new TimeoutExpired {CorrelationId = _id, Tag = 2});
			fm.IsAvailable(1.Seconds()).ShouldBeTrue();

			var saga = Repository.Where(x => x.CorrelationId == _id).First();
			saga.CurrentState.ShouldEqual(HealthSaga.Down, "MakeSagaDown failed");
		}
开发者ID:vikasl,项目名称:MassTransit,代码行数:12,代码来源:HealthService_Specs.cs

示例11: Dynamic_should_receive_the_message

        public void Dynamic_should_receive_the_message()
        {
            var receivedDynamic = new FutureMessage<A>();

            UnsubscribeAction subscription = RemoteBus.SubscribeHandler<A>(receivedDynamic.Set);
            using (subscription.Disposable())
            {
                LocalBus.Publish(new A());

                receivedDynamic.IsAvailable(8.Seconds()).ShouldBeTrue("Dynamic not received");
                _receivedA.IsAvailable(8.Seconds()).ShouldBeTrue("Static not received");
            }
        }
开发者ID:cstick,项目名称:MassTransit,代码行数:13,代码来源:DynamicAndStaticSubscriptions_Specs.cs

示例12: Subscring_to_an_endpoint_should_accept_and_dispatch_messages

		public void Subscring_to_an_endpoint_should_accept_and_dispatch_messages()
		{
            FutureMessage<PingMessage> fm=new FutureMessage<PingMessage>();
			bool workDid = false;

			LocalBus.Subscribe<PingMessage>(
				(msg)=> {workDid = true; fm.Set(msg); },
				delegate { return true; });

			RemoteBus.Publish(_message);
		    fm.IsAvailable(1.Seconds());
			Assert.That(workDid, Is.True, "Lazy Test!");
		}
开发者ID:KevM,项目名称:MassTransit,代码行数:13,代码来源:MessageQueueEndpoint_MeetsCriteria.cs

示例13: MakeSagaSuspect

		public void MakeSagaSuspect()
		{
			LocalBus.Publish(new EndpointCameOnline(_id, LocalBus.ControlBus.Endpoint.Uri,LocalBus.Endpoint.Uri, 0));
			var fm = new FutureMessage<TimeoutExpired>();
			RemoteBus.Subscribe<TimeoutExpired>(fm.Set);
			Thread.Sleep(5000);
			LocalBus.Publish(new TimeoutExpired {CorrelationId = _id, Tag = 1});
			fm.IsAvailable(5.Seconds()).ShouldBeTrue();

			var saga = Repository.Where(x => x.CorrelationId == _id).FirstOrDefault();
			saga.ShouldNotBeNull();
			saga.CurrentState.ShouldEqual(HealthSaga.Suspect, "MakeSagaSuspect failed");
		}
开发者ID:vikasl,项目名称:MassTransit,代码行数:13,代码来源:HealthService_Specs.cs

示例14: Configuring_a_service_bus_easily

		public void Configuring_a_service_bus_easily()
		{
			FutureMessage<PingMessage> received;
			using (IServiceBus bus = ServiceBusFactory.New(x => { x.ReceiveFrom("loopback://localhost/queue"); }))
			{
				received = new FutureMessage<PingMessage>();

				bus.SubscribeHandler<PingMessage>(received.Set);

				bus.Publish(new PingMessage());
				received.IsAvailable(8.Seconds()).ShouldBeTrue();
			}
		}
开发者ID:cstick,项目名称:MassTransit,代码行数:13,代码来源:SimpleConfiguration_Specs.cs

示例15: Should_request_an_instance_of_the_consumer_for_each_message

		public void Should_request_an_instance_of_the_consumer_for_each_message()
		{
			var called = new FutureMessage<PingMessage>();

			var ping = new PingMessage();

			var getter = MockRepository.GenerateMock<HandlerSelector<PingMessage>>();
			getter.Expect(x => x(null)).IgnoreArguments().Return(x => called.Set(x.Message));

			LocalBus.SubscribeHandlerSelector(getter);

			LocalBus.Publish(ping);

			called.IsAvailable(3.Seconds()).ShouldBeTrue();
		}
开发者ID:cstick,项目名称:MassTransit,代码行数:15,代码来源:SubscribeConsumer_Specs.cs


注:本文中的FutureMessage.IsAvailable方法示例由纯净天空整理自Github/MSDocs等开源代码及文档管理平台,相关代码片段筛选自各路编程大神贡献的开源项目,源码版权归原作者所有,传播和使用请参考对应项目的License;未经允许,请勿转载。