-
Notifications
You must be signed in to change notification settings - Fork 55
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
[#109]Implement Correlation metadata on Sender OutboundMessages #110
Conversation
@@ -207,19 +207,61 @@ protected Scheduler createScheduler(String name) { | |||
* @see SendOptions#trackReturned(boolean) | |||
*/ | |||
public Flux<OutboundMessageResult> sendWithPublishConfirms(Publisher<OutboundMessage> messages, SendOptions options) { | |||
return sendWithCorrelatedPublishConfirms(Flux.from(messages).map(message -> (OutboundMessage<Object>) message), options) | |||
.map(Function.identity()); |
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 the only part of the changes that are somewhat squint-worthy to me, but necessary to make the compiler happy
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.
the suggestions above will remove the need for such casts, but you'll probably need 2 separate operator implementations, or at least a bit more juggling at the operator level
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'd try not to force correlationMetadata on current users that don't need it
@@ -23,7 +23,7 @@ | |||
/** | |||
* Outbound message meant to be sent by a {@link Sender}. | |||
*/ | |||
public class OutboundMessage { | |||
public class OutboundMessage<T> { |
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 force a null
correlationMetadata on every user, I'd extend OutboundMessage
and put the generic and the field on the subclass (OutboundCorrelatedMessage
?)
@@ -19,9 +19,9 @@ | |||
/** | |||
* Result of a sent message when using publisher confirm. | |||
*/ | |||
public class OutboundMessageResult { | |||
public class OutboundMessageResult<T> { |
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.
similarly to the above comment, I'd extract this specificity in a OutboundCorrelatedMessageResult<T>
. Then Sender
can have methods that take a publisher of OutboundMessage
and return Flux<OutboundMessageResult
vs methods that take a publisher of OutboundCorrelatedMessage<T>
and return Flux<OutboundCorrelatedMessageResult<T>>
public T getCorrelationMetadata() { | ||
return correlationMetadata; | ||
} | ||
|
||
@Override | ||
public String toString() { |
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.
note: toString
should probably reflect new field?
@@ -207,19 +207,61 @@ protected Scheduler createScheduler(String name) { | |||
* @see SendOptions#trackReturned(boolean) | |||
*/ | |||
public Flux<OutboundMessageResult> sendWithPublishConfirms(Publisher<OutboundMessage> messages, SendOptions options) { | |||
return sendWithCorrelatedPublishConfirms(Flux.from(messages).map(message -> (OutboundMessage<Object>) message), options) | |||
.map(Function.identity()); |
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.
the suggestions above will remove the need for such casts, but you'll probably need 2 separate operator implementations, or at least a bit more juggling at the operator level
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 new version integrates much smoother than the first one. I agree with @simonbasle regarding the introduction of 2 sub-classes (e.g. CorrelableOutboundMessage
and CorrelableOutboundMessageResult
) to make this new feature an opt-in. Users won't carry the empty correlation metadata and won't use a raw type if they don't want to use any correlation. The tricky part will be the operator, but handling the 2 types in there should be doable without too much duplication.
@acogoluegnes @simonbasle Thank you both for the callouts and suggestions 👍 I'll refactor to attempt addressing your comments |
@acogoluegnes @simonbasle Your recommendations ended up helping me clean these changes up a bit. The main thing that needed generification was the type of |
The API could be made a bit more strict and restrict users from being able to use their own extensions of |
@@ -207,19 +207,60 @@ protected Scheduler createScheduler(String name) { | |||
* @see SendOptions#trackReturned(boolean) | |||
*/ | |||
public Flux<OutboundMessageResult> sendWithPublishConfirms(Publisher<OutboundMessage> messages, SendOptions options) { | |||
return Flux.from(sendWithTypedPublishConfirms(messages, options)); |
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.
No longer need the weird type casting here
|
||
private final OutboundMessage outboundMessage; | ||
private final T outboundMessage; |
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.
Users that don't use special OutboundMessage
extensions should still be able to use untyped/raw OutboundMessageResult
in backward compatible fashion
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.
looks far better to me 👍
maybe I would rename the <T>
type to something that reflects that there is a type constraint, like <OMSG>
, but that's all
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.
Great, a new feature without breaking anything! My only concern is that people using sendWithPublishConfirms
will use raw OutboundMessageResult
s, but this is acceptable.
I think the plan would be for sendWithPublishConfirms
to adopt the same signature as sendWithTypedPublishConfirms
in 2.0, and then make sendWithTypedPublishConfirms
deprecated, to be removed in 3.0. This would be a breaking change for anyone declaring a variable out of the flux of OutboundMessageResult
, unfortunate, but this is what major releases are for.
Thanks for the quick feedback and merge turnaround, @acogoluegnes and @simonbasle ! Is there anywhere I can monitor the release timeline for a new version that will have this update in it? Looks like |
This feature will indeed be in 1.4, which should be released in a few weeks. It should contain #111 as well and anything related to feedback from 1.3. |
Still a work-in-progress, but looking for feedback. Trying to consider an approach that isn't technically backward incompatible due to the now-necessary generic type declaration on the Flux's OutboundMessage correlation metadata type.