-
Notifications
You must be signed in to change notification settings - Fork 46
Increase robustness of outbox flushing with respect to outbox entry deserialization issues #851
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
Conversation
This looks like a sensible first step. I think, however, that we should follow normal error behaviour for anything that fails to deserialise:
This will avoid the same record getting re-read continously, allow blocking to progress as normal, and ensure that anyone who is using |
We're also going to need testts for these behaviours! |
Alright, good point. I tried different approaches and came up with the one comitted. In doing so I needed to modify core classes and, in particular, you may have suggestions regarding the Invocation class. Also I added/modified some tests. Please have a look and provide your feedback. Thanks. |
this.parameterTypes = new Class<?>[] {}; | ||
this.args = new Object[] {}; | ||
this.mdc = null; | ||
this.exceptionDuringDeserialization = Optional.of(exception); |
There was a problem hiding this comment.
Choose a reason for hiding this comment
The reason will be displayed to describe this comment to others. Learn more.
Rather than adding a new property here (which will impact on ser/deser of all Invocation
s, not just this one), why not create a FailedDeserializingInvocation
, something like this:
class FailedDeserializingInvocation extends Invocation {
private final IOException e;
FailedDeserializingInvocation(IOException e) {
this.className = "";
this.methodName = "";
this.parameterTypes = new Class<?>[] {};
this.args = new Object[] {};
this.mdc = null;
this.e= e;
}
@Override
void invoke(Object instance, TransactionOutboxListener listener)
throws NoSuchMethodException, IllegalAccessException, InvocationTargetException {
throw new WrappedCheckedException(e);
}
}
Should make the code elsewhere cleaner too.
You will need to replace @Value
on Invocation
to make it nonfinal so this can be done:
@ToString
@EqualsAndHashCode
@AllArgsConstructor
@FieldDefaults(makeFinal = true, level = AccessLevel.PRIVATE)
@Getter
There was a problem hiding this comment.
Choose a reason for hiding this comment
The reason will be displayed to describe this comment to others. Learn more.
Yes, makes sense. Done.
package com.gruelbox.transactionoutbox; | ||
|
||
/** Thrown when de-serialization of an invocation fails. */ | ||
class DeserializationFailedException extends RuntimeException { |
There was a problem hiding this comment.
Choose a reason for hiding this comment
The reason will be displayed to describe this comment to others. Learn more.
I think there's a standard exception somewhere in the core lib for generically wrapping checked exceptions, which is all that's going on here.
There was a problem hiding this comment.
Choose a reason for hiding this comment
The reason will be displayed to describe this comment to others. Learn more.
Thanks for the hint. Done.
...ackson/src/main/java/com/gruelbox/transactionoutbox/jackson/JacksonInvocationSerializer.java
Show resolved
Hide resolved
There was a problem hiding this comment.
Choose a reason for hiding this comment
The reason will be displayed to describe this comment to others. Learn more.
This is a really nice approach. I like how neatly it works when you push the exception down into the invocation. Great stuff.
Just a few tweaks on the implementation, but the approach and testing are sound.
Merged! Thanks :) |
Background:
Problem:
Analysis:
Solution:
Open points: