From 809b4462b72f527961344c76eb0ba24074ee8d49 Mon Sep 17 00:00:00 2001 From: Jonathan Robie Date: Sat, 17 Apr 2010 00:59:28 +0000 Subject: Added Hello World examples in Python and Java (these have also been checked in to the examples directory). Added section on JNDI properties for Java JMS. Significant changes to introduction. General cleanup. git-svn-id: https://svn.apache.org/repos/asf/qpid/trunk/qpid@935104 13f79535-47bb-0310-9956-ffa450edef68 --- doc/book/src/High-Level-API.xml | 281 ++++++++++++++++++++++++++++++++++++---- 1 file changed, 259 insertions(+), 22 deletions(-) (limited to 'doc') diff --git a/doc/book/src/High-Level-API.xml b/doc/book/src/High-Level-API.xml index 3fc656593f..0997473506 100644 --- a/doc/book/src/High-Level-API.xml +++ b/doc/book/src/High-Level-API.xml @@ -23,7 +23,6 @@ --> - Apache Qpid Messaging API @@ -60,9 +59,6 @@ - A connection represents a network connection. The parameters for the network connection are specified using a URL-based syntax when the connection is @@ -96,11 +92,11 @@ TODO: Add definition for message
A Simple Messaging Program in C++ - The following program shows how to create a Connection, + The following C++ program shows how to create a Connection, create a Session, send messages to a queue using a Sender, and receive messages from a queue using a Receiver. - #include #include @@ -137,14 +133,19 @@ int main(int argc, char** argv) { } }]]> - ##########################
A Simple Messaging Program in Python - The following Python program shows how to create a + Connection, create a Session, send messages to a queue using a + Sender, and receive messages from a queue using a Receiver. + + + - ########################## -
A Simple Messaging Program in Java JMS + + The following program shows how to use address strings and + JNDI for Qpid programs that use Java JMS. + + This program uses a JNDI file that defines a connection + factory for the broker we are using, and the address of the topic + exchange node that we will bind the sender and receiver to. (The + syntax of a ConnectionURL is given in .) + + + In the Java JMS code, we use create a JNDI context, use the context to find a connection factory and create and start a connection, create a session, and create a destination that corresponds to the topic exchange. Then we create a sender and a receiver, send a message with the sender, and receive it with the receiver. This code should be straightforward for anyone familiar with Java JMS. + +
@@ -912,9 +979,9 @@ TODO: Add some reliability option examples properties are mapped to AMQP message properties and delivery properties.
- Request-response applications frequently use a reply-to property to tell a server where to send a response. The following code shows how a server extracts the reply-to property and uses it to set the address to respond to a client. + Request-response applications frequently use a reply-to property to tell a server where to send a response. The following C++ code shows how a server extracts the reply-to property and uses it to set the address to respond to a client. - + Message request = receiver.fetch(); const Address& address = request.getReplyTo(); Get "reply-to" field from request ... if (address) { @@ -992,17 +1059,187 @@ Examples - do client / server, pub-sub here... --> +
+ Apache Qpid JNDI Properties for AMQP Messaging + + + Apache Qpid defines JNDI properties that can be used to + specify the parameters for a connection. Here is a typical JNDI properties file: + + java.naming.factory.initial = org.apache.qpid.jndi.PropertiesFileInitialContextFactory + +# register some connection factories +# connectionfactory.[jndiname] = [ConnectionURL] +connectionfactory.qpidConnectionfactory = amqp://guest:guest@clientid/test?brokerlist='tcp://localhost:5672' + +# Register an AMQP destination in JNDI +# destination.[jndiName] = [Address] +destination.directQueue = direct://amq.direct//message_queue?routingkey='routing_key' + + + + + +
+ JNDI Properties for Apache Qpid + + Apache Qpid supports the properties shown in the following table: + + + JNDI Properties supported by Apache Qpid + + + + + Property + + + Purpose + + + + + + + connectionfactory.<jndiname> + + + + The Connection URL that the connection factory will use to perform connections. + + + + + + queue.<jndiname> + + + + A JMS queue, which is implemented as an amq.direct exchange in Apache Qpid. + + + + + + topic.<jndiname> + + + + A JMS topic, which is implemented as an amq.topic exchange in Apache Qpid. + + + + + + destination.<jndiname> + + + + Can be used for defining all amq destinations, queues, topics and header matching, using an address string. + + + + + +
+
+ +
+ Connection URLs + + In JNDI properties, a Connection URL specifies properties for a connection. The format for a Connection URL is: + + + amqp://[<user>:<pass>@][<clientid>]<virtualhost>[?<option>='<value>'[&<option>='<value>']] + + + For instance, the following Connection URL specifies a user name, a password, a client ID, a virtual host ("test"), a broker list with a single broker, and a TCP host with the host name localhost using port 5672: + + + amqp://username:password@clientid/test?brokerlist='tcp://localhost:5672' + + + Apache Qpid supports the following properties in Connection URLs: + + + Connection URL Properties + + + + + Option + + + Type + + + Description + + + + + + + brokerlist + + + see below + + + The broker to use for this connection. In the current release, precisely one broker must be specified. + + + + + maxprefetch + + + -- + + + The maximum number of pre-fetched messages per destination. + + + + + sync_persistence + + + false + + + When true, a sync command is sent after every persistent message to guarantee that it has been received. + + + + +
+ + Broker lists are specified using a URL in this format: + + + brokerlist=<transport>://<host>[:<port>] + + + For instance, this is a typical broker list: + + + brokerlist='tcp://localhost:5672' + +
+ +
-- cgit v1.2.1