SimonP
Nov 10th, 2010, 11:44 AM
I am trying to create a simple spike that is an extension to one of the spring integration samples for transferring files.
In this original example the config looks like this
<bean class="org.springframework.beans.factory.config.PropertyP laceholderConfigurer"/>
<file:inbound-channel-adapter id="filesIn"
directory="file:${java.io.tmpdir}/spring-integration-samples/input"
> <!--filename-pattern="[a-z]+.txt"-->
<integration:poller id="poller" fixed-delay="5000"/>
</file:inbound-channel-adapter>
<file:file-to-string-transformer input-channel="filesIn" output-channel="strings"/>
<integration:channel id="strings"/>
<integration:service-activator input-channel="strings"
output-channel="filesOut"
ref="handler"/>
<file:outbound-channel-adapter id="filesOut" directory="file:${java.io.tmpdir}/spring-integration-samples/output"/>
<bean id="handler" class="org.springframework.integration.samples.filecopy.H andler"/>
I have changed this to
<bean class="org.springframework.beans.factory.config.PropertyP laceholderConfigurer"/>
<bean class="org.springframework.integration.aop.PublisherAnnot ationBeanPostProcessor"/>
<integration:annotation-config/>
<file:inbound-channel-adapter id="filesIn"
directory="file:${java.io.tmpdir}/spring-integration-samples/input"
> <!--filename-pattern="[a-z]+.txt"-->
<integration:poller id="poller" fixed-delay="5000"/>
</file:inbound-channel-adapter>
<file:file-to-string-transformer input-channel="filesIn" output-channel="strings"/>
<integration:channel id="strings"/>
<!-- the handler in this case is responsible for sending messages to a real Q -->
<integration:service-activator input-channel="strings" ref="handler"/> <!--output-channel="filesOut"-->
<bean id="handler" class="com.musa.spike.Handler"/>
<!-- this should be called when the FileMessageHandler gets Fired -->
<file:outbound-channel-adapter id="filesOut" directory="file:${java.io.tmpdir}/spring-integration-samples/output"/>
The handler used to just log and return the same string.
Now it does this
public void handleString(String input) {System.out.println("Sending file contents to teh default Rabbit MQ Queue");
ApplicationContext context = new AnnotationConfigApplicationContext(HelloWorldConfi guration.class);
AmqpTemplate amqpTemplate = context.getBean(AmqpTemplate.class);
amqpTemplate.convertAndSend(input);}
In a separate process I have this target setup as a message listener
public class FileMessageHandler {
@Publisher(channel="filesOut")
public String handleMessage(String text) {
System.out.println("Received: message from Rabbit MQ");
return text;
}
}
This gets called as expected but the output-channel-adapter is not being invoked.
<file:outbound-channel-adapter id="filesOut" directory="file:${java.io.tmpdir}/spring-integration-samples/output"/>
I have added
<bean class="org.springframework.integration.aop.PublisherAnnot ationBeanPostProcessor"/>
<integration:annotation-config/>
To the integration xml file. Can anyone tell me what I may have missed?
In this original example the config looks like this
<bean class="org.springframework.beans.factory.config.PropertyP laceholderConfigurer"/>
<file:inbound-channel-adapter id="filesIn"
directory="file:${java.io.tmpdir}/spring-integration-samples/input"
> <!--filename-pattern="[a-z]+.txt"-->
<integration:poller id="poller" fixed-delay="5000"/>
</file:inbound-channel-adapter>
<file:file-to-string-transformer input-channel="filesIn" output-channel="strings"/>
<integration:channel id="strings"/>
<integration:service-activator input-channel="strings"
output-channel="filesOut"
ref="handler"/>
<file:outbound-channel-adapter id="filesOut" directory="file:${java.io.tmpdir}/spring-integration-samples/output"/>
<bean id="handler" class="org.springframework.integration.samples.filecopy.H andler"/>
I have changed this to
<bean class="org.springframework.beans.factory.config.PropertyP laceholderConfigurer"/>
<bean class="org.springframework.integration.aop.PublisherAnnot ationBeanPostProcessor"/>
<integration:annotation-config/>
<file:inbound-channel-adapter id="filesIn"
directory="file:${java.io.tmpdir}/spring-integration-samples/input"
> <!--filename-pattern="[a-z]+.txt"-->
<integration:poller id="poller" fixed-delay="5000"/>
</file:inbound-channel-adapter>
<file:file-to-string-transformer input-channel="filesIn" output-channel="strings"/>
<integration:channel id="strings"/>
<!-- the handler in this case is responsible for sending messages to a real Q -->
<integration:service-activator input-channel="strings" ref="handler"/> <!--output-channel="filesOut"-->
<bean id="handler" class="com.musa.spike.Handler"/>
<!-- this should be called when the FileMessageHandler gets Fired -->
<file:outbound-channel-adapter id="filesOut" directory="file:${java.io.tmpdir}/spring-integration-samples/output"/>
The handler used to just log and return the same string.
Now it does this
public void handleString(String input) {System.out.println("Sending file contents to teh default Rabbit MQ Queue");
ApplicationContext context = new AnnotationConfigApplicationContext(HelloWorldConfi guration.class);
AmqpTemplate amqpTemplate = context.getBean(AmqpTemplate.class);
amqpTemplate.convertAndSend(input);}
In a separate process I have this target setup as a message listener
public class FileMessageHandler {
@Publisher(channel="filesOut")
public String handleMessage(String text) {
System.out.println("Received: message from Rabbit MQ");
return text;
}
}
This gets called as expected but the output-channel-adapter is not being invoked.
<file:outbound-channel-adapter id="filesOut" directory="file:${java.io.tmpdir}/spring-integration-samples/output"/>
I have added
<bean class="org.springframework.integration.aop.PublisherAnnot ationBeanPostProcessor"/>
<integration:annotation-config/>
To the integration xml file. Can anyone tell me what I may have missed?