}
}
profile->conn_active = NULL;
-
- 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);
- }
-
+ /* We are not going to open the command queue connection on create, but instead wait for the running thread to open it */
+
/* Start the worker threads */
switch_threadattr_create(&thd_attr, profile->pool);
switch_threadattr_stacksize_set(thd_attr, SWITCH_THREAD_STACKSIZE);
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 */
switch_log_printf(SWITCH_CHANNEL_LOG, SWITCH_LOG_DEBUG, "Creating command queue");
recv_queue = amqp_queue_declare(profile->conn_active->state, // state