private void CreateMessageHandlers(NetChannel channel) { foreach (var type in handlerTypes) { MessageHandlerFactory.Create(type, channel); } }
public void Should_create_a_handler() { var factory = new MessageHandlerFactory(); var result = factory.Create(typeof(foo)); result.ShouldNotBeNull(); }
public override IBasicConsumer CreateAsyncConsumer <T>(IModel channel, string subscriptionName, Action <T, MessageDeliverEventArgs> onReceiveMessage, ushort?batchSize) { var messageHandler = MessageHandlerFactory.Create(subscriptionName, onReceiveMessage); var consumer = new PriorityBurrowConsumer(channel, messageHandler, _watcher, false, (batchSize > 1 ? batchSize.Value : Global.DefaultConsumerBatchSize)); _createdConsumers.Add(consumer); return(consumer); }
public override IBasicConsumer CreateConsumer <T>(IModel channel, string subscriptionName, Action <T, MessageDeliverEventArgs> onReceiveMessage) { var messageHandler = MessageHandlerFactory.Create(subscriptionName, onReceiveMessage); var consumer = new PriorityBurrowConsumer(channel, messageHandler, _watcher, false, 1); _createdConsumers.Add(consumer); return(consumer); }
public override IBasicConsumer CreateConsumer <T>(IModel channel, string subscriptionName, Action <T> onReceiveMessage) { var messageHandler = MessageHandlerFactory.Create <T>(subscriptionName, (msg, evt) => onReceiveMessage(msg)); var consumer = new PriorityBurrowConsumer(channel, messageHandler, _watcher, true, 1); _createdConsumers.Add(consumer); return(consumer); }
public override IBasicConsumer CreateConsumer <T>(IModel channel, string subscriptionName, Action <T> onReceiveMessage, ushort?consumerThreadCount) { var messageHandler = MessageHandlerFactory.Create <T>(subscriptionName, (msg, evt) => onReceiveMessage(msg)); var consumer = new PriorityBurrowConsumer(channel, messageHandler, _watcher, true, (consumerThreadCount > 0 ? consumerThreadCount.Value : Global.DefaultConsumerBatchSize)); _createdConsumers.Add(consumer); return(consumer); }
private void ConsumerOnReceived(object sender, BasicDeliverEventArgs ea) { // get the details from the event var body = ea.Body; var message = Encoding.UTF8.GetString(body); var messageType = "endpoint"; // hardcoding the message type while we dev... //var messageType = Encoding.UTF8.GetString(ea.BasicProperties.Headers["message-type"] as byte[]); // instantiate the appropriate handler based on the message type IMessageProcessor processor = handlerFactory.Create(messageType); processor.Process(message); // Ack the event on the queue IBasicConsumer consumer = (IBasicConsumer)sender; consumer.Model.BasicAck(ea.DeliveryTag, false); }
static void Main(string[] args) { var q = new MessageQueue(); #region in another process var msg = new SendEmailMessage() { EmailAddress = "*****@*****.**" }; q.SendMessage(msg); #endregion var outMsg = q.GetNextMessage(); var handlerFactory = new MessageHandlerFactory(); var handler = handlerFactory.Create(msg); handler.ProcessMessage(msg); }
public void Should_create_a_handler() { var factory = new MessageHandlerFactory(); var result = factory.Create(typeof(foo)); result.ShouldNotBeNull(); }