From 33798122ce837e15815df44b1fd925f0da04a233 Mon Sep 17 00:00:00 2001 From: Alan Antonuk Date: Fri, 6 Mar 2015 10:18:48 -0800 Subject: Add support for heartbeats in tools. --- tools/common.c | 11 ++++++++++- 1 file changed, 10 insertions(+), 1 deletion(-) (limited to 'tools') diff --git a/tools/common.c b/tools/common.c index 06b41a9..c8b13e3 100644 --- a/tools/common.c +++ b/tools/common.c @@ -171,6 +171,7 @@ static int amqp_port = -1; static char *amqp_vhost; static char *amqp_username; static char *amqp_password; +static int amqp_heartbeat = 0; #ifdef WITH_SSL static int amqp_ssl = 0; static char *amqp_cacert = "/etc/ssl/certs/cacert.pem"; @@ -204,6 +205,10 @@ struct poptOption connect_options[] = { "password", 0, POPT_ARG_STRING, &amqp_password, 0, "the password to login with", "password" }, + { + "heartbeat", 0, POPT_ARG_INT, &amqp_heartbeat, 0, + "heartbeat interval, set to 0 to disable", "heartbeat" + }, #ifdef WITH_SSL { "ssl", 0, POPT_ARG_NONE, &amqp_ssl, 0, @@ -319,6 +324,10 @@ static void init_connection_info(struct amqp_connection_info *ci) ci->vhost = amqp_vhost; } + + if (amqp_heartbeat < 0) { + die("--heartbeat must be a positive value"); + } } amqp_connection_state_t make_connection(void) @@ -355,7 +364,7 @@ amqp_connection_state_t make_connection(void) if (status) { die("opening socket to %s:%d", ci.host, ci.port); } - die_rpc(amqp_login(conn, ci.vhost, 0, 131072, 0, + die_rpc(amqp_login(conn, ci.vhost, 0, 131072, amqp_heartbeat, AMQP_SASL_METHOD_PLAIN, ci.user, ci.password), "logging in to AMQP server"); -- cgit v1.2.1