public RabbitMessageBus(IDependencyResolver resolver, RabbitScaleoutConfiguration configuration) : base(resolver, configuration) { _bus = new RabbitMQBus(c => c.UseConnectionString(configuration.ConnectionString)); ScaleoutMessageSerializer serializer = new ScaleoutMessageSerializer(); _publisher = _bus.CreatePublisher(c => c.UseCustomSerializer(serializer)); _subscriber = _bus.CreateSubscriber(c => c.SetReceiveSelfPublish().AddCustomSerializer(serializer)); _subscriber.Subscribe<ScaleoutMessage>(OnMessage, filter: configuration.FilterHeaders); Open(0); _subscriber.Open(); }
public RabbitMessageBus(IDependencyResolver resolver, RabbitScaleoutConfiguration configuration) : base(resolver, configuration) { _bus = new RabbitMQBus(c => c.UseConnectionString(configuration.ConnectionString)); ScaleoutMessageSerializer serializer = new ScaleoutMessageSerializer(); _publisher = _bus.CreatePublisher(c => c.UseCustomSerializer(serializer)); _subscriber = _bus.CreateSubscriber(c => c.SetReceiveSelfPublish().AddCustomSerializer(serializer)); _subscriber.Subscribe <ScaleoutMessage>(OnMessage, filter: configuration.FilterHeaders); Open(0); _subscriber.Open(); }
/// <summary> /// Use RabbitMQ as the messaging backplane for scaling out of ASP.NET SignalR applications in a web farm. /// </summary> /// <param name="resolver">The dependency resolver</param> /// <param name="configuration">The RabbitMQ scale-out configuration options.</param> /// <returns>The dependency resolver.</returns> public static IDependencyResolver UseRabbit(this IDependencyResolver resolver, RabbitScaleoutConfiguration configuration) { var bus = new Lazy <RabbitMessageBus>(() => new RabbitMessageBus(resolver, configuration)); resolver.Register(typeof(IMessageBus), () => bus.Value); return(resolver); }