Skip to content
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

[ADD] no responders return the original subject #5250

Open
wants to merge 1 commit into
base: main
Choose a base branch
from

Conversation

ramonberrutti
Copy link
Contributor

Using Request-Reply is very useful.

When using Request with multiple replays, it is difficult to know when the requester loses interest in the replays.
Today, Nats returns an error 503 to the replay subject without any extra information.

Signed-off-by: Ramon Berrutti ramonberrutti@gmail.com

@ramonberrutti ramonberrutti requested a review from a team as a code owner March 26, 2024 21:23
@@ -252,7 +252,7 @@ func TestClientNoResponderSupport(t *testing.T) {
if len(am) == 0 {
t.Fatalf("Did not get a match for %q", l)
}
checkPayload(cr, []byte("NATS/1.0 503\r\n\r\n"), t)
checkPayload(cr, []byte("NATS/1.0 503\r\nNats-Subject: foo\r\n\r\n\r\n"), t)
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'm also checking that the body is empty.

@@ -4051,7 +4051,8 @@ func (c *client) processInboundClientMsg(msg []byte) (bool, bool) {
c.mu.Lock()
if c.opts.NoResponders {
if sub := c.subForReply(c.pa.reply); sub != nil {
proto := fmt.Sprintf("HMSG %s %s 16 16\r\nNATS/1.0 503\r\n\r\n\r\n", c.pa.reply, sub.sid)
hdrLen := 32 /* header without the subject */ + len(c.pa.subject)
proto := fmt.Sprintf("HMSG %s %s %d %d\r\nNATS/1.0 503\r\nNats-Subject: %s\r\n\r\n\r\n", c.pa.reply, sub.sid, hdrLen, hdrLen, c.pa.subject)
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 picked Nats-Subject as the header name because it is used elsewhere.

Copy link
Member

Choose a reason for hiding this comment

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

In that case it means the original subject the current message was published as - not sure we want to use that.

Copy link
Member

Choose a reason for hiding this comment

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

Also the only way you would get this is if you are responding and adding a reply subject - which means that when the server answers with no responders, you know what the reply subject that you published a response to is.

Copy link
Contributor Author

Choose a reason for hiding this comment

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

Why I need the feature:

  • Service A: pub reply to MyService.Endpoint with a _INBOX.
  • Service B: sub to MyService.Endpoint and publish multiple times (grpc server stream) to the client _INBOX.hash with a reply option to MyService.Endpoint.
  • The server tracks each inbox in a hashmap and deletes it when it receives a 503.

To resolve the issue, I'm doing something similar but my service subscribe to MyService.> and setting the reply as: MyService.Endpoint., I also could have two subscriptions, one for MyService.Endpoint and another for MyService.Endpoint.>

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.

None yet

2 participants