• 设为首页
  • 点击收藏
  • 手机版
    手机扫一扫访问
    迪恩网络手机版
  • 关注官方公众号
    微信扫一扫关注
    公众号

C# PingMessage类代码示例

原作者: [db:作者] 来自: [db:来源] 收藏 邀请

本文整理汇总了C#中PingMessage的典型用法代码示例。如果您正苦于以下问题:C# PingMessage类的具体用法?C# PingMessage怎么用?C# PingMessage使用的例子?那么恭喜您, 这里精选的类代码示例或许可以为您提供帮助。



PingMessage类属于命名空间,在下文中一共展示了PingMessage类的20个代码示例,这些例子默认根据受欢迎程度排序。您可以为喜欢或者感觉有用的代码点赞,您的评价将有助于我们的系统推荐出更棒的C#代码示例。

示例1: EstablishContext

		protected override void EstablishContext()
		{
			base.EstablishContext();

			_ping = new PingMessage();
			_future = new FutureMessage<PingMessage, Guid>(_ping.CorrelationId);

			_unsubscribe = RemoteBus.SubscribeHandler<PingMessage>(message => { _future.Set(message); });


			RemoteBus.ShouldHaveRemoteSubscriptionFor<PingMessage>();

			//LocalBus.ShouldHaveRemoteSubscriptionFor<PingMessage>();

			Trace.WriteLine("LocalBus");

			LocalBus.OutboundPipeline.Trace();

			Trace.WriteLine("RemoteBus");

			RemoteBus.OutboundPipeline.Trace();


			LocalBus.Publish(_ping);
		}
开发者ID:LucidSage,项目名称:MassTransit,代码行数:25,代码来源:Group_distributor_with_control_bus_should_work.cs


示例2: 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);

			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);
				});

			LocalBus.Publish(ping);

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

			consumer.ShouldHaveReceivedMessage(pong.Message, 8.Seconds());
			otherConsumer.ShouldHaveReceivedMessage(pong.Message, 8.Seconds());
		}
开发者ID:jimitndiaye,项目名称:MassTransit,代码行数:26,代码来源:MessageContext_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()
        {
            var ping = new PingMessage();

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

            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<PongMessage>();
            LocalBus.ShouldHaveRemoteSubscriptionFor<PingMessage>();

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

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

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


示例4: A_response_should_be_published_if_no_reply_address_is_specified

		public void A_response_should_be_published_if_no_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);

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

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


示例5: 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


示例6: VerifyMessageHeaderIsPassed

		private void VerifyMessageHeaderIsPassed(Action<IOutboundMessage> setHeaderAction, Action<IInboundMessageHeaders> checkHeaderAction)
		{
			byte[] data;
			var serializer = new XmlMessageSerializer();

			OutboundMessage.Set(setHeaderAction);

			var message = new PingMessage();

			using (MemoryStream output = new MemoryStream())
			{
				serializer.Serialize(output, message);

				data = output.ToArray();
			}

			Trace.WriteLine(OutboundMessage.Headers.MessageType);

			Trace.WriteLine(Encoding.UTF8.GetString(data));

			using (MemoryStream input = new MemoryStream(data))
			{
				serializer.Deserialize(input);

				checkHeaderAction(CurrentMessage.Headers);
			}
		}
开发者ID:KevM,项目名称:MassTransit,代码行数:27,代码来源:Header_Specs.cs


示例7: Should_ignore_a_response_that_was_not_for_us

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

            LocalBus.SubscribeHandler<PongMessage>(pongReceived.Set);

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

            var ping = new PingMessage();

            TimeSpan timeout = 8.Seconds();

            Assert.Throws<RequestTimeoutException>(() =>
                {
                    RemoteBus.Endpoint.SendRequest(ping, LocalBus, x =>
                        {
                            x.Handle<PongMessage>(badResponse.Set);

                            x.SetTimeout(timeout);
                        });
                });

            pingReceived.IsAvailable(timeout).ShouldBeTrue("The ping was not received");
            pongReceived.IsAvailable(timeout).ShouldBeTrue("The pong was not received");
            badResponse.IsAvailable(2.Seconds()).ShouldBeFalse("Should not have received a response");
        }
开发者ID:andreialecu,项目名称:MassTransit,代码行数:33,代码来源:PublishRequest_Specs.cs


示例8: Should_be_received_properly

        public async Task Should_be_received_properly()
        {
            object message = new PingMessage();
            await Bus.Publish(message);

            await _received;
        }
开发者ID:MassTransit,项目名称:MassTransit,代码行数:7,代码来源:PublishSubscribe_Specs.cs


示例9: 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


示例10: 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


示例11: 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


示例12: The_pipeline_should_have_insertable_items

		public void The_pipeline_should_have_insertable_items()
		{
			// two consumers, one for each type of message

			IndiscriminantConsumer<PingMessage> pingConsumer = new IndiscriminantConsumer<PingMessage>();
			IndiscriminantConsumer<PongMessage> pongConsumer = new IndiscriminantConsumer<PongMessage>();

			UnsubscribeAction pingToken = _pipeline.Subscribe(pingConsumer);
			UnsubscribeAction pongToken = _pipeline.Subscribe(pongConsumer);

			PipelineViewer.Trace(_pipeline);

			PingMessage pingMessage = new PingMessage();
			PongMessage pongMessage = new PongMessage();

			_pipeline.Dispatch(pingMessage, accept => true);
			_pipeline.Dispatch(pongMessage, accept => true);

			Assert.AreEqual(pingMessage, pingConsumer.Consumed);
			Assert.AreEqual(pongMessage, pongConsumer.Consumed);

			pingToken();
			pongToken();

			PipelineViewer.Trace(_pipeline);
		}
