import org.springframework.context.support.GenericXmlApplicationContext | |
import org.springframework.core.io.ByteArrayResource | |
import org.springframework.integration.support.MessageBuilder | |
import org.springframework.messaging.MessageChannel | |
def xml = '''<?xml version="1.0" encoding="UTF-8"?> | |
<bean:beans xmlns="http://www.springframework.org/schema/integration" | |
xmlns:xsi="http://www.w3.org/2001/XMLSchema-instance" | |
xmlns:bean="http://www.springframework.org/schema/beans" | |
xsi:schemaLocation="http://www.springframework.org/schema/beans http://www.springframework.org/schema/beans/spring-beans.xsd | |
http://www.springframework.org/schema/integration http://www.springframework.org/schema/integration/spring-integration.xsd"> | |
<channel id="inCh" /> | |
<splitter input-channel="inCh" output-channel="outCh" expression="payload.?[#this % 2 == 0]"/> | |
<channel id="outCh" /> | |
<outbound-channel-adapter id="printer" channel="outCh" expression="T(java.lang.System).out.println(payload + ': ' + headers['id'])"/> | |
</bean:beans> | |
''' | |
def context = new GenericXmlApplicationContext(new ByteArrayResource(xml.bytes)) | |
def inChannel = context.getBean('inCh', MessageChannel) | |
def outChannel = context.getBean('outCh', MessageChannel) | |
inChannel.send(MessageBuilder.withPayload((1..10) as List).build()) | |
//outChannel.send(MessageBuilder.withPayload((1..10) as List).build()) | |
Thread.sleep(3000) | |
Sign up for free
to join this conversation on GitHub.
Already have an account?
Sign in to comment