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

fix incorrect header for message id in ACK frames #118

Merged
merged 1 commit into from
Mar 21, 2022
Merged
Show file tree
Hide file tree
Changes from all commits
Commits
File filter

Filter by extension

Filter by extension

Conversations
Failed to load comments.
Loading
Jump to
Jump to file
Failed to load files.
Loading
Diff view
Diff view
4 changes: 2 additions & 2 deletions conn.go
Original file line number Diff line number Diff line change
Expand Up @@ -750,10 +750,10 @@ func (c *Conn) createAckNackFrame(msg *Message, ack bool) (*frame.Frame, error)
return nil, missingHeader(frame.MessageId)
}
case V12:
if ack, ok := msg.Header.Contains(frame.Ack); ok {
if ack, ok := msg.Header.Contains(frame.Id); ok {
f.Header.Add(frame.Id, ack)
} else {
return nil, missingHeader(frame.Ack)
return nil, missingHeader(frame.Id)
}
}

Expand Down
4 changes: 2 additions & 2 deletions conn_test.go
Original file line number Diff line number Diff line change
Expand Up @@ -354,7 +354,7 @@ func subscribeHelper(c *C, ackMode AckMode, version Version, opts ...func(*frame
frame.MessageId, messageId,
frame.Destination, destination)
if version == V12 {
f4.Header.Add(frame.Ack, messageId)
f4.Header.Add(frame.Id, messageId)
}
f4.Body = []byte(bodyText)
err = rw.Write(f4)
Expand Down Expand Up @@ -461,7 +461,7 @@ func subscribeTransactionHelper(c *C, ackMode AckMode, version Version, abort bo
frame.MessageId, messageId,
frame.Destination, destination)
if version == V12 {
f4.Header.Add(frame.Ack, messageId)
f4.Header.Add(frame.Id, messageId)
}
f4.Body = []byte(bodyText)
err = rw.Write(f4)
Expand Down
8 changes: 4 additions & 4 deletions server/client/conn.go
Original file line number Diff line number Diff line change
Expand Up @@ -415,9 +415,9 @@ func (c *Conn) allocateMessageId(f *frame.Frame, sub *Subscription) {
// if there is any requirement by the client to acknowledge, set
// the ack header as per STOMP 1.2
if sub == nil || sub.ack == frame.AckAuto {
f.Header.Del(frame.Ack)
f.Header.Del(frame.Id)
} else {
f.Header.Set(frame.Ack, messageId)
f.Header.Set(frame.Id, messageId)
Copy link

Choose a reason for hiding this comment

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

@Delorus @worg

It is my understanding that only ACK frames should use the id header. This MESSAGE frame should still use ack header. https://stomp.github.io/stomp-specification-1.2.html#MESSAGE

Or am I mistaken ?

Copy link
Author

Choose a reason for hiding this comment

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

@dselim you're right, sorry my bad 😔

Copy link

Choose a reason for hiding this comment

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

no worries!

}
}
}
Expand Down Expand Up @@ -659,7 +659,7 @@ func (c *Conn) handleAck(f *frame.Frame) error {
var err error
var msgId string

if ack, ok := f.Header.Contains(frame.Ack); ok {
if ack, ok := f.Header.Contains(frame.Id); ok {
msgId = ack
} else if msgId, ok = f.Header.Contains(frame.MessageId); !ok {
return missingHeader(frame.MessageId)
Expand Down Expand Up @@ -702,7 +702,7 @@ func (c *Conn) handleNack(f *frame.Frame) error {
var err error
var msgId string

if ack, ok := f.Header.Contains(frame.Ack); ok {
if ack, ok := f.Header.Contains(frame.Id); ok {
msgId = ack
} else if msgId, ok = f.Header.Contains(frame.MessageId); !ok {
return missingHeader(frame.MessageId)
Expand Down