开发者ID:KevM,项目名称:MassTransit,代码行数:26,代码来源:PipelineDispatcher_Specs.cs


示例13: Should_end_well

        public async Task Should_end_well()
        {
            var timer = Stopwatch.StartNew();

            Task[] publishers = new Task[100*1000];
            Parallel.For(0, 100, i =>
            {
                var offset = i * 1000;

                for (int j = 0; j < 1000; j++)
                {
                    var ping = new PingMessage();
                    var task = Bus.Publish(ping);
                    publishers[offset + j] = task;
                }
            });

            var published = timer.Elapsed;

            await Task.WhenAll(publishers);

            var confirmed = timer.Elapsed;

            Console.WriteLine("Published {0} messages in {1}ms ({2:F0}/s)", 100 * 1000, published.TotalMilliseconds, 100L * 1000L * 1000L / published.TotalMilliseconds);

            Console.WriteLine("Confirmed {0} messages in {1}ms ({2:F0}/s)", 100 * 1000, confirmed.TotalMilliseconds, 100L * 1000L * 1000L / confirmed.TotalMilliseconds);

            await _completed.Task;

            var completed = timer.Elapsed;

            Console.WriteLine("Completed {0} messages in {1}ms ({2:F0}/s)", 100 * 1000, completed.TotalMilliseconds, 100L * 1000L * 1000L / completed.TotalMilliseconds);
        }
开发者ID:kotvisbj,项目名称:MassTransit,代码行数:33,代码来源:HammerTime_Specs.cs


示例14: Setup

 public async Task Setup()
 {
     var message = new PingMessage();
     await InputQueueSendEndpoint.Send(message, context =>
     {
         context.SetSessionId(message.CorrelationId.ToString());
     });
 }
开发者ID:phatboyg,项目名称:MassTransit,代码行数:8,代码来源:Session_Specs.cs


示例15: It_should_be_received_by_a_component

		public void It_should_be_received_by_a_component()
		{
			RemoteBus.SubscribeConsumer<TestMessageConsumer<PingMessage>>();

			PingMessage message = new PingMessage();
			LocalBus.Publish(message);

			TestConsumerBase<PingMessage>.AnyShouldHaveReceivedMessage(message, _timeout);
		}
开发者ID:codeyu,项目名称:MassTransit,代码行数:9,代码来源:PublishToConsumer_Specs.cs


示例16: Setup

 public async Task Setup()
 {
     _pingMessage = new PingMessage();
     _pingMessage2 = new PingMessage();
     await InputQueueSendEndpoint.Send(_pingMessage, Pipe.Execute<SendContext<PingMessage>>(context =>
     {
         context.CorrelationId = _correlationId;
     }));
 }
开发者ID:phatboyg,项目名称:MassTransit,代码行数:9,代码来源:PublishFaultChannel_Specs.cs


示例17: A_simple_bus_should_be_able_to_subscribe_and_publish

		public void A_simple_bus_should_be_able_to_subscribe_and_publish()
		{
			TestMessageConsumer<PingMessage> consumer = new TestMessageConsumer<PingMessage>();
			LocalBus.Subscribe(consumer);

			PingMessage message = new PingMessage();
			LocalBus.Publish(message);

			consumer.ShouldHaveReceivedMessage(message, 500.Milliseconds());
		}
开发者ID:KevM,项目名称:MassTransit,代码行数:10,代码来源:PublishSubscribe_Specs.cs


示例18: Should_include_a_correlation_id

        public async Task Should_include_a_correlation_id()
        {
            var pingMessage = new PingMessage();
            await Bus.Publish(pingMessage);

            var context = await _handled;

            context.CorrelationId.HasValue.ShouldBe(true);
            context.CorrelationId.Value.ShouldBe(pingMessage.CorrelationId);
        }
开发者ID:nicklv,项目名称:MassTransit,代码行数:10,代码来源:CorrelationId_Specs.cs


示例19: A_simple_bus_should_be_able_to_subscribe_and_publish

        public void A_simple_bus_should_be_able_to_subscribe_and_publish()
        {
            var consumer = new TestMessageConsumer<PingMessage>();
            LocalBus.SubscribeInstance(consumer);

            var message = new PingMessage();
            LocalBus.Publish(message);

            consumer.ShouldHaveReceivedMessage(message, 8.Seconds());
        }
开发者ID:rajwilkhu,项目名称:MassTransit,代码行数:10,代码来源:PublishSubscribe_Specs.cs


示例20: It_should_be_received_by_one_subscribed_consumer

		public void It_should_be_received_by_one_subscribed_consumer()
		{
			TestMessageConsumer<PingMessage> consumer = new TestMessageConsumer<PingMessage>();
			RemoteBus.SubscribeInstance(consumer);

			PingMessage message = new PingMessage();
			LocalBus.Publish(message);

			consumer.ShouldHaveReceivedMessage(message, _timeout);
		}
开发者ID:codeyu,项目名称:MassTransit,代码行数:10,代码来源:PublishToConsumer_Specs.cs



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


鲜花

握手

雷人

路过

鸡蛋
该文章已有0人参与评论

请发表评论

全部评论

专题导读
上一篇:
C# Pipe类代码示例发布时间:2022-05-24
下一篇:
C# Ping类代码示例发布时间:2022-05-24
热门推荐
阅读排行榜

扫描微信二维码

查看手机版网站

随时了解更新最新资讯

139-2527-9053

在线客服(服务时间 9:00~18:00)

在线QQ客服
地址:深圳市南山区西丽大学城创智工业园
电邮:jeky_zhao#qq.com
移动电话:139-2527-9053

Powered by 互联科技 X3.4© 2001-2213 极客世界.|Sitemap