Closed PaulGale closed 11 years ago
Accepted. I will post again when I push a fix.
Acceptance retracted, sorry for the previous.
I can recreate this, but the only way to recreate it is to write incorrect/buggy gem client code.
If a connection is at the 1.2 protocol level, using a Stomp::Connection, and I write:
c.subscribe(q, :ack => "client", :id => "gatest1")
m = c.receive
c.ack m.headers['message-id'] # wrong with 1.2!!
that will cause this failure. But for a 1.2 connection the code should be:
c.subscribe(q, :ack => "client", :id => "gatest1")
m = c.receive
c.ack m.headers['ack']
Right now I am thinking this is probably a bug in your client code. Maybe you want something like:
c.subscribe(q, :ack => "client", :id => "gatest1")
m = c.receive
if c.protocol == Stomp::SPL_12
c.ack m.headers['ack']
else
c.ack m.headers['message-id']
end
I can not recreate this at all with a Stomp::Client style connection.
Let me know your thoughts please. Right now I do not think this is a problem with the gem code.
You are correct. It does not appear to be a bug in the gem.
The Stomp connection is being instantiated and managed via our use of ActiveMessaging v0.12.1.
If you look at the code for ActiveMessaging::Adapters::Stomp::Connection#received in https://github.com/kookster/activemessaging/blob/master/lib/activemessaging/adapters/stomp.rb
you can see the bug in their logic.
Thoughts?
So ....... a couple of points, and finally a suggestion for your problem.
First, if I look at the ActiveMessaging code, I think this is incorrect, starting at line 81:
def received message, headers={}
#check to see if the ack mode for this subscription is auto or client
# if the ack mode is client, send an ack
if (headers[:ack] === 'client')
ack_headers = message.headers.has_key?(:transaction) ? { :transaction=>message.headers[:transaction]} : {}
@stomp_connection.ack(message.headers['message-id'], ack_headers) # This is not correct for 1.2 connections
end
end
It is buggy with a 1.2 connection, which you clearly have. I strongly suggest you open an issue with them. Reference this report if needed.
Second, if you do open an issue with them, please point out to them that they are not using the recommended connection invocation. Their connect is:
@stomp_connection = ::Stomp::Connection.new(cfg[:login],cfg[:passcode],cfg[:host],cfg[:port].to_i,cfg[:reliable],cfg[:reconnectDelay], connect_headers)
This is not a hashed parameterized connection, which is recommended. See the gem docs for details on that recommendation.
That lack is not a show stopper with this problem, just one of my pet peeves.
Third, the suggestion ... I am guessing that:
this code, line 31:
connect_headers = cfg[:connect_headers] || {}
somehow triggers a CONNECT header like:
accept-version:1.0,1.1,1.2
Of course AMQ 5.8.0 comes back with 1.2. That is per the spec. And it is what triggers your immediate problem.
Can you influence that? Can you somehow influence the 'cfg' hash so that it triggers accepted versions such that they are only:
accept-version:1.0,1.1
I think that should get you through your immediate problem.
As always, let me know your thoughts please.
Many thanks for this report. I actually did not realize that AMQ 5.8 supported (in theory) Stomp 1.2. My test beds have been updated to reflect that.
And the bottom line is: this is not a bug in the stomp gem.
Regards, Guy
Closing this here. Fix needs to be corrected in ActiveMessaging, per above.
ActiveMQ 5.8.0 with 1.2.10 of the gem:
In the STOMP log output below, the
ACK
message has itsid
header incorrectly populated with the value of theMESSAGE
'smessage-id
header. It should, however, populate theid
header using the value of theMESSAGE
'sack
header, given that theack
mode on the subscription is set toclient
.As a result ActiveMQ rejects the
ACK
with theERROR
frame shown.According to the STOMP spec the same behavior is expected when the
ack
mode is set toclient-individual
(not verified).