Commit
This commit does not belong to any branch on this repository, and may belong to a fork outside of the repository.
- Loading branch information
Felipe Gutierrez
committed
Mar 7, 2013
1 parent
034d796
commit c1e0940
Showing
5 changed files
with
96 additions
and
78 deletions.
There are no files selected for viewing
This file contains 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
29 changes: 18 additions & 11 deletions
29
01-spring-camel/src/main/groovy/GroovySpringCamelAMQP.groovy
This file contains 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
Original file line number | Diff line number | Diff line change |
---|---|---|
@@ -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" |
39 changes: 21 additions & 18 deletions
39
01-spring-camel/src/main/groovy/com/itprosmx/spring/camel/SampleBean.groovy
This file contains 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
Original file line number | Diff line number | Diff line change |
---|---|---|
@@ -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" | ||
} | ||
} |
45 changes: 24 additions & 21 deletions
45
01-spring-camel/src/main/resources/META-INF/spring/SpringCamelAMQPBeans.groovy
This file contains 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
Original file line number | Diff line number | Diff line change |
---|---|---|
@@ -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') | ||
|
||
} |
This file contains 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
Original file line number | Diff line number | Diff line change |
---|---|---|
@@ -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> |