[rabbitmq-discuss] Draft of C++ rabbitMq API
    Alexandre Kalendarev 
    akalend at mail.ru
       
    Mon Mar  1 11:55:57 GMT 2010
    
    
  
Hi colleagues!
I developed the C++ interface, see below
If You have any ideas - wellcome! 
the Draft of C++ API
Connection class
class AMQPConnection {
	AMQPConnection();
	AMQPConnection( string connectionString );
	AMQPConnection( string connectionString , int channelNumber);
	
	void Open( string connectionString );
	void Open( string connectionString , int channelNumber);
	
	void Close();
	
	setChannel(int channelNumber);
}
const AMQPCnnDebug = "localhost:5672"
the example:
	AMQPConnection * cnn = new AMQPConnection(  "guest:guest at localhost:5673/somevhost" );
	default connection string is "localhost:5672"
	the debug connection string   AMQPCnnDebug  is "guest:guest at localhost:5673" 
Exchange class
class AMQPExchange {
	AMQPExchange( AMQPConnection * cnn );
	
	void Declare(string name);
	void Declare(string name, int parms);
	void Declare(string name, int parms, map properties ); // *)?
	void Delete(string name)
}
the parms is set of constants as AMQPDurable, AMQPAutodelete etc
the type of exchange is AMQPDirect default or AMQPFanout, or AMQPTopic 
Example:
	AMQPExchange * ex = new  AMQPExchange(new AMQPConnection());
	ex->Declare("my_exchange");
Queue class
class AMQPQueue {
	AMQPQueue(AMQPConnection * cnn);
	void Declare(string name);
	void Declare(string name, int parms);
	void Declare(string name, int parms, map properties ); // *)?
	void Delete(string name)
	void Purge (string name)
}
the parms is set of constants as AMQPDurable, AMQPAutodelete etc
example:
	AMQPEQueue * qu = new AMQPEQueue(new AMQPConnection());
	qu->Declare("qu_mylife");
Basic class:
class AMQPBasic {
	AMQPBasic(AMQPConnection * cnn);
	void setProperty(string name, string value  );
	void setProperty(string name, int value  );
	void Bind (string exchangeName, string queueName );
	void Bind (string exchangeName, string queueName , string key);
	void Publish( string exchangeName, string message);
	void Publish( string exchangeName, uchar* message);
	void Publish( string exchangeName, string message, string key);
	void Publish( string exchangeName, uchar* message, string key);
	void Cancel( string queueName)
	AMQPMessage *  Get( string queueName)
	void Ask( string queueName ) ????
	void Reject( string queueName ) ????
	void Consume( string queueName , IAMQPCallback * callbackName );
}
class AMQPMessage  ????
 int timestamp
 int expiration
 string contentType
 string deliveryTag
 uchar* message or string 
 int number // internal number message
 string exchange 
 string key
....
 IAMQPCallback is abstract class, the callbackName is derived from IAMQPCallback.
after received each the message call the method run of derived AMQPCallback base class.
*) properties is map of addional property, it will to resolve in future.
Examples:
	// publish message	
	AMQPConnection * cnn = new AMQPConnection();
	AMQPExchange * ex = new  AMQPExchange(cnn);
	ex->Declare("my_exchange", AMQPTopic);
	basic = new AMQPBasic(cnn);
	basic->Bind("my_exchange", "qu_mylive", "news" );
	basic->Publish("my_exchange", "12345" , "news");
	// consume message
	class printMessage : IAMQPCallback {
		void run (uchar* message) {
			std::cout << message << std::endl;
		}
	}
	
	AMQPConnection * cnn = new AMQPConnection();
	basic = new AMQPBasic(cnn);
	printMessage * pm = new printMessage();
	basic->Consume("qu_mylive", pm); 
unrealise classes(it will to resolve in future):  AMQPFile, AMQPStreams etc ...
exceptions:
AMQPnoConnectException
AMQPnonAutorizeException
AMQPnotFoundException 
AMQPnotAllowedException 
...
AMQPerrorException (AMQPcommandInvalidException  )
    
    
More information about the rabbitmq-discuss
mailing list