#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,