private async Task <ProcessedMessageStatus> SingleMessageConsumeAsync(MotorCloudEvent <byte[]> dataCloudEvent, CancellationToken token) { try { byte[] decoded; using (new AutoObserveStopwatch(() => _messageDecoding)) { decoded = await DecodeMessageAsync( dataCloudEvent.GetEncoding(), dataCloudEvent.TypedData, token); } TInput deserialized; using (new AutoObserveStopwatch(() => _messageDeserialization)) { deserialized = _deserializer.Deserialize(decoded); } return(await _queue .QueueBackgroundWorkItem(dataCloudEvent.CreateNew(deserialized, true)) .ConfigureAwait(true)); } catch (ArgumentException e) { _logger.LogError(LogEvents.InvalidInput, e, "Invalid Input"); return(ProcessedMessageStatus.InvalidInput); } catch (Exception e) { _logger.LogError(LogEvents.UnexpectedErrorOnMessageProcessing, e, "Invalid Input"); return(ProcessedMessageStatus.CriticalFailure); } }
public void CreateNew_OldEventHasContentEncoding_NewEventHasSameContentEncoding() { var oldEvent = new MotorCloudEvent <string>(GetApplicationNameService(), " ", new Uri("test://non")); oldEvent.SetEncoding("some-encoding"); var expectedData = new List <string>(); var newEvent = oldEvent.CreateNew(expectedData); Assert.Equal(oldEvent.GetEncoding(), newEvent.GetEncoding()); }