Skip to content

Publishing plus immediate flush #1211

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

Merged
merged 4 commits into from
Aug 20, 2024
Merged

Publishing plus immediate flush #1211

merged 4 commits into from
Aug 20, 2024

Conversation

scottf
Copy link
Contributor

@scottf scottf commented Aug 19, 2024

When a "request" was made, there were two pieces of code
called in succession

  1. put message in queue
  2. flush socket
    The intention was that on a request, we want to get the publish part of the request out over the socket quickly. But because operation 1 simply queues the message, the flush likely happens before the message even got moved to the socket

So instead of the 2 step process that was did not do what was intended, I added internally the ability to say "flush right after this publish"
It sets a flag on the message in the queue and when processing that message for the queue, when I see the flag, I flush

So instead of the 2 steps, I now do a publish and set the flag on that message.

This only affects "requests" which is what was originally intended. This does not affect publishing.

@scottf scottf requested a review from MauriceVanVeen August 19, 2024 23:30
* Flushes the underlying connection buffer the next chance it gets if the connection is valid.
* @throws IOException not applicable even though it's part of the signature due to implementation change
* Immediately flushes the underlying connection buffer if the connection is valid.
* @throws IOException the connection flush fails
Copy link
Member

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

*if the connection flush fails

@@ -269,38 +269,41 @@ NatsMessage accumulate(long maxSize, long maxMessages, Duration timeout)
return null;
}

NatsMessage msg = this.poll(timeout);
NatsPublishableMessage msg = (NatsPublishableMessage)this.poll(timeout);
Copy link
Member

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

Is this cast safe, poll(..) returns NatsMessage?

Copy link
Contributor Author

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

I think so because of single reader mode but I will review

@scottf scottf requested a review from MauriceVanVeen August 20, 2024 15:16
@scottf scottf merged commit 7f7caef into main Aug 20, 2024
4 checks passed
@scottf scottf deleted the put-locks-back branch August 20, 2024 19:29
* Flushes the underlying connection buffer the next chance it gets if the connection is valid.
* @throws IOException not applicable even though it's part of the signature due to implementation change
* Immediately flushes the underlying connection buffer if the connection is valid.
* @throws IOException if the connection flush fails
Copy link
Contributor Author

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

This simply reverts the comments back to the original, correct comment.

Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment
Labels
None yet
Projects
None yet
Development

Successfully merging this pull request may close these issues.

2 participants
pFad - Phonifier reborn

Pfad - The Proxy pFad of © 2024 Garber Painting. All rights reserved.

Note: This service is not intended for secure transactions such as banking, social media, email, or purchasing. Use at your own risk. We assume no liability whatsoever for broken pages.


Alternative Proxies:

Alternative Proxy

pFad Proxy

pFad v3 Proxy

pFad v4 Proxy