protected override void ConfigureInputQueueEndpoint(IInMemoryReceiveEndpointConfigurator configurator) { _observer = new ObservableObserver<ConsumeContext<A>>(); _observer.GroupBy(x => x.Message.Name).Subscribe(value => Console.WriteLine("Key: {0}", value.Key)); configurator.Observer(_observer); }
protected override void ConfigureInMemoryReceiveEndpoint(IInMemoryReceiveEndpointConfigurator configurator) { _observer = new ObservableObserver <ConsumeContext <A> >(); _observer.GroupBy(x => x.Message.Name).Subscribe(value => Console.WriteLine("Key: {0}", value.Key)); configurator.Observer(_observer); }
static (IBusControl, IObservable <Command>) CreateBusAndObservable() { var observer = new ObservableObserver <ConsumeContext <Command> >(); var bus = Bus.Factory.CreateUsingRabbitMq(cfg => { var host = cfg.Host(new Uri("rabbitmq://localhost"), h => { h.Username("guest"); h.Password("guest"); }); cfg.ReceiveEndpoint(host, typeof(Command).FullName, e => { e.PrefetchCount = 1; e.Observer(observer); }); EndpointConvention.Map <Fizz>(new Uri($"rabbitmq://localhost/{typeof(Command).FullName}")); EndpointConvention.Map <Buzz>(new Uri($"rabbitmq://localhost/{typeof(Command).FullName}")); cfg.ConfigureJsonSerializer(settings => { // Remove MassTransit.InterfaceProxyConverter to not create interface proxies settings.Converters.Remove(settings.Converters.Single(x => x is MessageDataJsonConverter)); // Add converter that manually sets the serializer's TypeNameHandling to Auto settings.Converters.Add(new UnionCasesJsonWriter <Command>()); // settings.TypeNameHandling = TypeNameHandling.Auto; return(settings); }); cfg.ConfigureJsonDeserializer(settings => { // Remove MassTransit.InterfaceProxyConverter to not create interface proxies // settings.Converters.Remove(settings.Converters.Single(x => x is InterfaceProxyConverter)); // Add converter that manually sets the serializer's TypeNameHandling to Auto settings.Converters.Add(new UnionCasesJsonReader <Command>()); // settings.TypeNameHandling = TypeNameHandling.Auto; return(settings); }); }); return(bus, observer.Select(x => x.Message)); }