summaryrefslogtreecommitdiff
diff options
context:
space:
mode:
authorAlan Antonuk <alan.antonuk@gmail.com>2015-03-06 10:18:48 -0800
committerAlan Antonuk <alan.antonuk@gmail.com>2015-03-06 10:18:48 -0800
commit33798122ce837e15815df44b1fd925f0da04a233 (patch)
tree3b23b6e2d1c77134f6fdd8a0a691f265a4d6f953
parent244034c6aa95fd0c9f37df54766123db4baa9ec3 (diff)
downloadrabbitmq-c-tools_heartbeat.tar.gz
Add support for heartbeats in tools.tools_heartbeat
-rw-r--r--tools/common.c11
1 files changed, 10 insertions, 1 deletions
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");