Skip to content

HTTPS clone URL

Subversion checkout URL

You can clone with HTTPS or Subversion.

Download ZIP

Loading…

Consumer publishing docs #444

Closed
wants to merge 2 commits into from

2 participants

@piotrga

No description provided.

@viktorklang viktorklang commented on the diff
akka-docs/scala/camel.rst
@@ -156,3 +156,29 @@ 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
+
+.. _camel-publishing:
+
+Consumer publishing
+-------------------
+
+Publishing a consumer actor at its Camel endpoint occurs when the actor is
+started.
+
+.. code-block:: scala
+
+ val sys = ActorSystem("camel")
+ val mina = sys.actorOf(Props[MinaConsumer]) // create actor and activate endpoint in background
@viktorklang Owner

No code in rst doc please, put it in a scala file and import it.

Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment
@viktorklang viktorklang commented on the diff
akka-docs/scala/camel.rst
((14 lines not shown))
+
+ val sys = ActorSystem("camel")
+ val mina = sys.actorOf(Props[MinaConsumer]) // create actor and activate endpoint in background
+
+Publication is done asynchronously; setting up an endpoint (more
+precisely, the route from that endpoint to the actor) may still be in progress
+after the ``actorOf`` method returned.
+
+Awaiting for activation
+~~~~~~~~~~~~~~~~~~~~~~~
+In order to make sure the endpoint is fully activated the ``awaitActivation`` method of ``CamelExtension`` can be used.
+
+.. code-block:: scala
+
+ val mina = sys.actorOf(Props[MinaConsumer)
+ CamelExtension(sys).awaitActivation(mina, 10 seconds)
@viktorklang Owner

No code in rst doc please, put it in a scala file and import it.

Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment
@viktorklang viktorklang commented on the diff
akka-docs/scala/camel.rst
((5 lines not shown))
+.. _camel-publishing:
+
+Consumer publishing
+-------------------
+
+Publishing a consumer actor at its Camel endpoint occurs when the actor is
+started.
+
+.. code-block:: scala
+
+ val sys = ActorSystem("camel")
+ val mina = sys.actorOf(Props[MinaConsumer]) // create actor and activate endpoint in background
+
+Publication is done asynchronously; setting up an endpoint (more
+precisely, the route from that endpoint to the actor) may still be in progress
+after the ``actorOf`` method returned.
@viktorklang Owner

What implication will this have for the user, i.e. what are you trying to convey here?

Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment
@viktorklang viktorklang commented on the diff
akka-docs/scala/code/akka/docs/camel/Introduction.scala
((10 lines not shown))
def receive = {
- case msg: CamelMessage { /* ... */ }
- case _ { /* ... */ }
+ case CamelMessage(body, headers) =>
+ val name: Any = headers.get("name").getOrElse("Stranger")
+ sender ! <html><body>{"Hello %s" format name}</body></html>
@viktorklang Owner

Cool, great work Piotr! Docs is always the hardest thing to write!

Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment
@viktorklang
Owner

Closed due to code in .rst doc and not fixed within 3 weeks

Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment
Commits on May 10, 2012
  1. @piotrga

    less geeky examples

    piotrga authored
  2. @piotrga
This page is out of date. Refresh to see the latest.
View
26 akka-docs/scala/camel.rst
@@ -156,3 +156,29 @@ 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
+
+.. _camel-publishing:
+
+Consumer publishing
+-------------------
+
+Publishing a consumer actor at its Camel endpoint occurs when the actor is
+started.
+
+.. code-block:: scala
+
+ val sys = ActorSystem("camel")
+ val mina = sys.actorOf(Props[MinaConsumer]) // create actor and activate endpoint in background
@viktorklang Owner

No code in rst doc please, put it in a scala file and import it.

Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment
+
+Publication is done asynchronously; setting up an endpoint (more
+precisely, the route from that endpoint to the actor) may still be in progress
+after the ``actorOf`` method returned.
@viktorklang Owner

What implication will this have for the user, i.e. what are you trying to convey here?

Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment
+
+Awaiting for activation
+~~~~~~~~~~~~~~~~~~~~~~~
+In order to make sure the endpoint is fully activated the ``awaitActivation`` method of ``CamelExtension`` can be used.
+
+.. code-block:: scala
+
+ val mina = sys.actorOf(Props[MinaConsumer)
+ CamelExtension(sys).awaitActivation(mina, 10 seconds)
@viktorklang Owner

No code in rst doc please, put it in a scala file and import it.

Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment
View
10 akka-docs/scala/code/akka/docs/camel/Introduction.scala
@@ -24,13 +24,15 @@ object Introduction {
{
//#Consumer
import akka.camel.{ CamelMessage, Consumer }
-
class JettyAdapter extends Consumer {
- def endpointUri = "jetty:http://localhost:8877/example"
+ def endpointUri = "jetty:http://localhost:8877/hello"
+
+ // Open http://localhost:8877/hello?name=Bob and see what's going to happen.
def receive = {
- case msg: CamelMessage { /* ... */ }
- case _ { /* ... */ }
+ case CamelMessage(body, headers) =>
+ val name: Any = headers.get("name").getOrElse("Stranger")
+ sender ! <html><body>{"Hello %s" format name}</body></html>
@viktorklang Owner

Cool, great work Piotr! Docs is always the hardest thing to write!

Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment
}
}
//#Consumer
Something went wrong with that request. Please try again.