]> git.ipfire.org Git - thirdparty/freeswitch.git/commitdiff
FS-10430: [mod_amqp] add support for libamqp >= 0.5.2
authorMike Jerris <mike@jerris.com>
Tue, 27 Jun 2017 21:42:45 +0000 (16:42 -0500)
committerroot <root@debian9.tollfreegateway.com>
Tue, 27 Jun 2017 21:42:45 +0000 (16:42 -0500)
src/mod/event_handlers/mod_amqp/mod_amqp_command.c
src/mod/event_handlers/mod_amqp/mod_amqp_logging.c
src/mod/event_handlers/mod_amqp/mod_amqp_producer.c

index 3d54bb69c57044afe4b148a79bb6ce7a4d65a715..3efd97cc38bb547579ca3fc8aa8b6e07fb459ee2 100644 (file)
@@ -280,12 +280,23 @@ void * SWITCH_THREAD_FUNC mod_amqp_command_thread(switch_thread_t *thread, void
                        }
 
                        /* Check if exchange already exists */
+#if AMQP_VERSION_MAJOR == 0 && (AMQP_VERSION_MINOR > 5 || (AMQP_VERSION_MINOR == 5 && AMQP_VERSION_PATCH >= 2 ))
+                       amqp_exchange_declare(profile->conn_active->state, 1,
+                                                                 amqp_cstring_bytes(profile->exchange),
+                                                                 amqp_cstring_bytes("topic"),
+                                                                 0, /* passive */
+                                                                 1, /* durable */
+                                                                 0, /* auto-delete */
+                                                                 0,
+                                                                 amqp_empty_table);
+#else
                        amqp_exchange_declare(profile->conn_active->state, 1,
                                                                  amqp_cstring_bytes(profile->exchange),
                                                                  amqp_cstring_bytes("topic"),
                                                                  0, /* passive */
                                                                  1, /* durable */
                                                                  amqp_empty_table);
+#endif
 
                        if (mod_amqp_log_if_amqp_error(amqp_get_rpc_reply(profile->conn_active->state), "Checking for command exchange")) {
                                switch_log_printf(SWITCH_CHANNEL_LOG, SWITCH_LOG_WARNING, "Profile[%s] failed to create missing command exchange", profile->name);
index f2449a89942d1aa88897e0f7bc4b95d37f7662e7..0085c99ddd385c79895ef58c9484c2b3890d9667 100644 (file)
@@ -244,12 +244,23 @@ switch_status_t mod_amqp_logging_create(char *name, switch_xml_t cfg)
                goto err;
        }
 
+#if AMQP_VERSION_MAJOR == 0 && (AMQP_VERSION_MINOR > 5 || (AMQP_VERSION_MINOR == 5 && AMQP_VERSION_PATCH >= 2 ))
        amqp_exchange_declare(profile->conn_active->state, 1,
                                                  amqp_cstring_bytes(profile->exchange),
                                                  amqp_cstring_bytes(profile->exchange_type),
                                                  0, /* passive */
                                                  profile->exchange_durable,
+                                                 profile->exchange_auto_delete,
+                                                 0,
                                                  amqp_empty_table);
