Skip to content

Commit 8b7471e

Browse files
authored
examples: show that you can pass amqp_bytes_t as function argument (#867)
* examples: show that you can pass amqp_bytes_t as function argument
1 parent 47f99dc commit 8b7471e

2 files changed

Lines changed: 6 additions & 8 deletions

File tree

examples/amqp_confirm_select.c

Lines changed: 3 additions & 4 deletions
Original file line numberDiff line numberDiff line change
@@ -26,7 +26,7 @@
2626

2727
#define SUMMARY_EVERY_US 5000
2828

29-
static void send_batch(amqp_connection_state_t conn, char const *queue_name,
29+
static void send_batch(amqp_connection_state_t conn, amqp_bytes_t queue_name,
3030
int rate_limit, int message_count) {
3131
uint64_t start_time = now_microseconds();
3232
int i;
@@ -49,8 +49,7 @@ static void send_batch(amqp_connection_state_t conn, char const *queue_name,
4949
uint64_t now = now_microseconds();
5050

5151
die_on_error(amqp_basic_publish(conn, 1, amqp_literal_bytes("amq.direct"),
52-
amqp_cstring_bytes(queue_name), 0, 0, NULL,
53-
message_bytes),
52+
queue_name, 0, 0, NULL, message_bytes),
5453
"Publishing");
5554
sent++;
5655
if (now > next_summary_time) {
@@ -177,7 +176,7 @@ int main(int argc, char const *const *argv) {
177176
amqp_confirm_select(conn, 1);
178177
die_on_amqp_error(amqp_get_rpc_reply(conn), "Enable confirm-select");
179178

180-
send_batch(conn, "test queue", rate_limit, message_count);
179+
send_batch(conn, amqp_literal_bytes("test queue"), rate_limit, message_count);
181180

182181
wait_for_acks(conn);
183182
die_on_amqp_error(amqp_channel_close(conn, 1, AMQP_REPLY_SUCCESS),

examples/amqp_producer.c

Lines changed: 3 additions & 4 deletions
Original file line numberDiff line numberDiff line change
@@ -13,7 +13,7 @@
1313

1414
#define SUMMARY_EVERY_US 1000000
1515

16-
static void send_batch(amqp_connection_state_t conn, char const *queue_name,
16+
static void send_batch(amqp_connection_state_t conn, amqp_bytes_t queue_name,
1717
int rate_limit, int message_count) {
1818
uint64_t start_time = now_microseconds();
1919
int i;
@@ -36,8 +36,7 @@ static void send_batch(amqp_connection_state_t conn, char const *queue_name,
3636
uint64_t now = now_microseconds();
3737

3838
die_on_error(amqp_basic_publish(conn, 1, amqp_literal_bytes("amq.direct"),
39-
amqp_cstring_bytes(queue_name), 0, 0, NULL,
40-
message_bytes),
39+
queue_name, 0, 0, NULL, message_bytes),
4140
"Publishing");
4241
sent++;
4342
if (now > next_summary_time) {
@@ -107,7 +106,7 @@ int main(int argc, char const *const *argv) {
107106
amqp_channel_open(conn, 1);
108107
die_on_amqp_error(amqp_get_rpc_reply(conn), "Opening channel");
109108

110-
send_batch(conn, "test queue", rate_limit, message_count);
109+
send_batch(conn, amqp_literal_bytes("test queue"), rate_limit, message_count);
111110

112111
die_on_amqp_error(amqp_channel_close(conn, 1, AMQP_REPLY_SUCCESS),
113112
"Closing channel");

0 commit comments

Comments
 (0)