Ignore:
Timestamp:
11/22/13 12:34:25 (11 years ago)
Author:
jripsl
Message:
  • switch routing behaviour (switch exchange type from "fanout" to "direct" to use routing key).
File:
1 edited

Legend:

Unmodified
Added
Removed
  • trunk/Monitoring/CNClient/send_AMQP_msg.c

    r962 r971  
    365365  die_on_amqp_error(amqp_get_rpc_reply(conn), "Opening channel"); 
    366366 
    367   amqp_exchange_declare(conn, 1, amqp_cstring_bytes("myexchange"), amqp_cstring_bytes("fanout"), 0, 0, amqp_empty_table); 
     367  //amqp_exchange_declare(conn, 1, amqp_cstring_bytes("myexchange"), amqp_cstring_bytes("fanout"), 0, 0, amqp_empty_table); // fanout exchange (i.e. without routing key) 
     368  amqp_exchange_declare(conn, 1, amqp_cstring_bytes("myexchange"), amqp_cstring_bytes("direct"), 0, 0, amqp_empty_table); // direct exchange (i.e. to be used with routing key) 
    368369  die_on_amqp_error(amqp_get_rpc_reply(conn), "Declaring exchange"); 
    369370 
     
    371372  die_on_amqp_error(amqp_get_rpc_reply(conn), "Declaring queue"); 
    372373 
    373   amqp_queue_bind(conn, 1, amqp_cstring_bytes("myqueue"), amqp_cstring_bytes("myexchange"), amqp_cstring_bytes(""), amqp_empty_table); //no need for binding key as we use the fanout exchange type 
     374  //amqp_queue_bind(conn, 1, amqp_cstring_bytes("myqueue"), amqp_cstring_bytes("myexchange"), amqp_cstring_bytes(""), amqp_empty_table); //no need for binding key as we use the fanout exchange type 
     375  amqp_queue_bind(conn, 1, amqp_cstring_bytes("myqueue"), amqp_cstring_bytes("myexchange"), amqp_cstring_bytes("myroutingkey"), amqp_empty_table);   //we use a binding key here as we use the direct exchange type 
    374376  die_on_amqp_error(amqp_get_rpc_reply(conn), "Binding"); 
    375377 
     
    382384 
    383385    for (i = 0; i < msg_count; i++) 
    384       die_on_error(amqp_basic_publish(conn, 1, amqp_cstring_bytes("myexchange"), amqp_cstring_bytes(""), 0, 0, &props, amqp_cstring_bytes(body)), "Publishing"); 
     386      die_on_error(amqp_basic_publish(conn, 1, amqp_cstring_bytes("myexchange"), amqp_cstring_bytes("myroutingkey"), 0, 0, &props, amqp_cstring_bytes(body)), "Publishing"); 
    385387  } 
    386388 
Note: See TracChangeset for help on using the changeset viewer.