How to Send a Message to an Apache ActiveMQ Queue with C/C++

#include "apr_general.h"
#include "stomp.h"

void main() {
  apr_initialize();

  apr_pool_t *pool;

  apr_pool_create(&pool, NULL);

  stomp_connection *connection;

  stomp_connect(&connection, "localhost", 61613, pool);

  stomp_frame connect_frame;

  connect_frame.command = "CONNECT";

  connect_frame.headers = NULL;

  stomp_write(connection, &connect_frame, pool);

  stomp_frame send_frame;

  send_frame.command = "SEND";

  send_frame.headers = apr_hash_make(pool);

  apr_hash_set(send_frame.headers, "destination", APR_HASH_KEY_STRING, "SampleQueue");

  send_frame.body_length = -1;

  send_frame.body = "Simples Assim";

  stomp_write(connection, &send_frame, pool);

  stomp_frame disconnect_frame;

  disconnect_frame.command = "DISCONNECT";

  disconnect_frame.headers = NULL;

  stomp_write(connection, &disconnect_frame, pool);

  stomp_disconnect(&connection);

  apr_pool_destroy(pool);

  apr_terminate();
}

Leave a Reply

Fill in your details below or click an icon to log in:

WordPress.com Logo

You are commenting using your WordPress.com account. Log Out / Change )

Twitter picture

You are commenting using your Twitter account. Log Out / Change )

Facebook photo

You are commenting using your Facebook account. Log Out / Change )

Google+ photo

You are commenting using your Google+ account. Log Out / Change )

Connecting to %s