浏览代码

rabbitmq: cleanup obsolete connection parameters

REVERT ME if you really need the old module parameters and are not able to update to 'url'.
Stefan Mititelu 8 年之前
父节点
当前提交
2812b693b0
共有 3 个文件被更改,包括 30 次插入235 次删除
  1. 23 100
      src/modules/rabbitmq/README
  2. 0 111
      src/modules/rabbitmq/doc/rabbitmq_admin.xml
  3. 7 24
      src/modules/rabbitmq/rabbitmq.c

+ 23 - 100
src/modules/rabbitmq/README

@@ -26,14 +26,9 @@ Stefan-Cristian Mititelu
         3. Parameters
         3. Parameters
 
 
               3.1. url (string)
               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
         4. Functions
 
 
@@ -46,16 +41,11 @@ Stefan-Cristian Mititelu
    List of Examples
    List of Examples
 
 
    1.1. Set the “url” parameter
    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
 Chapter 1. Admin Guide
 
 
@@ -70,14 +60,9 @@ Chapter 1. Admin Guide
    3. Parameters
    3. Parameters
 
 
         3.1. url (string)
         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
    4. Functions
 
 
@@ -118,20 +103,13 @@ Chapter 1. Admin Guide
 3. Parameters
 3. Parameters
 
 
    3.1. url (string)
    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)
 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”.
    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
    The timeout in seconds. The timeout_sec + timeout_usec combination
    gives the time to wait for an amqp reply, when
    gives the time to wait for an amqp reply, when
@@ -204,12 +127,12 @@ modparam("rabbitmq", "port", 5672)
 
 
    Default value is “1”.
    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)
 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
    The timeout in micro seconds. The timeout_sec + timeout_usec
    combination gives the time to wait for an amqp reply, when
    combination gives the time to wait for an amqp reply, when
@@ -217,12 +140,12 @@ modparam("rabbitmq", "timeout_sec", 1)
 
 
    Default value is “0”.
    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)
 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.
    Setting this parameter to 1, enables rabbitmq direct reply-to feature.
    More info about this, can be found at
    More info about this, can be found at
@@ -230,7 +153,7 @@ modparam("rabbitmq", "timeout_usec", 0)
 
 
    Default value is “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)
 modparam("rabbitmq", "direct_reply_to", 1)
 ...
 ...
@@ -254,7 +177,7 @@ modparam("rabbitmq", "direct_reply_to", 1)
 
 
    This function can be used from REQUEST_ROUTE.
    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
 rabbitmq_publish("exchange", "routing_key", "application/json", "$avp(json_reque
 st)");
 st)");
 
 
@@ -274,6 +197,6 @@ messagebody, reply)
 
 
    This function can be used from REQUEST_ROUTE.
    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
 rabbitmq_publish_consume("exchange", "routing_key", "application/json", "$avp(js
 on_request)", "$avp(json_reply)");
 on_request)", "$avp(json_reply)");

+ 0 - 111
src/modules/rabbitmq/doc/rabbitmq_admin.xml

@@ -75,7 +75,6 @@
 			<title><varname>url</varname> (string)</title>
 			<title><varname>url</varname> (string)</title>
 			<para>
 			<para>
 				The amqp connection url.
 				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)
 			</para>
 			</para>
 
 
 			<para>
 			<para>
