-
Notifications
You must be signed in to change notification settings - Fork 2k
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
[ServiceBus] Cache UpdateDispositionWorkItem Mono #22317
Changes from 1 commit
File filter
Filter by extension
Conversations
Jump to
Diff view
Diff view
There are no files selected for viewing
Original file line number | Diff line number | Diff line change |
---|---|---|
|
@@ -250,7 +250,7 @@ private Mono<Void> updateDispositionInternal(String lockToken, DeliveryState del | |
sink.error(new AmqpException(false, "updateDisposition failed while dispatching to Reactor.", | ||
error, handler.getErrorContext(receiver))); | ||
} | ||
}); | ||
}).cache().then(Mono.empty()); // cache because closeAsync use `when` to subscribe this Mono again. | ||
|
||
workItem.setMono(result); | ||
|
||
|
@@ -362,7 +362,7 @@ private void cleanupWorkItems() { | |
}); | ||
} | ||
|
||
private void completeWorkItem(String lockToken, Delivery delivery, MonoSink<Void> sink, Throwable error) { | ||
private void completeWorkItem(String lockToken, Delivery delivery, MonoSink<Object> sink, Throwable error) { | ||
There was a problem hiding this comment. Choose a reason for hiding this commentThe reason will be displayed to describe this comment to others. Learn more. Why do we need it to be a MonoSink of Object? I thought you could cache to There was a problem hiding this comment. Choose a reason for hiding this commentThe reason will be displayed to describe this comment to others. Learn more. the final Mono<Void> result = Mono.create(sink -> {
workItem.start(sink);
try {
provider.getReactorDispatcher().invoke(() -> {
unsettled.disposition(deliveryState);
pendingUpdates.put(lockToken, workItem);
});
} catch (IOException error) {
sink.error(new AmqpException(false, "updateDisposition failed while dispatching to Reactor.",
error, handler.getErrorContext(receiver)));
}
}).cache().then(); There was a problem hiding this comment. Choose a reason for hiding this commentThe reason will be displayed to describe this comment to others. Learn more. You can cast the create operator to final Mono<Void> result = Mono.<Void>create(sink -> {
workItem.start(sink);
try {
provider.getReactorDispatcher().invoke(() -> {
unsettled.disposition(deliveryState);
pendingUpdates.put(lockToken, workItem);
});
} catch (IOException error) {
sink.error(new AmqpException(false, "updateDisposition failed while dispatching to Reactor.",
error, handler.getErrorContext(receiver)));
}
}).cache(); |
||
final boolean isSettled = delivery != null && delivery.remotelySettled(); | ||
if (isSettled) { | ||
delivery.settle(); | ||
|
@@ -392,7 +392,7 @@ private static final class UpdateDispositionWorkItem { | |
|
||
private Mono<Void> mono; | ||
private Instant expirationTime; | ||
private MonoSink<Void> sink; | ||
private MonoSink<Object> sink; | ||
private Throwable throwable; | ||
|
||
private UpdateDispositionWorkItem(String lockToken, DeliveryState state, Duration timeout) { | ||
|
@@ -429,11 +429,11 @@ private Mono<Void> getMono() { | |
return mono; | ||
} | ||
|
||
private MonoSink<Void> getSink() { | ||
private MonoSink<Object> getSink() { | ||
return sink; | ||
} | ||
|
||
private void start(MonoSink<Void> sink) { | ||
private void start(MonoSink<Object> sink) { | ||
Objects.requireNonNull(sink, "'sink' cannot be null."); | ||
this.sink = sink; | ||
this.sink.onDispose(() -> isDisposed.set(true)); | ||
|
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.
Do we need
.then(Mono.empty())
? If so, then usethen()
?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.
Good catch. Mono.empty() is not required here.