diff --git a/src/mod/event_handlers/mod_amqp/mod_amqp_command.c b/src/mod/event_handlers/mod_amqp/mod_amqp_command.c index 851f52c46f..dba6d20eb0 100644 --- a/src/mod/event_handlers/mod_amqp/mod_amqp_command.c +++ b/src/mod/event_handlers/mod_amqp/mod_amqp_command.c @@ -298,13 +298,13 @@ void * SWITCH_THREAD_FUNC mod_amqp_command_thread(switch_thread_t *thread, void 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); + if (mod_amqp_log_if_amqp_error(amqp_get_rpc_reply(profile->conn_active->state), "Checking for command exchange\n")) { + switch_log_printf(SWITCH_CHANNEL_LOG, SWITCH_LOG_WARNING, "Profile[%s] failed to create missing command exchange\n", profile->name); continue; } /* Ensure we have a queue */ - switch_log_printf(SWITCH_CHANNEL_LOG, SWITCH_LOG_DEBUG, "Creating command queue"); + switch_log_printf(SWITCH_CHANNEL_LOG, SWITCH_LOG_DEBUG, "Creating command queue\n"); recv_queue = amqp_queue_declare(profile->conn_active->state, // state 1, // channel profile->queue ? amqp_cstring_bytes(profile->queue) : amqp_empty_bytes, // queue name @@ -312,7 +312,7 @@ void * SWITCH_THREAD_FUNC mod_amqp_command_thread(switch_thread_t *thread, void 0, 1, // exclusive, auto-delete amqp_empty_table); // args - if (mod_amqp_log_if_amqp_error(amqp_get_rpc_reply(profile->conn_active->state), "Declaring queue")) { + if (mod_amqp_log_if_amqp_error(amqp_get_rpc_reply(profile->conn_active->state), "Declaring queue\n")) { switch_log_printf(SWITCH_CHANNEL_LOG, SWITCH_LOG_WARNING, "Profile[%s] failed to connect with code(%d), sleeping for %dms\n", profile->name, status, profile->reconnect_interval_ms); switch_sleep(profile->reconnect_interval_ms * 1000); diff --git a/src/mod/event_handlers/mod_amqp/mod_amqp_producer.c b/src/mod/event_handlers/mod_amqp/mod_amqp_producer.c index 0c3bc4e22e..940578b7cd 100644 --- a/src/mod/event_handlers/mod_amqp/mod_amqp_producer.c +++ b/src/mod/event_handlers/mod_amqp/mod_amqp_producer.c @@ -249,6 +249,7 @@ switch_status_t mod_amqp_producer_create(char *name, switch_xml_t cfg) } else if (!strncmp(var, "content-type", 12)) { content_type = switch_core_strdup(profile->pool, val); } else if (!strncmp(var, "format_fields", 13)) { + char *tmp; switch_log_printf(SWITCH_CHANNEL_LOG, SWITCH_LOG_INFO, "amqp format fields : %s\n", val); if ((format_fields_size = mod_amqp_count_chars(val, ',')) >= MAX_ROUTING_KEY_FORMAT_FIELDS) { switch_log_printf(SWITCH_CHANNEL_LOG, SWITCH_LOG_CRIT, "You can have only %d routing fields in the routing key.\n", @@ -257,9 +258,11 @@ switch_status_t mod_amqp_producer_create(char *name, switch_xml_t cfg) } /* increment size because the count returned the number of separators, not number of fields */ + tmp = strdup(val); format_fields_size++; - switch_separate_string(val, ',', format_fields, MAX_ROUTING_KEY_FORMAT_FIELDS); + switch_separate_string(tmp, ',', format_fields, MAX_ROUTING_KEY_FORMAT_FIELDS); format_fields[format_fields_size] = NULL; + free(tmp); } else if (!strncmp(var, "event_filter", 12)) { /* Parse new events */ profile->event_subscriptions = switch_separate_string(val, ',', argv, (sizeof(argv) / sizeof(argv[0]))); @@ -343,7 +346,7 @@ switch_status_t mod_amqp_producer_create(char *name, switch_xml_t cfg) amqp_empty_table); #endif - if (mod_amqp_log_if_amqp_error(amqp_get_rpc_reply(profile->conn_active->state), "Declaring exchange")) { + if (mod_amqp_log_if_amqp_error(amqp_get_rpc_reply(profile->conn_active->state), "Declaring exchange\n")) { switch_log_printf(SWITCH_CHANNEL_LOG, SWITCH_LOG_ERROR, "Profile[%s] failed to create exchange\n", profile->name); goto err; } diff --git a/src/mod/event_handlers/mod_amqp/mod_amqp_utils.c b/src/mod/event_handlers/mod_amqp/mod_amqp_utils.c index bd0289ca8f..9f0ed3ffd0 100644 --- a/src/mod/event_handlers/mod_amqp/mod_amqp_utils.c +++ b/src/mod/event_handlers/mod_amqp/mod_amqp_utils.c @@ -97,6 +97,31 @@ switch_status_t mod_amqp_do_config(switch_bool_t reload) return SWITCH_STATUS_FALSE; } + if (reload) { + switch_hash_index_t *hi; + mod_amqp_producer_profile_t *producer; + mod_amqp_command_profile_t *command; + mod_amqp_logging_profile_t *logging; + + switch_event_unbind_callback(mod_amqp_producer_event_handler); + + while ((hi = switch_core_hash_first(mod_amqp_globals.producer_hash))) { + switch_core_hash_this(hi, NULL, NULL, (void **)&producer); + mod_amqp_producer_destroy(&producer); + } + while ((hi = switch_core_hash_first(mod_amqp_globals.command_hash))) { + switch_core_hash_this(hi, NULL, NULL, (void **)&command); + mod_amqp_command_destroy(&command); + } + + switch_log_unbind_logger(mod_amqp_logging_recv); + + while ((hi = switch_core_hash_first(mod_amqp_globals.logging_hash))) { + switch_core_hash_this(hi, NULL, NULL, (void **)&logging); + mod_amqp_logging_destroy(&logging); + } + } + if ((profiles = switch_xml_child(cfg, "producers"))) { if ((profile = switch_xml_child(profiles, "profile"))) { for (; profile; profile = profile->next) {