public void Send_Receive_Message() { using (IBus bus = new RabbitMQBus()) { using (IChannelFactory<ITestContract> channelFactory = new MessageBus.Core.Proxy.ChannelFactory<ITestContract>(bus)) { ISubscriptionFactory<ITestContract> subscriptionFactory = new SubscriptionFactory<ITestContract>(bus, c => c.SetReceiveSelfPublish()); string actual = ""; ManualResetEvent ev = new ManualResetEvent(false); using (ISubscriptionSelector<ITestContract> selector = subscriptionFactory.Subscribe()) { selector.Subscribe<string>(contract => contract.Foo, s => { actual = s; ev.Set(); }); ITestContract channel = channelFactory.CreateChannel(); channel.Foo("boo"); ev.WaitOne(TimeSpan.FromSeconds(5)); actual.Should().Be("boo"); } } } }
public void Send_Receive_Message() { using (IBus bus = new RabbitMQBus()) { using (IChannelFactory <ITestContract> channelFactory = new MessageBus.Core.Proxy.ChannelFactory <ITestContract>(bus)) { ISubscriptionFactory <ITestContract> subscriptionFactory = new SubscriptionFactory <ITestContract>(bus, c => c.SetReceiveSelfPublish()); string actual = ""; ManualResetEvent ev = new ManualResetEvent(false); using (ISubscriptionSelector <ITestContract> selector = subscriptionFactory.Subscribe()) { selector.Subscribe <string>(contract => contract.Foo, s => { actual = s; ev.Set(); }); ITestContract channel = channelFactory.CreateChannel(); channel.Foo("boo"); ev.WaitOne(TimeSpan.FromSeconds(5)); actual.Should().Be("boo"); } } } }
public void Send_Receive_CustomSerializationMessage() { using (IBus bus = new RabbitMQBus()) { using (IChannelFactory <ITestContract> channelFactory = new MessageBus.Core.Proxy.ChannelFactory <ITestContract>(bus, c => c.UseJsonSerializerSettings(new JsonSerializerSettings { TypeNameHandling = TypeNameHandling.Auto }))) { ISubscriptionFactory <ITestContract> subscriptionFactory = new SubscriptionFactory <ITestContract>(bus); Data actual = null; ManualResetEvent ev = new ManualResetEvent(false); Data data = new Data { Value = "boo" }; using (ISubscriptionSelector <ITestContract> selector = subscriptionFactory.Subscribe(c => c.SetReceiveSelfPublish().UseJsonSerializerSettings(new JsonSerializerSettings { TypeNameHandling = TypeNameHandling.Auto }))) { selector.Subscribe <Data>(contract => contract.Foo, s => { actual = s; ev.Set(); }); ITestContract channel = channelFactory.CreateChannel(); channel.Foo(data); ev.WaitOne(TimeSpan.FromSeconds(5)); actual.ShouldBeEquivalentTo(data); } } } }
public void Send_Receive_CustomSerializationMessage() { using (IBus bus = new RabbitMQBus()) { using (IChannelFactory<ITestContract> channelFactory = new MessageBus.Core.Proxy.ChannelFactory<ITestContract>(bus, c => c.UseJsonSerializerSettings(new JsonSerializerSettings { TypeNameHandling = TypeNameHandling.Auto }))) { ISubscriptionFactory<ITestContract> subscriptionFactory = new SubscriptionFactory<ITestContract>(bus); Data actual = null; ManualResetEvent ev = new ManualResetEvent(false); Data data = new Data { Value = "boo" }; using (ISubscriptionSelector<ITestContract> selector = subscriptionFactory.Subscribe(c => c.SetReceiveSelfPublish().UseJsonSerializerSettings(new JsonSerializerSettings { TypeNameHandling = TypeNameHandling.Auto }))) { selector.Subscribe<Data>(contract => contract.Foo, s => { actual = s; ev.Set(); }); ITestContract channel = channelFactory.CreateChannel(); channel.Foo(data); ev.WaitOne(TimeSpan.FromSeconds(5)); actual.ShouldBeEquivalentTo(data); } } } }