Camel RabbitMQ topic exchange example

@drse / updated May 12, 2015

Share:  


@Grapes([
  @Grab('org.apache.camel:camel-core:2.15.0'),
  @Grab('org.apache.camel:camel-rabbitmq:2.15.0')
])

import org.apache.camel.builder.RouteBuilder
import org.apache.camel.impl.DefaultCamelContext

def camel = new DefaultCamelContext()

camel.addRoutes(new RouteBuilder() {
  def void configure() {
    from("rabbitmq://localhost/myExchange?exchangeType=topic&routingKey=*.log.*&autoDelete=false")
    .to("log:main?showAll=true")
  }
})

camel.start()

println "Route started..."

Runtime.runtime.addShutdownHook({ ->
  camel.stop()
})