Created
February 23, 2013 08:24
-
-
Save etaque/5018959 to your computer and use it in GitHub Desktop.
Consume ActiveMQ messages with akka-camel
This file contains hidden or bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
<bean id="activemq" class="org.apache.activemq.camel.component.ActiveMQComponent"> | |
<property name="brokerURL" value="tcp://0.0.0.0:61616"/> | |
</bean> |
This file contains hidden or bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
package org.example | |
import akka.actor._ | |
import akka.camel.{ CamelMessage, Consumer, CamelExtension } | |
import org.apache.activemq.camel.component.ActiveMQComponent | |
class CdrLogConsumer extends Actor with Consumer { | |
def endpointUri = "activemq:FOO.BAR" | |
def receive = { | |
case msg: CamelMessage => println("received %s" format msg.bodyAs[String]) | |
} | |
} | |
object CamelApp extends App { | |
val system = ActorSystem("AkkaProjectInScala") | |
val camel = CamelExtension(system) | |
val camelContext = camel.context | |
camelContext.addComponent("activemq", ActiveMQComponent.activeMQComponent( | |
"tcp://0.0.0.0:61616")) | |
val consumer = system.actorOf(Props[CdrLogConsumer]) | |
} |
This file contains hidden or bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
import sbt._ | |
import sbt.Keys._ | |
object CamelAppBuild extends Build { | |
lazy val akkaProjectInScala = Project( | |
id = "akka-project-in-scala", | |
base = file("."), | |
settings = Project.defaultSettings ++ Seq( | |
name := "Akka Project In Scala", | |
organization := "org.example", | |
version := "0.1-SNAPSHOT", | |
scalaVersion := "2.10.0", | |
resolvers += "Typesafe Releases" at "http://repo.typesafe.com/typesafe/releases", | |
libraryDependencies += "com.typesafe.akka" %% "akka-actor" % "2.1.0", | |
libraryDependencies += "com.typesafe.akka" %% "akka-camel" % "2.1.0", | |
libraryDependencies += "org.apache.activemq" % "activemq-camel" % "5.8.0" | |
) | |
) | |
} |
Sign up for free
to join this conversation on GitHub.
Already have an account?
Sign in to comment