BAEL-80 - spring integration
(cherry picked from commit b5c7147)
This commit is contained in:
parent
66b6ce3dbe
commit
5fa83c03d5
|
@ -1,7 +1,6 @@
|
|||
<?xml version="1.0" encoding="UTF-8"?>
|
||||
<beans xmlns="http://www.springframework.org/schema/beans"
|
||||
xmlns:xsi="http://www.w3.org/2001/XMLSchema-instance"
|
||||
xmlns:int="http://www.springframework.org/schema/integration"
|
||||
xmlns:xsi="http://www.w3.org/2001/XMLSchema-instance" xmlns:int="http://www.springframework.org/schema/integration"
|
||||
xmlns:file="http://www.springframework.org/schema/integration/file"
|
||||
xmlns:ftp="http://www.springframework.org/schema/integration/ftp"
|
||||
xmlns:mail="http://www.springframework.org/schema/integration/mail"
|
||||
|
@ -19,25 +18,63 @@
|
|||
http://www.springframework.org/schema/integration/twitter
|
||||
http://www.springframework.org/schema/integration/twitter/spring-integration-twitter.xsd">
|
||||
|
||||
<int:publish-subscribe-channel id="videoChannel" />
|
||||
|
||||
<int:bridge input-channel="videoChannel" output-channel="ftpOutbound" />
|
||||
<int:channel id="ftpOutbound" />
|
||||
<int:bridge input-channel="videoChannel" output-channel="emailOutbound" />
|
||||
<int:channel id="emailOutbound" />
|
||||
|
||||
|
||||
<int:bridge output-channel="twitterOutbound" input-channel="videoChannel" />
|
||||
|
||||
<int:channel id="twitterOutbound" />
|
||||
|
||||
<twitter:outbound-channel-adapter
|
||||
twitter-template="twitterTemplate" channel="twitterOutbound" />
|
||||
|
||||
<bean name="twitterTemplate"
|
||||
class="org.springframework.social.twitter.api.impl.TwitterTemplate">
|
||||
<constructor-arg index="0" value="${consumer-key}" />
|
||||
<constructor-arg index="1" value="${consumer-secret}" />
|
||||
<constructor-arg index="2" value="${access-token}" />
|
||||
<constructor-arg index="3" value="${access-token-secret}" />
|
||||
</bean>
|
||||
|
||||
<file:inbound-channel-adapter id="videoFolder"
|
||||
directory="C:\projects\baeldung\clean-start-tutorials\tutorials\spring-integration\src\main\resources\source"
|
||||
channel="videoChannel"
|
||||
directory="/studio/edits/video" channel="videoChannel"
|
||||
prevent-duplicates="true">
|
||||
<int:poller fixed-rate="1000" />
|
||||
</file:inbound-channel-adapter>
|
||||
|
||||
<file:outbound-channel-adapter id="destFileFolder"
|
||||
directory="C:\projects\baeldung\clean-start-tutorials\tutorials\spring-integration\src\main\resources\destination"
|
||||
channel="videoChannel"
|
||||
>
|
||||
</file:outbound-channel-adapter>
|
||||
<mail:outbound-channel-adapter channel="emailOutbound"
|
||||
mail-sender="mailSender" />
|
||||
|
||||
<int:channel id="videoChannel"/>
|
||||
<bean name="mailSender" class="org.springframework.mail.javamail.JavaMailSenderImpl">
|
||||
<property name="host" value="smtp.gmail.com" />
|
||||
<property name="port" value="587" />
|
||||
<property name="username" value="yourUsername" />
|
||||
<property name="password" value="yourPassword" />
|
||||
</bean>
|
||||
|
||||
<!-- <int:service-activator input-channel="videoChannel" output-channel="destFileFolder" method="handleMessage"
|
||||
ref="customActivator"/>
|
||||
<ftp:outbound-channel-adapter channel="ftpOutbound"
|
||||
remote-directory="/news/archive/video/" session-factory="sessionFactory" />
|
||||
|
||||
<bean name="customActivator" class="com.baeldung.samples.endpoints.ActivatorImpl"/>-->
|
||||
|
||||
|
||||
<bean name="sessionFactory"
|
||||
class="org.springframework.integration.ftp.session.DefaultFtpSessionFactory">
|
||||
<property name="host" value="localhost" />
|
||||
<property name="port" value="587" />
|
||||
<property name="username" value="yourUsername" />
|
||||
<property name="password" value="yourPassword" />
|
||||
</bean>
|
||||
|
||||
<int:bridge input-channel="videoChannel" output-channel="activatorChannel"/>
|
||||
<int:channel id="activatorChannel"/>
|
||||
|
||||
<int:service-activator input-channel="activatorChannel" method="handleMessage" ref="customActivator"/>
|
||||
|
||||
<bean name="customActivator" class="com.baeldung.samples.endpoints.ActivatorImpl"/>
|
||||
|
||||
</beans>
|
||||
|
|
|
@ -0,0 +1,62 @@
|
|||
<?xml version="1.0" encoding="UTF-8"?>
|
||||
<beans xmlns="http://www.springframework.org/schema/beans"
|
||||
xmlns:xsi="http://www.w3.org/2001/XMLSchema-instance"
|
||||
xmlns:int="http://www.springframework.org/schema/integration"
|
||||
xmlns:file="http://www.springframework.org/schema/integration/file"
|
||||
xmlns:ftp="http://www.springframework.org/schema/integration/ftp"
|
||||
xmlns:mail="http://www.springframework.org/schema/integration/mail"
|
||||
xmlns:twitter="http://www.springframework.org/schema/integration/twitter"
|
||||
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
|
||||
http://www.springframework.org/schema/integration/file
|
||||
http://www.springframework.org/schema/integration/file/spring-integration-file.xsd
|
||||
http://www.springframework.org/schema/integration/ftp
|
||||
http://www.springframework.org/schema/integration/ftp/spring-integration-ftp.xsd
|
||||
http://www.springframework.org/schema/integration/mail
|
||||
http://www.springframework.org/schema/integration/mail/spring-integration-mail.xsd
|
||||
http://www.springframework.org/schema/integration/twitter
|
||||
http://www.springframework.org/schema/integration/twitter/spring-integration-twitter.xsd">
|
||||
|
||||
<file:inbound-channel-adapter id="videoFolder"
|
||||
directory="C:\projects\baeldung\clean-start-tutorials\tutorials\spring-integration\src\main\resources\source"
|
||||
channel="videoChannel"
|
||||
prevent-duplicates="true">
|
||||
<int:poller fixed-rate="1000"/>
|
||||
</file:inbound-channel-adapter>
|
||||
|
||||
<file:outbound-channel-adapter id="destFileFolder"
|
||||
directory="C:\projects\baeldung\clean-start-tutorials\tutorials\spring-integration\src\main\resources\destination"
|
||||
|
||||
>
|
||||
</file:outbound-channel-adapter>
|
||||
|
||||
<int:publish-subscribe-channel id="videoChannel" />
|
||||
|
||||
<int:channel id="emailOutbound" />
|
||||
|
||||
<mail:outbound-channel-adapter channel="emailOutbound"
|
||||
mail-sender="mailSender" />
|
||||
|
||||
<file:file-to-bytes-transformer
|
||||
input-channel="videoChannel"
|
||||
output-channel="emailOutbound"
|
||||
delete-files="false"/>
|
||||
|
||||
<mail:header-enricher input-channel="videoChannel" output-channel="emailOutbound">
|
||||
<mail:attachment-filename value="test"/>
|
||||
</mail:header-enricher>
|
||||
|
||||
<bean name="mailSender" class="org.springframework.mail.javamail.JavaMailSenderImpl">
|
||||
<property name="host" value="smtp.gmail.com" />
|
||||
<property name="port" value="587" />
|
||||
<property name="username" value="${username}" />
|
||||
<property name="password" value="${password}" />
|
||||
</bean>
|
||||
|
||||
<int:bridge input-channel="videoChannel" output-channel="destFileFolder" />
|
||||
<int:bridge input-channel="videoChannel" output-channel="emailOutbound" />
|
||||
|
||||
|
||||
</beans>
|
Binary file not shown.
After Width: | Height: | Size: 760 KiB |
|
@ -44,5 +44,17 @@ public final class FileCopyTest {
|
|||
Thread.sleep(5000);
|
||||
|
||||
|
||||
}
|
||||
|
||||
@Test
|
||||
public void publish() throws InterruptedException {
|
||||
|
||||
|
||||
final AbstractApplicationContext context =
|
||||
new ClassPathXmlApplicationContext("classpath:META-INF/spring/integration/spring-integration-file-publish-context.xml");
|
||||
|
||||
Thread.sleep(15000);
|
||||
|
||||
|
||||
}
|
||||
}
|
||||
|
|
Loading…
Reference in New Issue