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.このコンテンツは選択した言語では利用できません。
4.2. Using the Consumer Template
Overview リンクのコピーリンクがクリップボードにコピーされました!
リンクのコピーリンクがクリップボードにコピーされました!
The consumer template provides methods for polling a consumer endpoint in order to receive incoming messages. You can choose to receive the incoming message either in the form of an exchange object or in the form of a message body (where the message body can be cast to a particular type using a built-in type converter).
Example of polling exchanges リンクのコピーリンクがクリップボードにコピーされました!
リンクのコピーリンクがクリップボードにコピーされました!
You can use a consumer template to poll a consumer endpoint for exchanges using one of the following polling methods: blocking
receive()
; receive()
with a timeout; or receiveNoWait()
, which returns immediately. Because a consumer endpoint represents a service, it is also essential to start the service thread by calling start()
before you attempt to poll for exchanges.
The following example shows how to poll an exchange from the
seda:foo
consumer endpoint using the blocking receive()
method:
Where the consumer template instance,
consumer
, is instantiated using the CamelContext.createConsumerTemplate()
method and the consumer service thread is started by calling ConsumerTemplate.start()
.
Example of polling message bodies リンクのコピーリンクがクリップボードにコピーされました!
リンクのコピーリンクがクリップボードにコピーされました!
You can also poll a consumer endpoint for incoming message bodies using one of the following methods: blocking
receiveBody()
; receiveBody()
with a timeout; or receiveBodyNoWait()
, which returns immediately. As in the previous example, it is also essential to start the service thread by calling start()
before you attempt to poll for exchanges.
The following example shows how to poll an incoming message body from the
seda:foo
consumer endpoint using the blocking receiveBody()
method:
Methods for polling exchanges リンクのコピーリンクがクリップボードにコピーされました!
リンクのコピーリンクがクリップボードにコピーされました!
There are three basic methods for polling exchanges from a consumer endpoint:
receive()
without a timeout blocks indefinitely; receive()
with a timeout blocks for the specified period of milliseconds; and receiveNoWait()
is non-blocking. You can specify the consumer endpoint either as an endpoint URI or as an Endpoint
instance.
Methods for polling message bodies リンクのコピーリンクがクリップボードにコピーされました!
リンクのコピーリンクがクリップボードにコピーされました!
There are three basic methods for polling message bodies from a consumer endpoint:
receiveBody()
without a timeout blocks indefinitely; receiveBody()
with a timeout blocks for the specified period of milliseconds; and receiveBodyNoWait()
is non-blocking. You can specify the consumer endpoint either as an endpoint URI or as an Endpoint
instance. Moreover, by calling the templating forms of these methods, you can convert the returned body to a particular type, T
, using a built-in type converter.