You are viewing a plain text version of this content. The canonical link for it is here.
Posted to commits@camel.apache.org by da...@apache.org on 2018/03/07 07:39:22 UTC
[camel] 01/02: Polished docs
This is an automated email from the ASF dual-hosted git repository.
davsclaus pushed a commit to branch master
in repository https://gitbox.apache.org/repos/asf/camel.git
commit b84fcb1ea9eb8498dbcd6d4cdaac7703df614ddb
Author: Claus Ibsen <cl...@gmail.com>
AuthorDate: Wed Mar 7 08:30:29 2018 +0100
Polished docs
---
.../src/main/docs/rabbitmq-component.adoc | 79 ++++++++++------------
1 file changed, 36 insertions(+), 43 deletions(-)
diff --git a/components/camel-rabbitmq/src/main/docs/rabbitmq-component.adoc b/components/camel-rabbitmq/src/main/docs/rabbitmq-component.adoc
index 6d3f529..9a941ea 100644
--- a/components/camel-rabbitmq/src/main/docs/rabbitmq-component.adoc
+++ b/components/camel-rabbitmq/src/main/docs/rabbitmq-component.adoc
@@ -12,21 +12,21 @@ Maven users will need to add the following dependency to their `pom.xml`
for this component:
[source,xml]
-------------------------------------------------------------
+----
<dependency>
<groupId>org.apache.camel</groupId>
<artifactId>camel-rabbitmq</artifactId>
<version>x.x.x</version>
<!-- use the same version as your Camel core version -->
</dependency>
-------------------------------------------------------------
+----
-### URI format
+=== URI format
-[source,java]
--------------------------------------------------
+[source,text]
+----
rabbitmq://hostname[:port]/exchangeName?[options]
--------------------------------------------------
+----
Where *hostname* is the hostname of the running rabbitmq instance or
cluster. Port is optional and if not specified then defaults to the
@@ -34,17 +34,13 @@ RabbitMQ client default (5672). The exchange name determines which
exchange produced messages will sent to. In the case of consumers, the
exchange name determines which exchange the queue will bind to.
-### Options
-
+=== Options
// component options: START
The RabbitMQ component has no options.
// component options: END
-
-
-
// endpoint options: START
The RabbitMQ endpoint is configured using URI syntax:
@@ -134,37 +130,40 @@ with the following path and query parameters:
// endpoint options: END
-
-
See
http://www.rabbitmq.com/releases/rabbitmq-java-client/current-javadoc/com/rabbitmq/client/ConnectionFactory.html[http://www.rabbitmq.com/releases/rabbitmq-java-client/current-javadoc/com/rabbitmq/client/ConnectionFactory.html]
and the AMQP specification for more information on connection options.
-### Custom connection factory
+=== Using connection factory
+
+To connect to RabbitMQ you can setup a `ConnectionFactory` (same as with JMS) with the login details such as:
[source,xml]
-----------------------------------------------------------------------------------------
-<bean id="customConnectionFactory" class="com.rabbitmq.client.ConnectionFactory">
+----
+<bean id="rabbitConnectionFactory" class="com.rabbitmq.client.ConnectionFactory">
<property name="host" value="localhost"/>
<property name="port" value="5672"/>
<property name="username" value="camel"/>
<property name="password" value="bugsbunny"/>
</bean>
+
+And then refer to the connection factory in the endpoint uri as shown below:
+
<camelContext>
<route>
<from uri="direct:rabbitMQEx2"/>
- <to uri="rabbitmq://localhost:5672/ex2?connectionFactory=#customConnectionFactory"/>
+ <to uri="rabbitmq://localhost:5672/ex2?connectionFactory=#rabbitConnectionFactory"/>
</route>
</camelContext>
-----------------------------------------------------------------------------------------
+----
-Headers
+=== Message Headers
The following headers are set on exchanges when consuming messages.
[width="100%",cols="10%,90%",options="header",]
-|=======================================================================
+|===
|Property |Value
|`rabbitmq.ROUTING_KEY` |The routing key that was used to receive the message, or the routing key
@@ -181,13 +180,13 @@ from the RabbitMQ broker. The value of this header controls this
behavior. If the value is false (by default) then the message is
discarded/dead-lettered. If the value is true, then the message is
re-queued.
-|=======================================================================
+|===
The following headers are used by the producer. If these are set on the
camel exchange then they will be set on the RabbitMQ message.
[width="100%",cols="10%,90%",options="header",]
-|=======================================================================
+|===
|Property |Value
|`rabbitmq.ROUTING_KEY` |The routing key that will be used when sending the message
@@ -219,67 +218,61 @@ camel exchange then they will be set on the RabbitMQ message.
|`rabbitmq.TIMESTAMP` |The timestamp to set on the RabbitMQ message
|`rabbitmq.APP_ID` |The appId to set on the RabbitMQ message
-|=======================================================================
+|===
Headers are set by the consumer once the message is received. The
producer will also set the headers for downstream processors once the
exchange has taken place. Any headers set prior to production that the
producer sets will be overriden.
-### Message Body
+=== Message Body
The component will use the camel exchange in body as the rabbit mq
message body. The camel exchange in object must be convertible to a byte
array. Otherwise the producer will throw an exception of unsupported
body type.
-### Samples
+=== Samples
To receive messages from a queue that is bound to an exchange A with the
routing key B,
[source,java]
--------------------------------------------
+----
from("rabbitmq://localhost/A?routingKey=B")
--------------------------------------------
+----
To receive messages from a queue with a single thread with auto
acknowledge disabled.
[source,java]
---------------------------------------------------------------------------
+----
from("rabbitmq://localhost/A?routingKey=B&threadPoolSize=1&autoAck=false")
---------------------------------------------------------------------------
+----
To send messages to an exchange called C
[source,java]
--------------------------------
-...to("rabbitmq://localhost/C")
--------------------------------
+----
+to("rabbitmq://localhost/C")
+----
Declaring a headers exchange and queue
[source,java]
----------------------------------------------------------------------------------
+----
from("rabbitmq://localhost/ex?exchangeType=headers&queue=q&bindingArgs=#bindArgs")
----------------------------------------------------------------------------------
+----
-and place corresponding Map<String, Object> with the id of "bindArgs" in the Registry.
+and place corresponding `Map<String, Object>` with the id of "bindArgs" in the Registry.
For example declaring a method in spring
[source,java]
----------------------------------------------------------------------------------
+----
@Bean(name="bindArgs")
public Map<String, Object> bindArgsBuilder() {
return Collections.singletonMap("foo", "bar");
}
----------------------------------------------------------------------------------
-
-### See Also
+----
-* Configuring Camel
-* Component
-* Endpoint
-* Getting Started
--
To stop receiving notification emails like this one, please contact
davsclaus@apache.org.