summary | shortlog | log | commit | commitdiff | tree
raw | patch | inline | side by side (parent: adc387a)
raw | patch | inline | side by side (parent: adc387a)
author | Florian Forster <octo@leeloo.lan.home.verplant.org> | |
Wed, 4 Aug 2010 20:44:15 +0000 (22:44 +0200) | ||
committer | Florian Forster <octo@leeloo.lan.home.verplant.org> | |
Wed, 4 Aug 2010 20:44:15 +0000 (22:44 +0200) |
Use "volatile" by default, but enable the user to switch to "persistent" if
it is important that no value is lost.
it is important that no value is lost.
src/amqp.c | patch | blob | history |
diff --git a/src/amqp.c b/src/amqp.c
index ecbf338e2fb0f4e5fcfc75aa154eb7d4ede76cef..5f44dfc3779b7209810bbb45b0e81009ed6abbf2 100644 (file)
--- a/src/amqp.c
+++ b/src/amqp.c
#include <amqp.h>
#include <amqp_framing.h>
+/* Defines for the delivery mode. I have no idea why they're not defined by the
+ * library.. */
+#define AMQP_DM_VOLATILE 1
+#define AMQP_DM_PERSISTENT 2
+
static int port;
static char *host = NULL;
static char *vhost = NULL;
static char *password = NULL;
static char *exchange = NULL;
static char *routingkey = NULL;
+static uint8_t delivery_mode = AMQP_DM_VOLATILE;
static amqp_connection_state_t amqp_conn = NULL;
static pthread_mutex_t amqp_conn_lock = PTHREAD_MUTEX_INITIALIZER;
"User",
"Password",
"Exchange",
- "RoutingKey"
+ "RoutingKey",
+ "Persistent"
};
static int config_keys_num = STATIC_ARRAY_SIZE(config_keys);
return (config_set(&exchange, value));
else if (strcasecmp(key, "routingkey") == 0)
return (config_set(&routingkey, value));
+ else if (strcasecmp ("Persistent", key) == 0)
+ {
+ if (IS_TRUE (value))
+ delivery_mode = AMQP_DM_PERSISTENT;
+ else
+ delivery_mode = AMQP_DM_VOLATILE;
+ return (0);
+ }
return (-1);
}
props._flags = AMQP_BASIC_CONTENT_TYPE_FLAG | AMQP_BASIC_DELIVERY_MODE_FLAG;
props.content_type = amqp_cstring_bytes("application/json");
- props.delivery_mode = 2; /* persistent delivery mode */
+ props.delivery_mode = delivery_mode;
status = amqp_basic_publish(amqp_conn,
/* channel = */ 1,