-
Notifications
You must be signed in to change notification settings - Fork 174
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
Deprecate and replace MessageConverter with reactive IncomingMessageConverter #1772
Closed
Conversation
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
@cescoffier As discussed in the Zulip chat. There are a 5 or 6 failing Kafka tests that seem to be a result of the now required |
Codecov Report
@@ Coverage Diff @@
## main #1772 +/- ##
=============================================
- Coverage 73.83% 12.49% -61.34%
+ Complexity 3145 441 -2704
=============================================
Files 275 276 +1
Lines 11228 11238 +10
Branches 1437 1432 -5
=============================================
- Hits 8290 1404 -6886
- Misses 2249 9645 +7396
+ Partials 689 189 -500
|
This covers issues with message conversion failures related to both MANUAL and POST_PROCESSING ack strategies.
### IncomingMessageConverter / MessageConverter * Introduces IncomingMessageConverter which as a reactive interface * * Naming allows/prepares for outgoing message converters as well * Deprecates MessageConverter ### ConverterUtils * `canCovert` is now always called (as the API docs suggest) even after converter caching * Identity converter is no longer used; compatbile payloads and target types use go through no conversion * Handles `MessageConverter.convert` failures * * Wrapped with logging and automatic message rejection Fixes smallrye#1769
The ad-hoc conversion that was happening in `IncomingRabbitMQMessage.getPayload()` has been removed and replaced with a standard set of `IncomingMessageConverter`s that support JSON, text and byte arrays; the same that was attempted in the getPayload. This ensures conversion only happens once (instead of every time getPayload is called) and that errors don’t happen or are handled properly when the do. The removes `content-type-override` option. It was a hack to get the ad-hoc conversion to treat messages as some other type. This should be handled in an `IncomingMessageConverter` with proper error handling (which wasn’t done before.
be40a56
to
a4f059a
Compare
Sign up for free
to join this conversation on GitHub.
Already have an account?
Sign in to comment
Add this suggestion to a batch that can be applied as a single commit.
This suggestion is invalid because no changes were made to the code.
Suggestions cannot be applied while the pull request is closed.
Suggestions cannot be applied while viewing a subset of changes.
Only one suggestion per line can be applied in a batch.
Add this suggestion to a batch that can be applied as a single commit.
Applying suggestions on deleted lines is not supported.
You must change the existing code in this line in order to create a valid suggestion.
Outdated suggestions cannot be applied.
This suggestion has been applied or marked resolved.
Suggestions cannot be applied from pending reviews.
Suggestions cannot be applied on multi-line comments.
Suggestions cannot be applied while the pull request is queued to merge.
Suggestion cannot be applied right now. Please check back later.
Fixes #1769
IncomingMessageConverter
/MessageConverter
Deprecate
MesasgeConverter
MessageConverter
's interface is synchronous which does not allow it to handle failures in any meaningful way. First, if message conversion fails the interface requires it to return something which cannot currently be null; meaning there is no current mechanism to "ignore" a failed message. Second, it is required thatMessageConverter
s handle callingack
ornack
for a failure. Unfortunately those methods returnCompletionStage
s. Converters must ignore the results ofack
/nack
or perform some sort of blocking wait for them to complete.After talking with @cescoffier we decided changing the interface to use a reactive method would be best.
Introducing IncomingMessageConverter
IncomingMessageConverter
is the same interface but returns aUni<Message<?>>
. Changing its name serves two purposes. 1) The new name allows/prepares for outgoing message converters (as discussed in issues like #1162). 2) It allows continued use of (now deprecated)MessageConverter
until such time as it is removed.Adapter AnyMessageConverter
To facilitate using both
IncomingMessageConverter
andMessageConverter
a new base interfaceAnyMessageConverter
was added. It is marked deprecated along withMessageConverter
and when it is decided to removeMessageConverter
,AnyMessageConverter
will be removed as well.ConverterUtils Changes
Wrapping Legacy Converters
Calls to the deprecated
MessageConverter.convert
are now wrapped with failure handling that logs the failure, rejects (akanack
s) and ignores the message. This solves issues with stalling of message handling (e.g. #1769) since failures cannot be handled by these converters.Wrapping is not done for
IncomingMessageConverter
, now that the interface provides the full capabilities to handle failures gracefully it is expected that they will. All failures from streams returned fromIncomingMessageConverter
are ignored without logging or ack/nack (this is explained in the interface's API docs).canConvert
Previously due to caching of converters, the
canCovert
method was only ever called one time, when the converter was cached. This has the following problems:convert
is called.canConvert
is passed an instance ofMessage<?>
to make its decision but each call toconvert
will be passed a unique instance ofMessage<?>
which may not be anything like the message passed tocanCovert
.For these reasons
canConvert
is now always called (as the API docs already suggest) even after converter caching. If a converter cannot be used with the current message instance a new converter will be cached. For converters that see the same exact messages all the time there is little to no penalty. Additionally converters that may see a wide range of message types will now work correctly.No
Identity
converterThe
ConverterUtils.convert
method checks for the ability to assign the payload type in the message to the type target payload type required by the injection target. There is no need to lookup and use an identity converter since the message payload is already in a form the injection target can use.RabbitMQ Conversion
IncomingRabbitMQMessage
's ad-hoc conversion inIncomingRabbitMQMessage.getPayload()
has been replaced with a standard set of converts that replicate the previous behavior but with better error handling and more deterministic logic.Additionally this removes the
content-type-override
for RabbitMQ incoming connectors. It was used as a hack to make conversion happen on unsupported content types. This should be done in anIncomingMessageConverter
, with proper error handling, whenever this functionality is needed.