Skip to content
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

Investigate Improvements to MessageSerializationRegister #1112

Open
slang25 opened this issue Jan 18, 2023 · 0 comments
Open

Investigate Improvements to MessageSerializationRegister #1112

slang25 opened this issue Jan 18, 2023 · 0 comments

Comments

@slang25
Copy link
Member

slang25 commented Jan 18, 2023

At the moment MessageSerializationRegister has a few areas for improvement:

  • Inefficient serializer resolution - the current registry works by keying serializers by type, then looping through all serializers in the dictionary and asking "If I am able to get the subject for this message, does it then match the subject of the corresponding type it's keyed by". This is quite odd, and not efficient.
  • Difficult to customize the subject - The message subject is really used as a way to correlate the deserializer back to the message once it's been partially read (just enough to get the subject), there's no reason we couldn't customize this at registration and say "Hey this subscription will actually have messages with this subject", this will help us with interoping with other platforms.
  • Inefficient message envelope support - Let's say we want to add CloudEvents or some other format, and be processing some existing JustSaying format messages, you'd be deliberately throwing and catching exceptions constantly as the registry tries to identify the correct serializer. Having a separate envelope deserializer would reduce this to just 2, it could still use trial and error, but reduce the number of serializers to try.

There are two things we could look at to improve this:

  • SplitIMessageSerializer into two interfaces, where we can have something like a IMessageEnvelopeSerializer who's job is just to get the subject from the general message format (the "envelope" if you will)
  • Pass through the serializer type via generics all the way from the subscription registration. This would be a bigger change, but not having a MessageSerializationRegister would make a lot of sense. This might be tricky given the fan-in and fan-out approach that subscription groups provide.
Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment
Labels
None yet
Projects
None yet
Development

No branches or pull requests

1 participant