public void HandleBasicDeliver( string consumerTag, ulong deliveryTag, bool redelivered, string exchange, string routingKey, IBasicProperties properties, byte[] body) { Logger.Debug("HandleBasicDeliver on consumer: {0}, deliveryTag: {1}", consumerTag, deliveryTag); if (disposed) { // this message's consumer has stopped, so just return Logger.Info("Consumer has stopped running. Consumer '{0}' on queue '{1}'. Ignoring message", ConsumerTag, queue.Name); return; } if (onMessage == null) { Logger.Error("User consumer callback, 'onMessage' has not been set for consumer '{0}'." + "Please call InternalConsumer.StartConsuming before passing the consumer to basic.consume", ConsumerTag); return; } var messageReceivedInfo = new MessageReceivedInfo(consumerTag, deliveryTag, redelivered, exchange, routingKey, queue.Name); var messsageProperties = new MessageProperties(properties); var context = new ConsumerExecutionContext(onMessage, messageReceivedInfo, messsageProperties, body, this); consumerDispatcher.QueueAction(() => { EventBus.Publish(new DeliveredMessageEvent(messageReceivedInfo, messsageProperties, body)); handlerRunner.InvokeUserMessageHandler(context); }); }
public IMessage <T> DeserializeMessage <T>(MessageProperties properties, byte[] body) where T : class { var messageBody = serializer.Deserialize <T>(body); return(new Message <T>(messageBody, properties)); }
public object Clone() { var copy = new MessageProperties(); if (contentTypePresent) { copy.ContentType = ContentType; } if (contentEncodingPresent) { copy.ContentEncoding = ContentEncoding; } if (deliveryModePresent) { copy.DeliveryMode = DeliveryMode; } if (priorityPresent) { copy.Priority = Priority; } if (correlationIdPresent) { copy.CorrelationId = CorrelationId; } if (replyToPresent) { copy.ReplyTo = ReplyTo; } if (expirationPresent) { copy.Expiration = Expiration; } if (messageIdPresent) { copy.MessageId = MessageId; } if (timestampPresent) { copy.Timestamp = Timestamp; } if (typePresent) { copy.Type = Type; } if (userIdPresent) { copy.UserId = UserId; } if (appIdPresent) { copy.AppId = AppId; } if (clusterIdPresent) { copy.ClusterId = ClusterId; } if (headersPresent) { copy.Headers = new Dictionary <string, object>(Headers); } return(copy); }
public void SetProperties(MessageProperties properties) { GuardHelper.ArgumentNotNull(() => properties); Properties = properties; }