Subscription to headers exchange via STOMP

999 views
Skip to first unread message

Tim Russell

unread,
May 26, 2015, 5:48:52 PM5/26/15
to rabbitm...@googlegroups.com
Hello,

I'm using RabbitMQ 3.5.1 and attempting to subscribe to a headers exchange with STOMP over a websocket (specifically, using http://jmesnil.net/stomp-websocket/doc/).

var websocket = new SockJS('https://server:15674/stomp');
var stompClient = Stomp.over(websocket);
stompClient
.connect(headers, onConnect, onError);

var subscription = stompClient.subscribe("/exchange/my-event-exchange", function(event) {...}, {'x-match': 'all', abc: 'def', zzz: '124', id: '82979d0c-bc37-4bef-920f-45e99c0c7e43', persistent: true});


A SUBSCRIBE frame is successfully sent, but the filter headers ("abc" and "zzz" here) are essentially ignored.

DEBUG: >>> SUBSCRIBE
abc
:def
zzz
:125
x
-match:all
id
:82979d0c-bc37-4bef-920f-45e99c0c7e43
persistent
:true
destination
:/exchange/my-event-exchange


Instead of receiving only messages that match that pattern, the subscription receives all messages sent to the exchange.

I took a look at the source code that appears to handle this (https://github.com/rabbitmq/rabbitmq-stomp/blob/master/src/rabbit_stomp_processor.erl). I don't have any experience with Erlang, but it appears that line 604 sends the SUBSCRIBE frame without any arguments; I think this is where the filtering arguments would be getting sent if this were to work properly.

Is what I'm attempting currently possible?

Thanks!


Alvaro Videla

unread,
May 27, 2015, 4:02:25 AM5/27/15
to Tim Russell, rabbitm...@googlegroups.com
Hi,

From what I understand from this code: https://github.com/rabbitmq/rabbitmq-stomp/blob/master/src/rabbit_stomp_processor.erl#L606 and the rabbit_ensure_binding/3 function, STOMP doesn't handle header exchange bindings; it only uses bindings with routing keys.


BTW: the subscribe command you see there in the Erlang code is just a queue subscription or "start consuming from a queue", it's not related to bindings.

Regards,

Alvaro

--
You received this message because you are subscribed to the Google Groups "rabbitmq-users" group.
To unsubscribe from this group and stop receiving emails from it, send an email to rabbitmq-user...@googlegroups.com.
To post to this group, send email to rabbitm...@googlegroups.com.
For more options, visit https://groups.google.com/d/optout.

Michael Klishin

unread,
May 27, 2015, 4:04:41 AM5/27/15
to Tim Russell, rabbitm...@googlegroups.com, Alvaro Videla
 On 27 May 2015 at 11:02:25, Alvaro Videla (videl...@gmail.com) wrote:
> From what I understand from this code: https://github.com/rabbitmq/rabbitmq-stomp/blob/master/src/rabbit_stomp_processor.erl#L606
> and the rabbit_ensure_binding/3 function, STOMP doesn't handle
> header exchange bindings; it only uses bindings with routing
> keys.

and for "and" clauses ("x-match": "all"), a headers exchange can be fairly trivially
emulated with a topic one: just concatenate all values with a dot or other URI-safe
separator.
--
MK

Staff Software Engineer, Pivotal/RabbitMQ


Tim Russell

unread,
May 27, 2015, 9:35:44 AM5/27/15
to rabbitm...@googlegroups.com, trus...@starkinvestments.com
Thanks, Alvaro. You're totally right on the subscribe vs. binding. Not sure if you can answer this, but is it fair to say that STOMP precludes header exchange bindings, or is this simply a limitation of the current RabbitMQ STOMP adapter and/or the ensure_binding method?

Tim Russell

unread,
May 27, 2015, 9:43:46 AM5/27/15
to rabbitm...@googlegroups.com, trus...@starkinvestments.com, videl...@gmail.com
Thanks Michael. While I like how explicitly the headers exchange binding keys work (and the fact that, I think, the keys are order-neutral) I may just do this!

Michael Klishin

unread,
May 27, 2015, 9:49:02 AM5/27/15
to Tim Russell, rabbitm...@googlegroups.com
STOMP the protocol assumes topic exchange style routing.

MK

Tim Russell

unread,
May 27, 2015, 9:59:21 AM5/27/15
to rabbitm...@googlegroups.com, trus...@starkinvestments.com
Thanks. Topic exchange it is!
Reply all
Reply to author
Forward
0 new messages