Permalink
Browse files

adding a direct message

  • Loading branch information...
1 parent 034d796 commit c1e094036fce11b2b003cf3f735996ac098516a7 Felipe Gutierrez committed Mar 7, 2013
@@ -15,4 +15,5 @@ dependencies {
compile 'org.grails:grails-spring:2.2.0'
compile 'org.springframework.amqp:spring-rabbit:1.1.3.RELEASE'
runtime 'com.bluelock:camel-spring-amqp:1.4'
+ runtime 'log4j:log4j:1.2.16'
}
@@ -1,11 +1,18 @@
-
-
-import grails.spring.BeanBuilder
-
-import org.springframework.amqp.core.AmqpTemplate
-
-
-def bb = new BeanBuilder()
-bb.loadBeans("classpath:/META-INF/spring/SpringCamelAMQPBeans.groovy")
-
-def ctx = bb.createApplicationContext()
+
+
+import grails.spring.BeanBuilder
+
+import org.springframework.amqp.core.AmqpTemplate
+
+
+def bb = new BeanBuilder()
+//Windows (I hate windows for this)
+bb.loadBeans("file:\\C:\\Users\\felgutie\\Documents\\GitHub\\spring-examples\\01-spring-camel\\src\\main\\resources\\META-INF\\spring\\SpringCamelAMQPBeans.groovy")
+//Unix
+//bb.loadBeans("classpath:/META-INF/spring/SpringCamelAMQPBeans.groovy")
+
+def ctx = bb.createApplicationContext()
+def camel = ctx.getBean("camelContext")
+
+def template = camel.createProducerTemplate()
+template.sendBody "direct:message", "Camel Ride for beginner"
@@ -1,18 +1,21 @@
-package com.itprosmx.spring.camel
-
-/**
- *
- * @author felipeg
- *
- */
-class SampleBean {
-
- def run(){
- println "Hello Groovy Camel"
- }
-
- def message(msg){
- def result = new String(msg)
- println "Got: $result"
- }
-}
+package com.itprosmx.spring.camel
+
+import groovy.util.logging.Log4j
+
+/**
+ *
+ * @author felipeg
+ *
+ */
+@Log4j
+class SampleBean {
+
+ def run(){
+ log.info "Hello Groovy Camel"
+ }
+
+ def message(msg){
+ def result = new String(msg)
+ log.info "Got: $result"
+ }
+}
@@ -1,22 +1,25 @@
-beans{
-
- sample(com.itprosmx.spring.camel.SampleBean)
-
- xmlns camel: 'http://camel.apache.org/schema/spring'
- camel {
- camelContext(id:'camelContext', trace:true) {
- camel.'route'{
- camel.'from'(uri:'spring-amqp:myexchage:myqueue') {}
- camel.'to'(uri:"bean://sample?method=message") {}
-
- }
- }
- }
-
- xmlns rabbit:'http://www.springframework.org/schema/rabbit'
-
- rabbit.'connection-factory'(id:'connectionFactory', username:'guest', password:'guest', host:'localhost' )
- rabbit.'template'(id:"amqpTemplate",'connection-factory':'connectionFactory')
- rabbit.'admin'('connection-factory':'connectionFactory')
-
+beans{
+
+ sample(com.itprosmx.spring.camel.SampleBean)
+
+ xmlns camel: 'http://camel.apache.org/schema/spring'
+ camel {
+ camelContext(id:'camelContext', trace:true) {
+ camel.'route'{
+ camel.'from'(uri:'direct://message')
+ camel.'to'(uri:'spring-amqp:my.direct.exchange:my.direct.queue:here.*?type=directc&durable=true&autodelete=false') {}
+ }
+ camel.'route'{
+ camel.'from'(uri:'spring-amqp:my.direct.exchange:my.direct.queue:here.*?type=directc&durable=true&autodelete=false')
+ camel.'to'(uri:"bean://sample?method=message") {}
+ }
+ }
+ }
+
+ xmlns rabbit:'http://www.springframework.org/schema/rabbit'
+
+ rabbit.'connection-factory'(id:'connectionFactory', username:'guest', password:'guest', host:'localhost' )
+ rabbit.'template'(id:"amqpTemplate",'connection-factory':'connectionFactory')
+ rabbit.'admin'('connection-factory':'connectionFactory')
+
}
@@ -1,28 +1,32 @@
-<?xml version="1.0" encoding="UTF-8"?>
-<!DOCTYPE log4j:configuration SYSTEM "log4j.dtd">
-<log4j:configuration xmlns:log4j="http://jakarta.apache.org/log4j/">
-
- <!-- Appenders -->
- <appender name="console" class="org.apache.log4j.ConsoleAppender">
- <param name="Target" value="System.out" />
- <layout class="org.apache.log4j.PatternLayout">
- <param name="ConversionPattern" value="%d{HH:mm:ss.SSS} %-5p [%t][%c] %m%n" />
- </layout>
- </appender>
-
- <!-- Loggers -->
- <logger name="org.springframework.integration">
- <level value="warn" />
- </logger>
-
- <logger name="com.itprosmx.spring.integration">
- <level value="info" />
- </logger>
-
- <!-- Root Logger -->
- <root>
- <priority value="warn" />
- <appender-ref ref="console" />
- </root>
-
-</log4j:configuration>
+<?xml version="1.0" encoding="UTF-8"?>
+<!DOCTYPE log4j:configuration SYSTEM "log4j.dtd">
+<log4j:configuration xmlns:log4j="http://jakarta.apache.org/log4j/">
+
+ <!-- Appenders -->
+ <appender name="console" class="org.apache.log4j.ConsoleAppender">
+ <param name="Target" value="System.out" />
+ <layout class="org.apache.log4j.PatternLayout">
+ <param name="ConversionPattern" value="%d{HH:mm:ss.SSS} %-5p [%t][%c] %m%n" />
+ </layout>
+ </appender>
+
+ <!-- Loggers -->
+ <logger name="org.springframework.integration">
+ <level value="warn" />
+ </logger>
+
+ <logger name="amqp.spring.camel">
+ <level value="off" />
+ </logger>
+
+ <logger name="com.itprosmx.spring">
+ <level value="info" />
+ </logger>
+
+ <!-- Root Logger -->
+ <root>
+ <priority value="warn" />
+ <appender-ref ref="console" />
+ </root>
+
+</log4j:configuration>

0 comments on commit c1e0940

Please sign in to comment.