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:21 UTC
[camel] branch master updated (3682e16 -> c0894b1)
This is an automated email from the ASF dual-hosted git repository.
davsclaus pushed a change to branch master
in repository https://gitbox.apache.org/repos/asf/camel.git.
from 3682e16 Upgrade Arquillian to version 1.4.0.Final
new b84fcb1 Polished docs
new c0894b1 CAMEL-12324: Improve docs
The 2 revisions listed above as "new" are entirely new to this
repository and will be described in separate emails. The revisions
listed as "add" were already present in the repository and have only
been added to this reference.
Summary of changes:
.../src/main/docs/rabbitmq-component.adoc | 113 +++++++++++++--------
1 file changed, 71 insertions(+), 42 deletions(-)
--
To stop receiving notification emails like this one, please contact
davsclaus@apache.org.
[camel] 02/02: CAMEL-12324: Improve docs
Posted by da...@apache.org.
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 c0894b1ccde78bb200602040148ee74cae248367
Author: Claus Ibsen <cl...@gmail.com>
AuthorDate: Wed Mar 7 08:37:57 2018 +0100
CAMEL-12324: Improve docs
---
.../src/main/docs/rabbitmq-component.adoc | 36 ++++++++++++++++++++++
1 file changed, 36 insertions(+)
diff --git a/components/camel-rabbitmq/src/main/docs/rabbitmq-component.adoc b/components/camel-rabbitmq/src/main/docs/rabbitmq-component.adoc
index 9a941ea..d781a04 100644
--- a/components/camel-rabbitmq/src/main/docs/rabbitmq-component.adoc
+++ b/components/camel-rabbitmq/src/main/docs/rabbitmq-component.adoc
@@ -276,3 +276,39 @@ public Map<String, Object> bindArgsBuilder() {
}
----
+==== Routing between exchanges
+
+If you for example want to route messages from one Rabbit exchange to another as shown
+in the example below with foo -> bar:
+
+[source,java]
+----
+from("rabbitmq://localhost/foo")
+ .to("rabbitmq://localhost/bar")
+----
+
+Then beware that Camel will route the message to itself, eg foo -> foo. So why is that?
+This is because the consumer that receives the message (eg from) provides the message header
+`rabbitmq.EXCHANGE_NAME` with the name of the exchange, eg `foo`. And when the Camel producer
+is sending the message to `bar` then the header `rabbitmq.EXCHANGE_NAME` will override this
+and instead send the message to `foo`.
+
+To avoid this you need to either:
+
+- remove the header
+
+[source,java]
+----
+from("rabbitmq://localhost/foo")
+ .removeHeader("rabbitmq.EXCHANGE_NAME")
+ .to("rabbitmq://localhost/bar")
+----
+
+- or turn on `bridgeEndpoint` mode on the producer.
+
+[source,java]
+----
+from("rabbitmq://localhost/foo")
+ .to("rabbitmq://localhost/bar?bridgeEndpoint=true")
+----
+
--
To stop receiving notification emails like this one, please contact
davsclaus@apache.org.
[camel] 01/02: Polished docs
Posted by da...@apache.org.
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.