Spring Integration file-input-output-channel-adaptor :Lab-5

We will

  • Create and test an inbound file adapter.
  • Create and test an outbound file adapter\

Here we will only be using file-inbound-channel-adapter and file-inbound-outbound-channel-adapter  channels in place of std-in-channel-adapder and stdout-channel-adapter which we have used in previous labs(Channel labs)

spring-integration-file-outbound-channel-adapter.xml

<?xml version="1.0" encoding="UTF-8"?><beans xmlns="http://www.springframework.org/schema/beans"	xmlns:int="http://www.springframework.org/schema/integration"	xmlns:int-file="http://www.springframework.org/schema/integration/file"	xmlns:xsi="http://www.w3.org/2001/XMLSchema-instance" 	xmlns:int-stream="http://www.springframework.org/schema/integration/stream"	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/stream http://www.springframework.org/schema/integration/stream/spring-integration-stream.xsd	http://www.springframework.org/schema/integration/file http://www.springframework.org/schema/integration/file/spring-integration-file.xsd">	<int-file:inbound-channel-adapter id="producer-file-adapter"       channel="messageChannel" directory="/Users/dpq/Desktop/techWorrk/fileInbound" prevent-duplicates="true">    		<int:poller fixed-rate="5000" />	</int-file:inbound-channel-adapter>		<int-file:outbound-channel-adapter channel="messageChannel" id="consumer-file-adapter" directory="/Users/dpq/Desktop/techWorrk/fileOutbound" />			<int:poller id="defaultPoller" default="true" max-messages-per-poll="5" fixed-rate="200" />	<!-- a pub/sub message channel -->	<!--<int:publish-subscribe-channel id="messageChannel" />-->	<int:channel id="messageChannel" />          </beans>

Main container loader class which will load all the beans

Startup.java

import org.springframework.context.support.ClassPathXmlApplicationContext;public class Startup {	@SuppressWarnings({ "resource", "unused" })	// @SuppressWarnings({ "resource" })	public static void main(String[] args) {		ClassPathXmlApplicationContext context = new ClassPathXmlApplicationContext(				"/META-INF/spring/spring-integration-file-inbound-outbound-channel-adapter.xml");		while (true) {		}			}}Here once we push msg file inside inbound directory "/Users/dpq/Desktop/techWorrk/fileInbound" then that message will be pushed to outbound directory "/Users/dpq/Desktop/techWorrk/fileOutbound"

Popular posts from this blog

How to change column name in Dataframe and selection of few columns in Dataframe using Pyspark with example

What is Garbage collection in Spark and its impact and resolution

Credit Card Data Analysis using PySpark (how to use auto broadcast join after disabling it)