+#else
+       amqp_exchange_declare(profile->conn_active->state, 1,
+                                                 amqp_cstring_bytes(profile->exchange),
+                                                 amqp_cstring_bytes(profile->exchange_type),
+                                                 0, /* passive */
+                                                 profile->exchange_durable,
+                                                 amqp_empty_table);
+#endif
 
        if (mod_amqp_log_if_amqp_error(amqp_get_rpc_reply(profile->conn_active->state), "Declaring exchange")) {
                switch_log_printf(SWITCH_CHANNEL_LOG, SWITCH_LOG_ERROR, "Profile[%s] failed to create exchange\n", profile->name);
@@ -341,13 +352,24 @@ void * SWITCH_THREAD_FUNC mod_amqp_logging_thread(switch_thread_t *thread, void
 
       status = mod_amqp_connection_open(profile->conn_root, &(profile->conn_active), profile->name, profile->custom_attr);
       if ( status      == SWITCH_STATUS_SUCCESS ) {
-       // Ensure that the exchange exists, and is of the correct type
-       amqp_exchange_declare(profile->conn_active->state, 1,
-                             amqp_cstring_bytes(profile->exchange),
-                             amqp_cstring_bytes(profile->exchange_type),
-                             passive,
-                             durable,
-                             amqp_empty_table);
+                 // Ensure that the exchange exists, and is of the correct type
+#if AMQP_VERSION_MAJOR == 0 && (AMQP_VERSION_MINOR > 5 || (AMQP_VERSION_MINOR == 5 && AMQP_VERSION_PATCH >= 2 ))
+                 amqp_exchange_declare(profile->conn_active->state, 1,
+                                                               amqp_cstring_bytes(profile->exchange),
+                                                               amqp_cstring_bytes(profile->exchange_type),
+                                                               passive,
+                                                               durable,
+                                                               profile->exchange_auto_delete,
+                                                               0,
+                                                               amqp_empty_table);
+#else            
+                 amqp_exchange_declare(profile->conn_active->state, 1,
+                                                               amqp_cstring_bytes(profile->exchange),
+                                                               amqp_cstring_bytes(profile->exchange_type),
+                                                               passive,
+                                                               durable,
+                                                               amqp_empty_table);
+#endif
 
        if (!mod_amqp_log_if_amqp_error(amqp_get_rpc_reply(profile->conn_active->state), "Declaring exchange")) {
          switch_log_printf(SWITCH_CHANNEL_LOG, SWITCH_LOG_INFO, "Amqp reconnect successful- connected\n");
index 99c439f57ac2c1488c43ead5a05bb4c0fa38c823..d74776f564e79a6c57523ee79e768de056ce027e 100644 (file)
@@ -325,13 +325,23 @@ switch_status_t mod_amqp_producer_create(char *name, switch_xml_t cfg)
                switch_log_printf(SWITCH_CHANNEL_LOG, SWITCH_LOG_ERROR, "Profile[%s] was unable to connect to any connection\n", profile->name);
                goto err;
        }
-
+#if AMQP_VERSION_MAJOR == 0 && (AMQP_VERSION_MINOR > 5 || (AMQP_VERSION_MINOR == 5 && AMQP_VERSION_PATCH >= 2 ))
+       amqp_exchange_declare(profile->conn_active->state, 1,
+                                                 amqp_cstring_bytes(profile->exchange),
+                                                 amqp_cstring_bytes(profile->exchange_type),
+                                                 0, /* passive */
+                                                 profile->exchange_durable,
+                                                 profile->exchange_auto_delete,
+                                                 0,
+                                                 amqp_empty_table);
+#else
        amqp_exchange_declare(profile->conn_active->state, 1,
                                                  amqp_cstring_bytes(profile->exchange),
                                                  amqp_cstring_bytes(profile->exchange_type),
                                                  0, /* passive */
                                                  profile->exchange_durable,
                                                  amqp_empty_table);
+#endif
 
        if (mod_amqp_log_if_amqp_error(amqp_get_rpc_reply(profile->conn_active->state), "Declaring exchange")) {
                switch_log_printf(SWITCH_CHANNEL_LOG, SWITCH_LOG_ERROR, "Profile[%s] failed to create exchange\n", profile->name);
@@ -458,13 +468,23 @@ void * SWITCH_THREAD_FUNC mod_amqp_producer_thread(switch_thread_t *thread, void
                        status = mod_amqp_connection_open(profile->conn_root, &(profile->conn_active), profile->name, profile->custom_attr);
                        if ( status     == SWITCH_STATUS_SUCCESS ) {
                                // Ensure that the exchange exists, and is of the correct type
+#if AMQP_VERSION_MAJOR == 0 && (AMQP_VERSION_MINOR > 5 || (AMQP_VERSION_MINOR == 5 && AMQP_VERSION_PATCH >= 2 ))
                                amqp_exchange_declare(profile->conn_active->state, 1,
                                                                          amqp_cstring_bytes(profile->exchange),
                                                                          amqp_cstring_bytes(profile->exchange_type),
                                                                          passive,
                                                                          durable,
+                                                                         profile->exchange_auto_delete,
+                                                                         0,
                                                                          amqp_empty_table);
-
+#else
+                               amqp_exchange_declare(profile->conn_active->state, 1,
+                                                                         amqp_cstring_bytes(profile->exchange),
+                                                                         amqp_cstring_bytes(profile->exchange_type),
+                                                                         passive,
+                                                                         durable,
+                                                                         amqp_empty_table);
+#endif
                                if (!mod_amqp_log_if_amqp_error(amqp_get_rpc_reply(profile->conn_active->state), "Declaring exchange")) {
                                        switch_log_printf(SWITCH_CHANNEL_LOG, SWITCH_LOG_INFO, "Amqp reconnect successful- connected\n");
                                        continue;