AxonFramework / AxonFramework

Framework for Evolutionary Message-Driven Microservices on the JVM
https://axoniq.io/
Apache License 2.0
3.32k stars 790 forks source link

Allow DLQ to handle deserialization errors #3126

Closed CodeDrivenMitch closed 3 weeks ago

CodeDrivenMitch commented 1 month ago

Currently the DLQ does not enqueue messages with deserialization errors, due to the following stack trace:

SerializedMessage.getPayload(SerializedMessage.java:81)
MessageDecorator.getPayload(MessageDecorator.java:56)
MessageDecorator.getPayload(MessageDecorator.java:56)
EventMessageDeadLetterJpaConverter.convert(EventMessageDeadLetterJpaConverter.java:59)

In this trace the message is first deserialized (if it wasn't yet, through the LazyDeserializingMessage) before being serialized again. Besides being inefficient, this causes any deserialization error to occur again during enqueuement in the DLQ, causing the event processor to go into error mode.

This PR switches the call to the Message.serializePayload call, which is overridden by the SerializedMessage to not deserialize/serialize if the type matches (or tries to find a converter).

sonarcloud[bot] commented 1 month ago

Quality Gate Failed Quality Gate failed

Failed conditions
65.0% Coverage on New Code (required ≥ 80%)
B Reliability Rating on New Code (required ≥ A)

See analysis details on SonarCloud

Catch issues before they fail your Quality Gate with our IDE extension SonarLint

abuijze commented 3 weeks ago

Thanks for the PR. Could you rebase your branch onto 4.10.x? That way, we can release the fix in 4.10.1. Also, please check your code style config. It seems that some indentation rules are different in your IDE, which causes whitespace-only changes in the PR.