Fuse 6 is no longer supported
As of February 2025, Red Hat Fuse 6 is no longer supported. If you are using Fuse 6, please upgrade to Red Hat build of Apache Camel.此内容没有您所选择的语言版本。
Chapter 5. AMQP
AMQP 复制链接链接已复制到粘贴板!
复制链接链接已复制到粘贴板!
The AMQP component supports the AMQP protocol via the Qpid project.
Maven users will need to add the following dependency to their
pom.xml
for this component:
URI format 复制链接链接已复制到粘贴板!
复制链接链接已复制到粘贴板!
amqp:[queue:|topic:]destinationName[?options]
amqp:[queue:|topic:]destinationName[?options]
You can specify all of the various configuration options of the JMS component after the destination name.
AMQP Options 复制链接链接已复制到粘贴板!
复制链接链接已复制到粘贴板!
You can specify all of the various configuration options of the JMS component after the destination name.
Usage 复制链接链接已复制到粘贴板!
复制链接链接已复制到粘贴板!
As AMQP component is inherited from JMS component, the usage of the former is almost identical to the latter:
Configuring AMQP component 复制链接链接已复制到粘贴板!
复制链接链接已复制到粘贴板!
Starting from the Camel 2.16.1 you can also use the
AMQPComponent#amqp10Component(String connectionURI)
factory method to return the AMQP 1.0 component with the pre-configured topic prefix:
AMQPComponent amqp = AMQPComponent.amqp10Component("amqp://guest:guest@localhost:5672");
AMQPComponent amqp = AMQPComponent.amqp10Component("amqp://guest:guest@localhost:5672");
Keep in mind that starting from the Camel 2.17 the
AMQPComponent#amqp10Component(String connectionURI)
factory method has been deprecated on the behalf of the AMQPComponent#amqpComponent(String connectionURI)
:
AMQPComponent amqp = AMQPComponent.amqpComponent("amqp://localhost:5672"); AMQPComponent authorizedAmqp = AMQPComponent.amqpComponent("amqp://localhost:5672", "user", "password");
AMQPComponent amqp = AMQPComponent.amqpComponent("amqp://localhost:5672");
AMQPComponent authorizedAmqp = AMQPComponent.amqpComponent("amqp://localhost:5672", "user", "password");
Starting from Camel 2.17, in order to automatically configure the AMQP component, you can also add an instance of
org.apache.camel.component.amqp.AMQPConnectionDetails
to the registry. For example for Spring Boot you just have to define bean:
You can also rely on the Camel properties to read the AMQP connection details. Factory method
AMQPConnectionDetails.discoverAMQP()
attempts to read Camel properties in a Kubernetes-like convention, just as demonstrated on the snippet below:
Using topics 复制链接链接已复制到粘贴板!
复制链接链接已复制到粘贴板!
To have using topics working with
camel-amqp
you need to configure the component to use topic://
as topic prefix, as shown below:
Keep in mind that both
AMQPComponent#amqpComponent()
methods and AMQPConnectionDetails
pre-configure the component with the topic prefix, so you don't have to configure it explicitly.