Consumer Actors section
This commit is contained in:
parent
b64d7b81e8
commit
5d410ce1d1
3 changed files with 87 additions and 8 deletions
|
|
@ -74,8 +74,8 @@ Camel endpoints.
|
|||
.. includecode:: code/akka/docs/camel/Introduction.scala
|
||||
:include: imports,Producer
|
||||
|
||||
In the above example, any message sent to this actor will be added (produced) to
|
||||
the example JMS queue. Producer actors may choose from the same set of Camel
|
||||
In the above example, any message sent to this actor will be sent to
|
||||
the JMS queue ``orders``. Producer actors may choose from the same set of Camel
|
||||
components as Consumer actors do.
|
||||
|
||||
CamelMessage
|
||||
|
|
@ -113,3 +113,46 @@ Maven
|
|||
<artifactId>akka-camel</artifactId>
|
||||
<version>2.1-SNAPSHOT</version>
|
||||
</dependency>
|
||||
|
||||
.. _camel-consumer-actors:
|
||||
|
||||
|
||||
Consumer Actors
|
||||
================
|
||||
|
||||
For objects to receive messages, they must mixin the `Consumer`_
|
||||
trait. For example, the following actor class (Consumer1) implements the
|
||||
endpointUri method, which is declared in the Consumer trait, in order to receive
|
||||
messages from the ``file:data/input/actor`` Camel endpoint.
|
||||
|
||||
.. _Consumer: http://github.com/akka/akka/blob/master/akka-camel/src/main/scala/akka/camel/Consumer.scala
|
||||
|
||||
.. includecode:: code/akka/docs/camel/Consumers.scala#Consumer1
|
||||
|
||||
Whenever a file is put into the data/input/actor directory, its content is
|
||||
picked up by the Camel `file component`_ and sent as message to the
|
||||
actor. Messages consumed by actors from Camel endpoints are of type
|
||||
`CamelMessage`_. These are immutable representations of Camel messages.
|
||||
|
||||
.. _file component: http://camel.apache.org/file2.html
|
||||
.. _Message: http://github.com/akka/akka/blob/master/akka-camel/src/main/scala/akka/camel/CamelMessage.scala
|
||||
|
||||
|
||||
Here's another example that sets the endpointUri to
|
||||
``jetty:http://localhost:8877/camel/default``. It causes Camel's `Jetty
|
||||
component`_ to start an embedded `Jetty`_ server, accepting HTTP connections
|
||||
from localhost on port 8877.
|
||||
|
||||
.. _Jetty component: http://camel.apache.org/jetty.html
|
||||
.. _Jetty: http://www.eclipse.org/jetty/
|
||||
|
||||
.. includecode:: code/akka/docs/camel/Consumers.scala#Consumer2
|
||||
|
||||
After starting the actor, clients can send messages to that actor by POSTing to
|
||||
``http://localhost:8877/camel/default``. The actor sends a response by using the
|
||||
self.reply method (Scala). For returning a message body and headers to the HTTP
|
||||
client the response type should be `Message`_. For any other response type, a
|
||||
new Message object is created by akka-camel with the actor response as message
|
||||
body.
|
||||
|
||||
.. _Message: http://github.com/akka/akka/blob/master/akka-camel/src/main/scala/akka/camel/CamelMessage.scala
|
||||
|
|
|
|||
Loading…
Add table
Add a link
Reference in a new issue