[openamq-dev] Durable Queues
Malinga
malingajava at yahoo.com
Wed Aug 22 12:56:24 CEST 2007
Hi this is the class (external application) which is used to create the queues for the product. it creates a queue but its not permanent (durable) yet. whats the wrong ?
#include <stdio.h> /* This handles the basic IO functionality */
#include "base.h" /* iMatix base header file,
Defines the standard preprocessing environment for C development. Also
defines a set of portability macros for functionality that is not part
of the APR layer we are using for most portability. */
#include "amq_client_connection.h" /* A amq_client_connection object establishes and manages a single
connection to a amq server. The connection can hold many sessions - each is a
amq_client_session object. To use this API, first create a connection to the server,
then create one or more sessions and do work on the sessions. Each session represents
a serial stream of work. In simple applications, a single session is usually sufficient.
In multithreaded applications, each thread will want its own session. */
#include "amq_client_session.h" /* This class provides the session serialisation API.
Generated from amq_client_session.icl by icl_gen using GSL/4. */
#include "RMiddleware.h" /* Defines all the middleware related funtionality */
#include <sys/time.h> /* This will used to get the very usefull time related functions to calcualte the staticstics */
amq_client_connection_t *connection; // Current connection.
amq_client_session_t *session; // Current session.
icl_longstr_t *auth_data; // Autantication data set.
int create(int argc, char *argv [], char* chost, char* cdestination){
int rc;
if (!connection){
icl_system_initialise (argc, argv); /* This should called with the environment variables,
which will initialize the system, else it will give
us a error and stop furter processing. */
/* This will open a connection, need to do some more error handling */
auth_data = amq_client_connection_auth_plain ("guest", "guest");
connection = amq_client_connection_new (chost, "/", auth_data, "sender", 0, 30000);
icl_longstr_destroy (&auth_data);
}else{
//icl_console_print ("INFO : Connection Already Initialized");
}
///////////////////////////////////////////////////////////////////////////////////////////
///////////////////////////////////////////////////////////////////////////////////////////
////////////////////////////////// EXCEPTION HANDLING /////////////////////////////////////
///////////////////////////////////////////////////////////////////////////////////////////
///////////////////////////////////////////////////////////////////////////////////////////
if (!connection) {
icl_console_print ("ERROR : Could not open connection to the specified message broker");
return 3000;
}else{
icl_console_print ("INFO : connected to %s/%s - %s - %s",
connection->server_product,
connection->server_version,
connection->server_platform,
connection->server_information);
}
///////////////////////////////////////////////////////////////////////////////////////////
///////////////////////////////////////////////////////////////////////////////////////////
///////////////////////////////////////////////////////////////////////////////////////////
///////////////////////////////////////////////////////////////////////////////////////////
///////////////////////////////////////////////////////////////////////////////////////////
if(!session){
session = amq_client_session_new (connection);
}else{
icl_console_print ("INFO : Session Already Initialized");
}
///////////////////////////////////////////////////////////////////////////////////////////
///////////////////////////////////////////////////////////////////////////////////////////
////////////////////////////////// EXCEPTION HANDLING /////////////////////////////////////
///////////////////////////////////////////////////////////////////////////////////////////
///////////////////////////////////////////////////////////////////////////////////////////
if (!session) {
icl_console_print ("ERROR : could not open session to the specified conection");
return 3001; // Shoud not exit like this
}else{
icl_console_print ("INFO : established a virtual connection ( session ) to this connection");
}
///////////////////////////////////////////////////////////////////////////////////////////
///////////////////////////////////////////////////////////////////////////////////////////
///////////////////////////////////////////////////////////////////////////////////////////
///////////////////////////////////////////////////////////////////////////////////////////
///////////////////////////////////////////////////////////////////////////////////////////
// Create a private queue
amq_client_session_queue_declare (
session, // session
0, // ticket
NULL, // queue name
FALSE, // passive
TRUE, // durable
TRUE, // exclusive
FALSE, // auto-delete
NULL); // arguments
// Bind the queue to the exchange
amq_client_session_queue_bind (
session, // session
0, // ticket
NULL, // queue
"amq.direct", // exchange
cdestination, // routing-key
NULL); // arguments
amq_client_session_basic_consume (
session, // session
0, // ticket
NULL, // queue
NULL, // consumer-tag
TRUE, // no-local
TRUE, // no-ack
TRUE, // exclusive
NULL); // arguments
return 0;
}
void dispose (){
// Close the channel
amq_client_session_destroy (&session);
// icl_console_print ("INFO : Session disposed sucessfully");
// Close the connection
amq_client_connection_destroy (&connection);
// icl_console_print ("INFO : Connection disposed sucessfully");
// Uninitialise system
icl_system_terminate ();
//icl_console_print ("INFO : System terminated");
}
int main(int argc, char* argv[]){
int status = create(argc, argv, "localhost:5672", "destination");
printf("Status of queue creation : %d\n", status);
dispose();
return 0;
}
____________________________________________________________________________________
Boardwalk for $500? In 2007? Ha! Play Monopoly Here and Now (it's updated for today's economy) at Yahoo! Games.
http://get.games.yahoo.com/proddesc?gamekey=monopolyherenow
-------------- next part --------------
An HTML attachment was scrubbed...
URL: http://lists.openamq.org/pipermail/openamq-dev/attachments/20070822/bf5a4045/attachment-0001.htm
More information about the openamq-dev
mailing list