Skip to content

Instantly share code, notes, and snippets.

@etaque
Created February 23, 2013 08:24
Show Gist options
  • Star 1 You must be signed in to star a gist
  • Fork 1 You must be signed in to fork a gist
  • Save etaque/5018959 to your computer and use it in GitHub Desktop.
Save etaque/5018959 to your computer and use it in GitHub Desktop.
Consume ActiveMQ messages with akka-camel
<bean id="activemq" class="org.apache.activemq.camel.component.ActiveMQComponent">
<property name="brokerURL" value="tcp://0.0.0.0:61616"/>
</bean>
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])
}
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