private async Task ProcessEventAsync(IModel channel, BasicDeliverEventArgs ea) { var eventName = ea.RoutingKey; var eventType = EventTypes.GetOrDefault(eventName); if (eventType == null) { return; } var eventData = Serializer.Deserialize(ea.Body.ToArray(), eventType); await TriggerHandlersAsync(eventType, eventData, errorContext => { var retryAttempt = 0; if (ea.BasicProperties.Headers != null && ea.BasicProperties.Headers.ContainsKey(EventErrorHandlerBase.RetryAttemptKey)) { retryAttempt = (int)ea.BasicProperties.Headers[EventErrorHandlerBase.RetryAttemptKey]; } errorContext.EventData = Serializer.Deserialize(ea.Body.ToArray(), eventType); errorContext.SetProperty(EventErrorHandlerBase.HeadersKey, ea.BasicProperties); errorContext.SetProperty(EventErrorHandlerBase.RetryAttemptKey, retryAttempt); }); }
private async Task ProcessEventAsync(Message <string, byte[]> message) { var eventName = message.Key; var eventType = EventTypes.GetOrDefault(eventName); if (eventType == null) { return; } var eventData = Serializer.Deserialize(message.Value, eventType); await TriggerHandlersAsync(eventType, eventData, errorContext => { var retryAttempt = 0; if (message.Headers.TryGetLastBytes(EventErrorHandlerBase.RetryAttemptKey, out var retryAttemptBytes)) { retryAttempt = Serializer.Deserialize <int>(retryAttemptBytes); } errorContext.EventData = Serializer.Deserialize(message.Value, eventType); errorContext.SetProperty(EventErrorHandlerBase.HeadersKey, message.Headers); errorContext.SetProperty(EventErrorHandlerBase.RetryAttemptKey, retryAttempt); }); }
private async Task ProcessEventAsync(Message <string, byte[]> message) { var eventName = message.Key; var eventType = EventTypes.GetOrDefault(eventName); if (eventType == null) { return; } string messageId = null; if (message.Headers.TryGetLastBytes("messageId", out var messageIdBytes)) { messageId = System.Text.Encoding.UTF8.GetString(messageIdBytes); } if (await AddToInboxAsync(messageId, eventName, eventType, message.Value)) { return; } var eventData = Serializer.Deserialize(message.Value, eventType); await TriggerHandlersAsync(eventType, eventData); }
public override Task PublishFromOutboxAsync( OutgoingEventInfo outgoingEvent, OutboxConfig outboxConfig) { var eventType = EventTypes.GetOrDefault(outgoingEvent.EventName); var eventData = Serializer.Deserialize(outgoingEvent.EventData, eventType); return(PublishToEventBusAsync(eventType, eventData)); }
private async Task ProcessEventAsync(Message <string, byte[]> message) { var eventName = message.Key; var eventType = EventTypes.GetOrDefault(eventName); if (eventType == null) { return; } var eventData = Serializer.Deserialize(message.Value, eventType); await TriggerHandlersAsync(eventType, eventData); }
private async Task ProcessEventAsync(IModel channel, BasicDeliverEventArgs ea) { var eventName = ea.RoutingKey; var eventType = EventTypes.GetOrDefault(eventName); if (eventType == null) { return; } var eventData = Serializer.Deserialize(ea.Body.ToArray(), eventType); await TriggerHandlersAsync(eventType, eventData); }
public override async Task ProcessFromInboxAsync( IncomingEventInfo incomingEvent, InboxConfig inboxConfig) { var eventType = EventTypes.GetOrDefault(incomingEvent.EventName); if (eventType == null) { return; } var eventData = Serializer.Deserialize(incomingEvent.EventData, eventType); var exceptions = new List <Exception>(); await TriggerHandlersAsync(eventType, eventData, exceptions, inboxConfig); if (exceptions.Any()) { ThrowOriginalExceptions(eventType, exceptions); } }
private async Task<AckStrategy> ProcessEventAsync(byte[] buffer, MessageProperties messageProperties, MessageReceivedInfo messageReceivedInfo) { var eventName = messageReceivedInfo.RoutingKey; var eventType = EventTypes.GetOrDefault(eventName); if (eventType == null) { return AckStrategies.Ack; } var eventData = Serializer.Deserialize(buffer, eventType); await TriggerHandlersAsync(eventType, eventData, errorContext => { var retryAttempt = 0; if (messageProperties.Headers != null && messageProperties.Headers.ContainsKey(EventErrorHandlerBase.RetryAttemptKey)) { retryAttempt = (int)messageProperties.Headers[EventErrorHandlerBase.RetryAttemptKey]; } errorContext.EventData = eventData; errorContext.SetProperty(EventErrorHandlerBase.HeadersKey, messageProperties); errorContext.SetProperty(EventErrorHandlerBase.RetryAttemptKey, retryAttempt); }); return AckStrategies.Ack; }