Module: kamailio
Branch: master
Commit: 36b6d4d211d86a0f4047a79cf3b122ad974a5da9
URL:
https://github.com/kamailio/kamailio/commit/36b6d4d211d86a0f4047a79cf3b122a…
Author: Luis Azedo <luis(a)2600hz.com>
Committer: lazedo <luis.azedo(a)factorlusitano.com>
Date: 2017-04-05T23:34:21+01:00
kazoo : add broker zone to received payload
---
Modified: src/modules/kazoo/defs.h
Modified: src/modules/kazoo/kz_amqp.c
---
Diff:
https://github.com/kamailio/kamailio/commit/36b6d4d211d86a0f4047a79cf3b122a…
Patch:
https://github.com/kamailio/kamailio/commit/36b6d4d211d86a0f4047a79cf3b122a…
---
diff --git a/src/modules/kazoo/defs.h b/src/modules/kazoo/defs.h
index ab23fba..ca355f5 100644
--- a/src/modules/kazoo/defs.h
+++ b/src/modules/kazoo/defs.h
@@ -57,6 +57,7 @@
#define BLF_JSON_TYPE "Type"
#define BLF_JSON_MSG_ID "Msg-ID"
#define BLF_JSON_DIRECTION "Direction"
+#define BLF_JSON_BROKER_ZONE "AMQP-Broker-Zone"
#define BLF_JSON_CONTACT "Contact"
#define BLF_JSON_EVENT_PKG "Event-Package"
diff --git a/src/modules/kazoo/kz_amqp.c b/src/modules/kazoo/kz_amqp.c
index 05e8407..8bbbcd8 100644
--- a/src/modules/kazoo/kz_amqp.c
+++ b/src/modules/kazoo/kz_amqp.c
@@ -2571,7 +2571,7 @@ void kz_send_targeted_cmd(int server_id, amqp_bytes_t body)
}
-void kz_amqp_send_worker_event(int _kz_server_id, amqp_envelope_t* envelope,
kz_amqp_bind_ptr bind)
+void kz_amqp_send_worker_event(kz_amqp_server_ptr server_ptr, amqp_envelope_t* envelope,
kz_amqp_bind_ptr bind)
{
char buffer[100];
kz_amqp_cmd_ptr cmd = NULL;
@@ -2579,6 +2579,7 @@ void kz_amqp_send_worker_event(int _kz_server_id, amqp_envelope_t*
envelope, kz_
str* message_id = NULL;
int idx = envelope->channel-1;
int worker = 0;
+ int _kz_server_id = server_ptr->id;
json_obj_ptr json_obj = kz_json_parse((char*)envelope->message.body.bytes);
if (json_obj == NULL) {
@@ -2594,6 +2595,8 @@ void kz_amqp_send_worker_event(int _kz_server_id, amqp_envelope_t*
envelope, kz_
json_object_object_add(json_obj, BLF_JSON_SERVERID,
json_object_new_string(buffer));
}
+ json_object_object_add(json_obj, BLF_JSON_BROKER_ZONE,
json_object_new_string(server_ptr->zone->zone));
+
JObj = kz_json_get_object(json_obj, BLF_JSON_MSG_ID);
if(JObj != NULL) {
message_id = kz_str_dup_from_char((char*)json_object_get_string(JObj));
@@ -2762,7 +2765,7 @@ int kz_amqp_consumer_proc(kz_amqp_server_ptr server_ptr)
case AMQP_RESPONSE_NORMAL:
idx = envelope.channel-1;
if(idx < channel_base) {
- kz_amqp_send_worker_event(server_ptr->id, &envelope, NULL);
+ kz_amqp_send_worker_event(server_ptr, &envelope, NULL);
} else {
idx = idx - channel_base;
if(!consumer_channels[idx].consumer->no_ack ) {
@@ -2772,7 +2775,7 @@ int kz_amqp_consumer_proc(kz_amqp_server_ptr server_ptr)
}
}
if(OK)
- kz_amqp_send_worker_event(server_ptr->id, &envelope,
consumer_channels[idx].consumer);
+ kz_amqp_send_worker_event(server_ptr, &envelope,
consumer_channels[idx].consumer);
}
break;
case AMQP_RESPONSE_SERVER_EXCEPTION: