Erlang/OTP Forums

Author Message

<  RabbitMQ mailing list  ~  Patch to support amq.topic in STOMP adaptor

Guest
Posted: Thu Jun 12, 2008 3:41 pm Reply with quote
Guest
Hi,

This lets you put in exchange to a subscribe and thus start listening
to an amq.topic

Also, the arguments field to the queue.bind is a bit cargo culted
(this is my first piece of erlang code ever Smile.

Sorry of the tab/space level is wrong!

Cheers
Artur




--- rabbit_stomp.erl.bak 2008-06-11 09:42:29.000000000 +0000
+++ rabbit_stomp.erl 2008-06-11 11:41:54.000000000 +0000
@@ -468,6 +468,7 @@
list_to_binary("Q_" ++ QueueStr)
end,
Queue = list_to_binary(QueueStr),
+
{ok, send_method(#'basic.consume'{ticket = Ticket,
queue = Queue,
consumer_tag =
ConsumerTag,
@@ -475,6 +476,32 @@
no_ack = (AckMode ==
auto),
exclusive = false,
nowait = true},
+ case stomp_frame:header(Frame, "exchange") of
+ {ok, ExchangeStr } ->
+ Exchange = list_to_binary(ExchangeStr),
+ RoutingKey = list_to_binary
(stomp_frame:header(Frame, "routing_key","")),
+ send_method(#'queue.bind'{ticket =
Ticket,
+ queue =
Queue,
+ exchange =
Exchange,
+ routing_key
= RoutingKey,
+ nowait = true,
+ arguments =
+
make_string_table(fun user_header_key/1,
+
Headers)
+ },
+
+ send_method
(#'queue.declare'{ticket = Ticket,
+
queue = Queue,
+
passive = stomp_frame:boolean_header(Frame, "passive", false),
+
durable = stomp_frame:boolean_header(Frame, "durable", false),
+
exclusive = stomp_frame:boolean_header(Frame, "exclusive", false),
+
auto_delete = stomp_frame:boolean_header(Frame, "auto-delete",
true),
+
nowait = true,
+
arguments =
+
make_string_table(fun user_header_key/1,
+
Headers)},
+ State));
+ not_found ->
send_method(#'queue.declare'{ticket =
Ticket,
queue =
Queue,
passive =
stomp_frame:boolean_header(Frame, "passive", false),
@@ -485,7 +512,9 @@
arguments =

make_string_table(fun user_header_key/1,

Headers)},
- State))};
+ State)
+ end
+ )};
not_found ->
{ok, send_error("Missing destination",
"SUBSCRIBE must include a 'destination'
header\n",


_______________________________________________
rabbitmq-discuss mailing list
rabbitmq-discuss@lists.rabbitmq.com
http://lists.rabbitmq.com/cgi-bin/mailman/listinfo/rabbitmq-discuss
Post received from mailinglist
tonyg
Posted: Mon Jun 16, 2008 3:49 pm Reply with quote
User Joined: 07 Nov 2006 Posts: 199
Hi Artur,

Thanks for the patch! It's a useful feature.

I've applied something that captures the essence of your enhancement,
with a few minor differences:

- I've made the threading of State more visible

- I've changed the headers used to feed the "arguments" for
both queue.declare and queue.bind to "X-Q-"prefixed and
"X-B-"prefixed, respectively, rather than simply "X-"prefixed.

The change is present in Mercurial on both 'default' and
'rabbitmq_v1_3_0_branch' branches. Let me know if it works for you.


I have one question for you and the group at large - the new code
supports *exactly one* binding between an exchange and the
destination-queue. AMQP supports zero or more. How should we expose this
as STOMP headers?

We could have multiple "bind" headers, containing "exchange,routingkey"
or similar; the problem then is what happens when an exchange name
contains a comma (or other delimiter).

If we're going to have to solve the escaping-of-delimiters problem
anyway - and it looks like we are, if we want this multiple-bind feature
- then we may as well have *two* kinds of delimiter, for a single "bind"
header of the form

bind: exchange1,routingkeypattern1;exchange2,routingkeypattern2;...

Yuck. Any thoughts?

(Backslash-escaping? Gross, but viable?)


Regards,
Tony
--
[][][] Tony Garnock-Jones | Mob: +44 (0)7905 974 211
[][] LShift Ltd | Tel: +44 (0)20 7729 7060
[] [] http://www.lshift.net/ | Email: tonyg@lshift.net

_______________________________________________
rabbitmq-discuss mailing list
rabbitmq-discuss@lists.rabbitmq.com
http://lists.rabbitmq.com/cgi-bin/mailman/listinfo/rabbitmq-discuss
Post received from mailinglist
View user's profile Send private message MSN Messenger

Display posts from previous:  

All times are GMT
Page 1 of 1
This forum is locked: you cannot post, reply to, or edit topics.

Jump to:  

You cannot post new topics in this forum
You cannot reply to topics in this forum
You cannot edit your posts in this forum
You cannot delete your posts in this forum
You cannot vote in polls in this forum
You cannot attach files in this forum
You cannot download files in this forum