Skip to content

HTTPS clone URL

Subversion checkout URL

You can clone with
or
.
Download ZIP
Browse files

added a service activator and bridge endpoints

  • Loading branch information...
commit d36d51e9a1fb374ec462cadf032286da43a00370 1 parent bb201df
@felipeg48 authored
View
12 ...ion-endpoints/src/main/groovy/com/itprosmx/spring/integration/ServiceActivatorBean.groovy
@@ -14,6 +14,18 @@ class ServiceActivatorBean {
void process(msg){
log.info "Processing..."
+ log.info "Message: $msg"
+ }
+
+ def processReply(msg){
+ log.info "Processing and Replying..."
+ log.info "Message: $msg"
+
+ msg.tag = "HELLO WORLD!"
+
+ log.info "Sending reply with > tag:${msg.tag}"
log.info msg
+
+ msg
}
}
View
1  ...on-endpoints/src/main/groovy/com/itprosmx/spring/integration/ServiceActivatorModel.groovy
@@ -14,4 +14,5 @@ class ServiceActivatorModel {
String name
String phone
Date birthday
+ String tag
}
View
14 01-spring-integration-endpoints/src/main/resources/META-INF/spring/endpoints-context.xml
@@ -17,7 +17,17 @@
<int:channel id="messageChannelSA" />
<int:service-activator input-channel="messageChannelSA" ref="serviceActivatorBean" method="process"/>
-
+ <!-- serviceActivatorReplyTest -->
+ <int:channel id="messageChannelSAReply" />
+ <int:channel id="messageChannelSAReplyOutput">
+ <int:queue capacity="10"/>
+ </int:channel>
+ <int:service-activator input-channel="messageChannelSAReply" output-channel="messageChannelSAReplyOutput" ref="serviceActivatorBean" method="processReply"/>
+
+ <!-- messageBridgeTest -->
+ <int:channel id="inputChannel" />
+ <int:channel id="outputChannel"/>
+ <int:bridge input-channel="inputChannel" output-channel="outputChannel" />
+ <int:service-activator input-channel="outputChannel" ref="serviceActivatorBean" method="process"/>
-
</beans>
View
3  01-spring-integration-endpoints/src/main/resources/log4j.xml
@@ -6,7 +6,10 @@
<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" />
+ -->
+ <param name="ConversionPattern" value="%d{HH:mm:ss.SSS} %-5p [%c{1}] %m%n" />
</layout>
</appender>
View
39 ...ntegration-endpoints/src/test/groovy/com/itprosmx/spring/integration/EndPointsTest.groovy
@@ -4,11 +4,15 @@
package com.itprosmx.spring.integration
import static org.junit.Assert.*
+import groovy.util.logging.Log4j
+import org.junit.Ignore
import org.junit.Test
import org.junit.runner.RunWith
import org.springframework.beans.factory.annotation.Autowired
import org.springframework.integration.MessageChannel
+import org.springframework.integration.channel.PublishSubscribeChannel
+import org.springframework.integration.core.PollableChannel
import org.springframework.integration.support.MessageBuilder
import org.springframework.test.context.ContextConfiguration
import org.springframework.test.context.junit4.SpringJUnit4ClassRunner
@@ -19,12 +23,23 @@ import org.springframework.test.context.junit4.SpringJUnit4ClassRunner
*/
@RunWith(SpringJUnit4ClassRunner.class)
@ContextConfiguration("/META-INF/spring/endpoints-context.xml")
+@Log4j
class EndPointsTest {
@Autowired
MessageChannel messageChannelSA
+ @Autowired
+ MessageChannel messageChannelSAReply
+ @Autowired
+ PollableChannel messageChannelSAReplyOutput
+
+ @Autowired
+ MessageChannel inputChannel
+
+
@Test
+ @Ignore
void serviceActivatorTest() {
assertNotNull messageChannelSA
@@ -37,8 +52,32 @@ class EndPointsTest {
}
@Test
+ @Ignore
+ void serviceActivatorReplyTest() {
+ assertNotNull messageChannelSAReply
+ assertNotNull messageChannelSAReplyOutput
+
+ def model = new ServiceActivatorModel(name:"John Doe",phone:"1-800-SPRING",birthday:new Date().parse("yyyy/MM/dd", "2005/01/01"))
+ assertNotNull model
+
+ def msg = MessageBuilder.withPayload(model).build()
+ assertNotNull msg
+ messageChannelSAReply.send msg
+
+ def reply = messageChannelSAReplyOutput.receive()
+ assertNotNull reply
+ log.info reply
+ }
+
+ @Test
void messageBridgeTest() {
+ assertNotNull inputChannel
+ def model = new ServiceActivatorModel(name:"John Doe",phone:"1-800-SPRING",birthday:new Date().parse("yyyy/MM/dd", "2005/01/01"))
+ assertNotNull model
+ def msg = MessageBuilder.withPayload(model).build()
+ assertNotNull msg
+ inputChannel.send msg
}
@Test
Please sign in to comment.
Something went wrong with that request. Please try again.