From 2812b693b0ef97e3d720ff0b8a2982eeae566d71 Mon Sep 17 00:00:00 2001 From: Stefan Mititelu Date: Thu, 9 Mar 2017 10:33:28 +0200 Subject: [PATCH] rabbitmq: cleanup obsolete connection parameters REVERT ME if you really need the old module parameters and are not able to update to 'url'. --- src/modules/rabbitmq/README | 123 ++++---------------- src/modules/rabbitmq/doc/rabbitmq_admin.xml | 111 ------------------ src/modules/rabbitmq/rabbitmq.c | 31 ++--- 3 files changed, 30 insertions(+), 235 deletions(-) diff --git a/src/modules/rabbitmq/README b/src/modules/rabbitmq/README index 2199e8e9d5f..30b662d2b19 100644 --- a/src/modules/rabbitmq/README +++ b/src/modules/rabbitmq/README @@ -26,14 +26,9 @@ Stefan-Cristian Mititelu 3. Parameters 3.1. url (string) - 3.2. username (string) - 3.3. password (string) - 3.4. host (string) - 3.5. vhost (string) - 3.6. port (int) - 3.7. timeout_sec (int) - 3.8. timeout_usec (int) - 3.9. direct_reply_to (int) + 3.2. timeout_sec (int) + 3.3. timeout_usec (int) + 3.4. direct_reply_to (int) 4. Functions @@ -46,16 +41,11 @@ Stefan-Cristian Mititelu List of Examples 1.1. Set the “url” parameter - 1.2. Set the “username” parameter - 1.3. Set the “password” parameter - 1.4. Set the “host” parameter - 1.5. Set the “vhost” parameter - 1.6. Set the “port” parameter - 1.7. Set the “timeout_sec” parameter - 1.8. Set the “timeout_usec” parameter - 1.9. Set the “direct_reply_to” parameter - 1.10. rabbitmq_publish usage - 1.11. rabbitmq_publish_consume usage + 1.2. Set the “timeout_sec” parameter + 1.3. Set the “timeout_usec” parameter + 1.4. Set the “direct_reply_to” parameter + 1.5. rabbitmq_publish usage + 1.6. rabbitmq_publish_consume usage Chapter 1. Admin Guide @@ -70,14 +60,9 @@ Chapter 1. Admin Guide 3. Parameters 3.1. url (string) - 3.2. username (string) - 3.3. password (string) - 3.4. host (string) - 3.5. vhost (string) - 3.6. port (int) - 3.7. timeout_sec (int) - 3.8. timeout_usec (int) - 3.9. direct_reply_to (int) + 3.2. timeout_sec (int) + 3.3. timeout_usec (int) + 3.4. direct_reply_to (int) 4. Functions @@ -118,20 +103,13 @@ Chapter 1. Admin Guide 3. Parameters 3.1. url (string) - 3.2. username (string) - 3.3. password (string) - 3.4. host (string) - 3.5. vhost (string) - 3.6. port (int) - 3.7. timeout_sec (int) - 3.8. timeout_usec (int) - 3.9. direct_reply_to (int) + 3.2. timeout_sec (int) + 3.3. timeout_usec (int) + 3.4. direct_reply_to (int) 3.1. url (string) - The amqp connection url. If set to something else than the default - value, it will overwrite the values of all connection parameters below - (e.g. username, password, host, vhost, port) + The amqp connection url. Default value is “amqp://guest:guest@localhost:5672/%2F”. @@ -141,62 +119,7 @@ modparam("rabbitmq", "url", "amqp://kamailio:kamailio@localhost:5672/%2Fkamailio ") ... -3.2. username (string) - - The user name of amqp connection. - - Default value is “"guest"”. - - Example 1.2. Set the “username” parameter -... -modparam("rabbitmq", "username", "user") -... - -3.3. password (string) - - The password of amqp connection. - - Default value is “"guest"”. - - Example 1.3. Set the “password” parameter -... -modparam("rabbitmq", "password", "pass") -... - -3.4. host (string) - - The host of amqp connection. - - Default value is “"localhost"”. - - Example 1.4. Set the “host” parameter -... -modparam("rabbitmq", "host", "127.0.0.1") -... - -3.5. vhost (string) - - The vhost of the amqp connection. - - Default value is “"/"”. - - Example 1.5. Set the “vhost” parameter -... -modparam("rabbitmq", "vhost", "/vhost") -... - -3.6. port (int) - - The port of the amqp connection. - - Default value is “5672”. - - Example 1.6. Set the “port” parameter -... -modparam("rabbitmq", "port", 5672) -... - -3.7. timeout_sec (int) +3.2. timeout_sec (int) The timeout in seconds. The timeout_sec + timeout_usec combination gives the time to wait for an amqp reply, when @@ -204,12 +127,12 @@ modparam("rabbitmq", "port", 5672) Default value is “1”. - Example 1.7. Set the “timeout_sec” parameter + Example 1.2. Set the “timeout_sec” parameter ... modparam("rabbitmq", "timeout_sec", 1) ... -3.8. timeout_usec (int) +3.3. timeout_usec (int) The timeout in micro seconds. The timeout_sec + timeout_usec combination gives the time to wait for an amqp reply, when @@ -217,12 +140,12 @@ modparam("rabbitmq", "timeout_sec", 1) Default value is “0”. - Example 1.8. Set the “timeout_usec” parameter + Example 1.3. Set the “timeout_usec” parameter ... modparam("rabbitmq", "timeout_usec", 0) ... -3.9. direct_reply_to (int) +3.4. direct_reply_to (int) Setting this parameter to 1, enables rabbitmq direct reply-to feature. More info about this, can be found at @@ -230,7 +153,7 @@ modparam("rabbitmq", "timeout_usec", 0) Default value is “0”. - Example 1.9. Set the “direct_reply_to” parameter + Example 1.4. Set the “direct_reply_to” parameter ... modparam("rabbitmq", "direct_reply_to", 1) ... @@ -254,7 +177,7 @@ modparam("rabbitmq", "direct_reply_to", 1) This function can be used from REQUEST_ROUTE. - Example 1.10. rabbitmq_publish usage + Example 1.5. rabbitmq_publish usage rabbitmq_publish("exchange", "routing_key", "application/json", "$avp(json_reque st)"); @@ -274,6 +197,6 @@ messagebody, reply) This function can be used from REQUEST_ROUTE. - Example 1.11. rabbitmq_publish_consume usage + Example 1.6. rabbitmq_publish_consume usage rabbitmq_publish_consume("exchange", "routing_key", "application/json", "$avp(js on_request)", "$avp(json_reply)"); diff --git a/src/modules/rabbitmq/doc/rabbitmq_admin.xml b/src/modules/rabbitmq/doc/rabbitmq_admin.xml index 373138b73bc..24f9275131f 100644 --- a/src/modules/rabbitmq/doc/rabbitmq_admin.xml +++ b/src/modules/rabbitmq/doc/rabbitmq_admin.xml @@ -75,7 +75,6 @@ <varname>url</varname> (string) The amqp connection url. - If set to something else than the default value, it will overwrite the values of all connection parameters below (e.g. username, password, host, vhost, port) @@ -94,116 +93,6 @@ modparam("rabbitmq", "url", "amqp://kamailio:kamailio@localhost:5672/%2Fkamailio -
- <varname>username</varname> (string) - - The user name of amqp connection. - - - - - Default value is "guest". - - - - - Set the <quote>username</quote> parameter - -... -modparam("rabbitmq", "username", "user") -... - - -
- -
- <varname>password</varname> (string) - - The password of amqp connection. - - - - - Default value is "guest". - - - - - Set the <quote>password</quote> parameter - -... -modparam("rabbitmq", "password", "pass") -... - - -
- -
- <varname>host</varname> (string) - - The host of amqp connection. - - - - - Default value is "localhost". - - - - - Set the <quote>host</quote> parameter - -... -modparam("rabbitmq", "host", "127.0.0.1") -... - - -
- -
- <varname>vhost</varname> (string) - - The vhost of the amqp connection. - - - - - Default value is "/". - - - - - Set the <quote>vhost</quote> parameter - -... -modparam("rabbitmq", "vhost", "/vhost") -... - - -
- -
- <varname>port</varname> (int) - - The port of the amqp connection. - - - - - Default value is 5672. - - - - - Set the <quote>port</quote> parameter - -... -modparam("rabbitmq", "port", 5672) -... - - -
-
<varname>timeout_sec</varname> (int) diff --git a/src/modules/rabbitmq/rabbitmq.c b/src/modules/rabbitmq/rabbitmq.c index 96194d7775d..7f9fc12ce07 100644 --- a/src/modules/rabbitmq/rabbitmq.c +++ b/src/modules/rabbitmq/rabbitmq.c @@ -72,11 +72,6 @@ amqp_connection_state_t conn = NULL; /* module parameters */ struct amqp_connection_info amqp_info; char *amqp_url = RABBITMQ_DEFAULT_AMQP_URL; -char *amqp_username = "guest"; -char *amqp_password = "guest"; -char *amqp_host = "localhost"; -char *amqp_vhost = "/"; -int amqp_port = 5672; int max_reconnect_attempts = 1; int timeout_sec = 1; int timeout_usec = 0; @@ -128,11 +123,6 @@ static cmd_export_t cmds[] = { /* module parameters */ static param_export_t params[] = { {"url", PARAM_STRING, &amqp_url}, - {"username", PARAM_STRING, &amqp_username}, - {"password", PARAM_STRING, &amqp_password}, - {"host", PARAM_STRING, &amqp_host}, - {"vhost", PARAM_STRING, &amqp_vhost}, - {"port", PARAM_INT, &amqp_port}, {"timeout_sec", PARAM_INT, &timeout_sec}, {"timeout_usec", PARAM_INT, &timeout_usec}, {"direct_reply_to", PARAM_INT, &direct_reply_to}, @@ -155,18 +145,11 @@ struct module_exports exports = { /* module init */ static int mod_init(void) { - if (strcmp(amqp_url, RABBITMQ_DEFAULT_AMQP_URL)) { - if (amqp_parse_url(amqp_url, &amqp_info) == AMQP_STATUS_BAD_URL) { - LM_ERR("FAIL parsing url: '%s'\n", amqp_url); - return -1; - } else { - LM_INFO("SUCCESS parsing url: '%s'\n", amqp_url); - amqp_username = amqp_info.user; - amqp_password = amqp_info.password; - amqp_host = amqp_info.host; - amqp_vhost = amqp_info.vhost; - amqp_port = amqp_info.port; - } + if (amqp_parse_url(amqp_url, &amqp_info) == AMQP_STATUS_BAD_URL) { + LM_ERR("FAIL parsing url: '%s'\n", amqp_url); + return -1; + } else { + LM_INFO("SUCCESS parsing url: '%s'\n", amqp_url); } return 0; @@ -539,14 +522,14 @@ static int rabbitmq_connect(amqp_connection_state_t *conn) { return RABBITMQ_ERR_SOCK; } - ret = amqp_socket_open(amqp_sock, amqp_host, amqp_port); + ret = amqp_socket_open(amqp_sock, amqp_info.host, amqp_info.port); if (ret != AMQP_STATUS_OK) { LM_ERR("FAIL: open TCP sock, amqp_status=%d", ret); // amqp_destroy_connection(*conn); return RABBITMQ_ERR_SOCK; } - log_ret = log_on_amqp_error(amqp_login(*conn, amqp_vhost, 0, 131072, 0, AMQP_SASL_METHOD_PLAIN, amqp_username, amqp_password), "amqp_login()"); + log_ret = log_on_amqp_error(amqp_login(*conn, amqp_info.vhost, 0, 131072, 0, AMQP_SASL_METHOD_PLAIN, amqp_info.user, amqp_info.password), "amqp_login()"); if (log_ret != AMQP_RESPONSE_NORMAL && log_ret != AMQP_RESPONSE_NONE) { LM_ERR("FAIL: amqp_login()\n"); // amqp_destroy_connection(*conn);