[rabbitmq-discuss] Patch to support amq.topic in STOMP adaptor

Artur Bergman sky at crucially.net
Thu Jun 12 16:40:27 BST 2008


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 :).

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",





More information about the rabbitmq-discuss mailing list