@@ -94,116 +93,6 @@ modparam("rabbitmq", "url", "amqp://kamailio:kamailio@localhost:5672/%2Fkamailio
 			</example>
 			</example>
 		</section>
 		</section>
 
 
-		<section id="rabbitmq.p.username">
-			<title><varname>username</varname> (string)</title>
-			<para>
-				The user name of amqp connection.
-			</para>
-
-			<para>
-				<emphasis>
-					Default value is <quote>"guest"</quote>.
-				</emphasis>
-			</para>
-
-			<example>
-				<title>Set the <quote>username</quote> parameter</title>
-				<programlisting format="linespecific">
-...
-modparam("rabbitmq", "username", "user")
-...
-				</programlisting>
-			</example>
-		</section>
-
-		<section id="rabbitmq.p.password">
-			<title><varname>password</varname> (string)</title>
-			<para>
-				The password of amqp connection.
-			</para>
-
-			<para>
-				<emphasis>
-					Default value is <quote>"guest"</quote>.
-				</emphasis>
-			</para>
-
-			<example>
-				<title>Set the <quote>password</quote> parameter</title>
-				<programlisting format="linespecific">
-...
-modparam("rabbitmq", "password", "pass")
-...
-				</programlisting>
-			</example>
-		</section>
-
-		<section id="rabbitmq.p.host">
-			<title><varname>host</varname> (string)</title>
-			<para>
-				The host of amqp connection.
-			</para>
-
-			<para>
-				<emphasis>
-					Default value is <quote>"localhost"</quote>.
-				</emphasis>
-			</para>
-
-			<example>
-				<title>Set the <quote>host</quote> parameter</title>
-				<programlisting format="linespecific">
-...
-modparam("rabbitmq", "host", "127.0.0.1")
-...
-				</programlisting>
-			</example>
-		</section>
-
-		<section id="rabbitmq.p.vhost">
-			<title><varname>vhost</varname> (string)</title>
-			<para>
-				The vhost of the amqp connection.
-			</para>
-
-			<para>
-				<emphasis>
-					Default value is <quote>"/"</quote>.
-				</emphasis>
-			</para>
-
-			<example>
-				<title>Set the <quote>vhost</quote> parameter</title>
-				<programlisting format="linespecific">
-...
-modparam("rabbitmq", "vhost", "/vhost")
-...
-				</programlisting>
-			</example>
-		</section>
-
-		<section id="rabbitmq.p.port">
-			<title><varname>port</varname> (int)</title>
-			<para>
-				The port of the amqp connection.
-			</para>
-
-			<para>
-				<emphasis>
-					Default value is <quote>5672</quote>.
-				</emphasis>
-			</para>
-
-			<example>
-				<title>Set the <quote>port</quote> parameter</title>
-				<programlisting format="linespecific">
-...
-modparam("rabbitmq", "port", 5672)
-...
-				</programlisting>
-			</example>
-		</section>
-
 		<section id="rabbitmq.p.timeout_sec">
 		<section id="rabbitmq.p.timeout_sec">
 			<title><varname>timeout_sec</varname> (int)</title>
 			<title><varname>timeout_sec</varname> (int)</title>
 			<para>
 			<para>

+ 7 - 24
src/modules/rabbitmq/rabbitmq.c

@@ -72,11 +72,6 @@ amqp_connection_state_t conn = NULL;
 /* module parameters */
 /* module parameters */
 struct amqp_connection_info amqp_info;
 struct amqp_connection_info amqp_info;
 char *amqp_url = RABBITMQ_DEFAULT_AMQP_URL;
 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 max_reconnect_attempts = 1;
 int timeout_sec = 1;
 int timeout_sec = 1;
 int timeout_usec = 0;
 int timeout_usec = 0;
@@ -128,11 +123,6 @@ static cmd_export_t cmds[] = {
 /* module parameters */
 /* module parameters */
 static param_export_t params[] = {
 static param_export_t params[] = {
 	{"url", PARAM_STRING, &amqp_url},
 	{"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_sec", PARAM_INT, &timeout_sec},
 	{"timeout_usec", PARAM_INT, &timeout_usec},
 	{"timeout_usec", PARAM_INT, &timeout_usec},
 	{"direct_reply_to", PARAM_INT, &direct_reply_to},
 	{"direct_reply_to", PARAM_INT, &direct_reply_to},
@@ -155,18 +145,11 @@ struct module_exports exports = {
 /* module init */
 /* module init */
 static int mod_init(void)
 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;
 	return 0;
@@ -539,14 +522,14 @@ static int rabbitmq_connect(amqp_connection_state_t *conn) {
 		return RABBITMQ_ERR_SOCK;
 		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) {
 	if (ret != AMQP_STATUS_OK) {
 		LM_ERR("FAIL: open TCP sock, amqp_status=%d", ret);
 		LM_ERR("FAIL: open TCP sock, amqp_status=%d", ret);
 		// amqp_destroy_connection(*conn);
 		// amqp_destroy_connection(*conn);
 		return RABBITMQ_ERR_SOCK;
 		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) {
 	if (log_ret != AMQP_RESPONSE_NORMAL && log_ret != AMQP_RESPONSE_NONE) {
 		LM_ERR("FAIL: amqp_login()\n");
 		LM_ERR("FAIL: amqp_login()\n");
 		// amqp_destroy_connection(*conn);
 		// amqp_destroy_connection(*conn);