Module: kamailio
Branch: master
Commit: a0fa8cd663f8fb14b1126aa7e26f96ed16813cd9
URL: 
https://github.com/kamailio/kamailio/commit/a0fa8cd663f8fb14b1126aa7e26f96ed16813cd9

Author: Stefan Mititelu <stefan.mitit...@onem.com>
Committer: Stefan Mititelu <stefan.mitit...@onem.com>
Date: 2017-03-08T13:56:21+02:00

rabbitmq: replace anonymous reply-to queue with 'kamailio-uuid'

In order to better identify reply-to queues, when direct reply-to is not used.
Also rabbitmq is known to be slower, working with anonymous queues.

---

Modified: src/modules/rabbitmq/Makefile
Modified: src/modules/rabbitmq/rabbitmq.c

---

Diff:  
https://github.com/kamailio/kamailio/commit/a0fa8cd663f8fb14b1126aa7e26f96ed16813cd9.diff
Patch: 
https://github.com/kamailio/kamailio/commit/a0fa8cd663f8fb14b1126aa7e26f96ed16813cd9.patch

---

diff --git a/src/modules/rabbitmq/Makefile b/src/modules/rabbitmq/Makefile
index 6980506..b9a839b 100644
--- a/src/modules/rabbitmq/Makefile
+++ b/src/modules/rabbitmq/Makefile
@@ -7,8 +7,8 @@ LIBS=
 
 ifeq ($(CROSS_COMPILE),)
 RMQ_BUILDER=$(shell \
-       if pkg-config --exists librabbitmq; then \
-               echo 'pkg-config librabbitmq'; \
+       if pkg-config --exists librabbitmq && pkg-config --exists uuid; then \
+               echo 'pkg-config librabbitmq uuid'; \
        fi)
 endif
 
@@ -17,7 +17,7 @@ ifneq ($(RMQ_BUILDER),)
        LIBS += $(shell $(RMQ_BUILDER) --libs)
 else
        DEFS+=-I$(LOCALBASE)/include
-       LIBS+=-L$(SYSBASE)/include/lib -L$(LOCALBASE)/lib -lrabbitmq
+       LIBS+=-L$(SYSBASE)/include/lib -L$(LOCALBASE)/lib -lrabbitmq -luuid
 endif
 
 DEFS+=-DKAMAILIO_MOD_INTERFACE
diff --git a/src/modules/rabbitmq/rabbitmq.c b/src/modules/rabbitmq/rabbitmq.c
index af7cb98..ad6c62b 100644
--- a/src/modules/rabbitmq/rabbitmq.c
+++ b/src/modules/rabbitmq/rabbitmq.c
@@ -48,6 +48,7 @@
 #include <stdlib.h>
 #include <stdio.h>
 #include <string.h>
+#include <uuid/uuid.h>
 
 #include <stdint.h>
 #include <amqp_tcp_socket.h>
@@ -289,6 +290,10 @@ static int rabbitmq_publish_consume(struct sip_msg* msg, 
char* in_exchange, char
 
        amqp_queue_declare_ok_t *reply_to;
 
+       uuid_t uuid;
+       char uuid_buffer[40];
+       char reply_to_buffer[64];
+
        // sanity checks
        if (get_str_fparam(&exchange, msg, (fparam_t*)in_exchange) < 0) {
                LM_ERR("failed to get exchange\n");
@@ -347,7 +352,13 @@ static int rabbitmq_publish_consume(struct sip_msg* msg, 
char* in_exchange, char
        if (direct_reply_to == 1) {
                reply_to = amqp_queue_declare(conn, 1, 
amqp_cstring_bytes("amq.rabbitmq.reply-to"), 0, 0, 0, 1, amqp_empty_table);
        } else {
-               reply_to = amqp_queue_declare(conn, 1, amqp_empty_bytes, 0, 0, 
0, 1, amqp_empty_table);
+               uuid_generate_random(uuid);
+               uuid_unparse(uuid, uuid_buffer);
+
+               strcpy(reply_to_buffer, "kamailio-");
+               strcat(reply_to_buffer, uuid_buffer);
+
+               reply_to = amqp_queue_declare(conn, 1, 
amqp_cstring_bytes(reply_to_buffer), 0, 0, 0, 1, amqp_empty_table);
        }
 
        if (log_on_amqp_error(amqp_get_rpc_reply(conn), "amqp_queue_declare()") 
!= AMQP_RESPONSE_NORMAL) {


_______________________________________________
sr-dev mailing list
sr-dev@lists.sip-router.org
http://lists.sip-router.org/cgi-bin/mailman/listinfo/sr-dev

Reply via email to