Skip to content

Commit

Permalink
add: new option 'exchange_type'. Set it to 'fanout' in order to broad…
Browse files Browse the repository at this point in the history
…cast the message to multiple queues. (see #4 )
  • Loading branch information
ziirish committed Dec 12, 2013
1 parent 4b50b66 commit 2df2854
Show file tree
Hide file tree
Showing 3 changed files with 14 additions and 0 deletions.
6 changes: 6 additions & 0 deletions src/module.c
Original file line number Diff line number Diff line change
Expand Up @@ -52,6 +52,7 @@ int nebmodule_init (
g_options.password = "guest";
g_options.virtual_host = "canopsis";
g_options.exchange_name = "canopsis.events";
g_options.exchange_type = NULL;
g_options.log_level = 0;
g_options.connector = "nagios";
g_options.max_size = 8192;
Expand Down Expand Up @@ -258,6 +259,11 @@ n2a_parse_arguments (const char *args_orig)
g_options.exchange_name = right;
n2a_logger (LG_DEBUG, "Setting exchange_name to %s", g_options.exchange_name);
}
else if (strcmp (left, "exchange_type") == 0)
{
g_options.exchange_type = right;
n2a_logger (LG_DEBUG, "Setting exchange_type to %s", g_options.exchange_type);
}
else if (strcmp (left, "connector") == 0)
{
g_options.connector = right;
Expand Down
1 change: 1 addition & 0 deletions src/module.h
Original file line number Diff line number Diff line change
Expand Up @@ -53,6 +53,7 @@ struct options
char *password;
char *virtual_host;
char *exchange_name;
char *exchange_type;
char *connector;
char *eventsource_name;
fifo *pFifo;
Expand Down
7 changes: 7 additions & 0 deletions src/neb2amqp.c
Original file line number Diff line number Diff line change
Expand Up @@ -193,6 +193,13 @@ bool n2a_amqp_connect (void)
n2a_on_amqp_error (amqp_get_rpc_reply (conn), "Opening channel");
}

if (!amqp_errors && NULL != g_options.exchange_type)
{
n2a_logger (LG_DEBUG, "AMQP: setting exchange type");
amqp_exchange_declare(conn, 1, amqp_cstring_bytes(g_options.exchange_name), amqp_cstring_bytes(g_options.exchange_type), 0, 0, amqp_empty_table);
n2a_on_amqp_error (amqp_get_rpc_reply(conn), "Declaring exchange");
}

if (!amqp_errors)
{
n2a_logger (LG_INFO, "AMQP: Successfully connected");
Expand Down

0 comments on commit 2df2854

Please sign in to comment.