提交 ba63cc45 authored 作者: William King's avatar William King

FS-8306 #resolve if the exchange doesn't exist, then create it, else

fail. This resolves several error cases.
上级 444b9152
...@@ -151,11 +151,8 @@ switch_status_t mod_amqp_command_create(char *name, switch_xml_t cfg) ...@@ -151,11 +151,8 @@ switch_status_t mod_amqp_command_create(char *name, switch_xml_t cfg)
} }
} }
profile->conn_active = NULL; profile->conn_active = NULL;
/* We are not going to open the command queue connection on create, but instead wait for the running thread to open it */
if ( mod_amqp_connection_open(profile->conn_root, &(profile->conn_active), profile->name, profile->custom_attr) != SWITCH_STATUS_SUCCESS) {
switch_log_printf(SWITCH_CHANNEL_LOG, SWITCH_LOG_ERROR, "Profile[%s] was unable to connect to any connection\n", profile->name);
}
/* Start the worker threads */ /* Start the worker threads */
switch_threadattr_create(&thd_attr, profile->pool); switch_threadattr_create(&thd_attr, profile->pool);
switch_threadattr_stacksize_set(thd_attr, SWITCH_THREAD_STACKSIZE); switch_threadattr_stacksize_set(thd_attr, SWITCH_THREAD_STACKSIZE);
...@@ -200,6 +197,19 @@ void * SWITCH_THREAD_FUNC mod_amqp_command_thread(switch_thread_t *thread, void ...@@ -200,6 +197,19 @@ void * SWITCH_THREAD_FUNC mod_amqp_command_thread(switch_thread_t *thread, void
continue; continue;
} }
/* Check if exchange already exists */
amqp_exchange_declare(profile->conn_active->state, 1,
amqp_cstring_bytes(profile->exchange),
amqp_cstring_bytes("topic"),
0, /* passive */
1, /* durable */
amqp_empty_table);
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);
continue;
}
/* Ensure we have a queue */ /* 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");
recv_queue = amqp_queue_declare(profile->conn_active->state, // state recv_queue = amqp_queue_declare(profile->conn_active->state, // state
......
Markdown 格式
0%
您添加了 0 到此讨论。请谨慎行事。
请先完成此评论的编辑!
注册 或者 后发表评论