-
Notifications
You must be signed in to change notification settings - Fork 18
New issue
Have a question about this project? Sign up for a free GitHub account to open an issue and contact its maintainers and the community.
By clicking “Sign up for GitHub”, you agree to our terms of service and privacy statement. We’ll occasionally send you account related emails.
Already on GitHub? Sign in to your account
Cannot consume messages if they are not published using this library #141
Comments
Thanks for the feedback @zRosenthal. This library is designed to by default expect messages to be in the CloudEvents specification. The publishers in this library publish in this specification. We also need someway to understand the type of message so we can map it to .NET type for serialization and mapping to handler. CloudEvents gave us placeholders for that information. We did want to make the library extensible for non CloudEvents scenarios. You can inject your own implementation of the IEnvelopeSerializer and IMessageSerializer interfaces into the DI container. This allows you to define your own format of the messages. I would love to hear your feedback on adding your own serialization format to the library. |
For this framework, the If some other microservice (maybe a lamdba or non-.Net app) tried to publish a message to be consumed up by a .NET service that utilizes this messaging framework, that message payload should ideally be stringified for smooth deserialization by the message framework. Would that be a misinterpretation of opinion and intent from this framework? A stronger opinion seems beneficial if the CloudEvent spec is going to be adopted because it wouldn't be ideal for applications that do not have access to this messaging framework to run into integration issues just because the format of the data happens to be slightly different. e.g. If the .NET application received this message (note the format of the data field):
Is the expectation that a non-serialized object (JSON object) in the payload is unexpected and needs to be explicitly handled? |
I ran into identical problems starting out with this. I've got a queue that receives events from EventBridge when a PutObject is completed in an S3 bucket. This library has no idea how to understand those messages, apparently because it expects the CloudEvents spec while EventBridge isn't publishing the event in that spec. While I can inject new serializers in to get around that, it feels like its undermining a lot of the headline selling point of the library in the first place (that it makes working with SQS easy so you can focus on business logic, which is a great idea). Having a built in method to say "deserliaze this message into this class definition I've provided and decorated with [JsonPropertyName]" would alleviate the issue entirely. That's something I definitely can do, but it feels like something a library like this should have a means to handle out of the box given that it's going to be a common usage scenario. Thanks. :) |
Describe the bug
Love the idea of this library as it drastically simplifies consuming from SQS. However in testing I am unable to get it to work unless the messages are published using this library.
This makes this library unusable in most enterprise environments where we consume events from a wide variety of sources many of which are not directly controlled by the team/app that is publishing those events.
Expected Behavior
Able to consume any json message
Current Behavior
Quick test routing events from AWS EventBridge
fail: AWS.Messaging.Serialization.EnvelopeSerializer[0]
MessageEnvelope instance is not valid
Id cannot be null or empty.
Source cannot be null.
Version cannot be null or empty.
MessageTypeIdentifier cannot be null or empty.
TimeStamp is not set.Message cannot be null.
Whats interesting about this is that the message from EventBridge actually does include Id, Source, Version however my understanding is that because that data is not contained in the
detail
node it is ignored.Reproduction Steps
Publish a generic json object to an SQS queue without utilizing this library.
Possible Solution
Why are all of these fields required? Do we truly need them or can they be optional?
Can we allow custom mappers for the fields that are absolutely required? Could even ship with a prebuilt EventBridge mapper to utilize the existing properties in event.
Additional Information/Context
No response
AWS.Messaging (or related) package versions
AWS.Messaging 0.9.1
Targeted .NET Platform
.NET 8
Operating System and version
OSX Sonoma 14.1
The text was updated successfully, but these errors were encountered: