public void Send(TransportMessage message, Address address) { UnitOfWork.Add(channel => { var properties = RabbitMqTransportMessageExtensions.FillRabbitMqProperties(message, channel.CreateBasicProperties()); RoutingTopology.Send(channel, address, message, properties); }); }
void SendMessage(TransportMessage message, SendOptions sendOptions, IModel channel) { var destination = DetermineDestination(sendOptions); var properties = channel.CreateBasicProperties(); RabbitMqTransportMessageExtensions.FillRabbitMqProperties(message, sendOptions, properties); routingTopology.Send(channel, destination, message, properties); }
void PublishMessage(TransportMessage message, PublishOptions publishOptions, IModel channel) { var eventType = publishOptions.EventType; var properties = channel.CreateBasicProperties(); RabbitMqTransportMessageExtensions.FillRabbitMqProperties(message, publishOptions, properties); RoutingTopology.Publish(channel, eventType, message, properties); }
public bool Publish(TransportMessage message, IEnumerable <Type> eventTypes) { var eventType = eventTypes.First();//we route on the first event for now UnitOfWork.Add(channel => { var properties = RabbitMqTransportMessageExtensions.FillRabbitMqProperties(message, channel.CreateBasicProperties()); RoutingTopology.Publish(channel, eventType, message, properties); }); //we don't know if there was a subscriber so we just return true return(true); }
void Action(object obj) { try { var cancellationToken = (CancellationToken)obj; var connection = ConnectionManager.GetConsumeConnection(); using (var channel = connection.CreateModel()) { channel.BasicQos(0, PrefetchCount, false); var consumer = new QueueingBasicConsumer(channel); channel.BasicConsume(workQueue, autoAck, consumer); circuitBreaker.Success(); while (!cancellationToken.IsCancellationRequested) { Exception exception = null; var message = DequeueMessage(consumer); if (message == null) { continue; } TransportMessage transportMessage = null; try { var messageProcessedOk = false; try { transportMessage = RabbitMqTransportMessageExtensions.ToTransportMessage(message); } catch (Exception ex) { Logger.Error("Poison message detected, deliveryTag: " + message.DeliveryTag, ex); //just ack the poison message to avoid getting stuck messageProcessedOk = true; } if (transportMessage != null) { messageProcessedOk = tryProcessMessage(transportMessage); } if (!autoAck) { if (messageProcessedOk) { channel.BasicAck(message.DeliveryTag, false); } else { channel.BasicReject(message.DeliveryTag, true); } } } catch (Exception ex) { exception = ex; if (!autoAck) { channel.BasicReject(message.DeliveryTag, true); } } finally { endProcessMessage(transportMessage, exception); } } } } finally { countdownEvent.Signal(); } }