The idea is to filter the sources, replacing @<var>@ occurrences with the mapping for <var> (which is currently hard-coded). @@ -> @. In order to make this work, I had to move the doc sources one directory down (into akka-docs/rst) so that the filtered result could be in a sibling directory so that relative links (to _sphinx plugins or real code) would continue to work. While I was at it I also changed it so that WARNINGs and ERRORs are not swallowed into the debug dump anymore but printed at [warn] level (minimum). One piece of fallout is that the (online) html build is now run after the normal one, not in parallel.
47 lines
1.4 KiB
Scala
47 lines
1.4 KiB
Scala
package docs.camel
|
|
|
|
object PublishSubscribe {
|
|
{
|
|
//#PubSub
|
|
import akka.actor.{ Actor, ActorRef, ActorSystem, Props }
|
|
import akka.camel.{ Producer, CamelMessage, Consumer }
|
|
|
|
class Subscriber(name: String, uri: String) extends Actor with Consumer {
|
|
def endpointUri = uri
|
|
|
|
def receive = {
|
|
case msg: CamelMessage ⇒ println("%s received: %s" format (name, msg.body))
|
|
}
|
|
}
|
|
|
|
class Publisher(name: String, uri: String) extends Actor with Producer {
|
|
|
|
def endpointUri = uri
|
|
|
|
// one-way communication with JMS
|
|
override def oneway = true
|
|
}
|
|
|
|
class PublisherBridge(uri: String, publisher: ActorRef) extends Actor with Consumer {
|
|
def endpointUri = uri
|
|
|
|
def receive = {
|
|
case msg: CamelMessage ⇒ {
|
|
publisher ! msg.bodyAs[String]
|
|
sender ! ("message published")
|
|
}
|
|
}
|
|
}
|
|
|
|
// Add below to a Boot class
|
|
// Setup publish/subscribe example
|
|
val system = ActorSystem("some-system")
|
|
val jmsUri = "jms:topic:test"
|
|
val jmsSubscriber1 = system.actorOf(Props(new Subscriber("jms-subscriber-1", jmsUri)))
|
|
val jmsSubscriber2 = system.actorOf(Props(new Subscriber("jms-subscriber-2", jmsUri)))
|
|
val jmsPublisher = system.actorOf(Props(new Publisher("jms-publisher", jmsUri)))
|
|
val jmsPublisherBridge = system.actorOf(Props(new PublisherBridge("jetty:http://0.0.0.0:8877/camel/pub/jms", jmsPublisher)))
|
|
//#PubSub
|
|
|
|
}
|
|
}
|