Skip to content

Instantly share code, notes, and snippets.

Show Gist options
  • Save marcelmaatkamp/427449 to your computer and use it in GitHub Desktop.
Save marcelmaatkamp/427449 to your computer and use it in GitHub Desktop.
#!/usr/bin/env groovy
/**
* Small example showing how to make a routing
* in Apache Camel and ActiveMQ in a groovy shell-script.
*
* @author: Marcel Maatkamp (m.maatkamp avec gmail dot com)
*/
@Grapes([
@Grab('org.apache.camel:camel-core:2.3.0'),
@Grab('org.apache.camel:camel-mina:2.3.0'),
@Grab('org.apache.camel:camel-jms:2.3.0'),
@Grab('org.apache.activemq:activemq-core:5.3.2'),
@Grab('org.apache.activemq:activemq-camel:5.3.2'),
@Grab('org.slf4j:slf4j-log4j12:1.6.0'),
@GrabConfig(systemClassLoader = true)
])
import org.apache.camel.builder.RouteBuilder
import org.apache.activemq.ActiveMQConnectionFactory
import org.apache.camel.impl.DefaultCamelContext
import org.apache.camel.component.jms.JmsComponent
import javax.jms.ConnectionFactory
def context = new DefaultCamelContext()
def connectionFactory = new ActiveMQConnectionFactory("vm://localhost")
context.addComponent("jms", JmsComponent.jmsComponentAutoAcknowledge(connectionFactory))
context.addRoutes(new RouteBuilder() {
public void configure() {
from("ftp://riderautoparts.com/orders"
+ "?username=rider&password=secret")
.to("jms:incomingOrders")
}
})
context.start()
Thread.sleep(10000)
context.stop()
Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment