-
-
Notifications
You must be signed in to change notification settings - Fork 1.4k
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
base: main
Are you sure you want to change the base?
[ADD] no responders return the original subject #5250
Conversation
@@ -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) |
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'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) |
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 picked Nats-Subject as the header name because it is used elsewhere.
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.
In that case it means the original subject the current message was published as - not sure we want to use that.
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.
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.
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.
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.>
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 [email protected]