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"?>
|
<?xml version="1.0" encoding="UTF-8"?>
|
||||||
<beans xmlns="http://www.springframework.org/schema/beans"
|
<beans xmlns="http://www.springframework.org/schema/beans"
|
||||||
xmlns:xsi="http://www.w3.org/2001/XMLSchema-instance"
|
xmlns:xsi="http://www.w3.org/2001/XMLSchema-instance" xmlns:int="http://www.springframework.org/schema/integration"
|
||||||
xmlns:int="http://www.springframework.org/schema/integration"
|
|
||||||
xmlns:file="http://www.springframework.org/schema/integration/file"
|
xmlns:file="http://www.springframework.org/schema/integration/file"
|
||||||
xmlns:ftp="http://www.springframework.org/schema/integration/ftp"
|
xmlns:ftp="http://www.springframework.org/schema/integration/ftp"
|
||||||
xmlns:mail="http://www.springframework.org/schema/integration/mail"
|
xmlns:mail="http://www.springframework.org/schema/integration/mail"
|
||||||
|
@ -14,30 +13,68 @@
|
||||||
http://www.springframework.org/schema/integration/file/spring-integration-file.xsd
|
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
|
||||||
http://www.springframework.org/schema/integration/ftp/spring-integration-ftp.xsd
|
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
|
||||||
http://www.springframework.org/schema/integration/mail/spring-integration-mail.xsd
|
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
|
||||||
http://www.springframework.org/schema/integration/twitter/spring-integration-twitter.xsd">
|
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"
|
<file:inbound-channel-adapter id="videoFolder"
|
||||||
directory="C:\projects\baeldung\clean-start-tutorials\tutorials\spring-integration\src\main\resources\source"
|
directory="/studio/edits/video" channel="videoChannel"
|
||||||
channel="videoChannel"
|
|
||||||
prevent-duplicates="true">
|
prevent-duplicates="true">
|
||||||
<int:poller fixed-rate="1000"/>
|
<int:poller fixed-rate="1000" />
|
||||||
</file:inbound-channel-adapter>
|
</file:inbound-channel-adapter>
|
||||||
|
|
||||||
<file:outbound-channel-adapter id="destFileFolder"
|
<mail:outbound-channel-adapter channel="emailOutbound"
|
||||||
directory="C:\projects\baeldung\clean-start-tutorials\tutorials\spring-integration\src\main\resources\destination"
|
mail-sender="mailSender" />
|
||||||
channel="videoChannel"
|
|
||||||
>
|
|
||||||
</file:outbound-channel-adapter>
|
|
||||||
|
|
||||||
<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"
|
<ftp:outbound-channel-adapter channel="ftpOutbound"
|
||||||
ref="customActivator"/>
|
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>
|
</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);
|
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