├── .gitattributes
├── .gitignore
├── README.md
├── feedsexample
├── .classpath
├── .project
├── .settings
│ ├── com.springsource.sts.config.flow.prefs
│ ├── org.eclipse.core.resources.prefs
│ ├── org.eclipse.jdt.core.prefs
│ └── org.eclipse.m2e.core.prefs
├── README.txt
├── pom.xml
└── src
│ └── main
│ ├── java
│ └── com
│ │ └── cpandey
│ │ └── siexample
│ │ ├── FeedsExample.java
│ │ ├── aggregator
│ │ ├── CompletionStrategy.java
│ │ ├── CorrelationStrategy.java
│ │ └── SoFeedAggregator.java
│ │ ├── filter
│ │ └── SoFeedFilter.java
│ │ ├── jmx
│ │ ├── ControlBusTest.java
│ │ ├── NotificationListener.java
│ │ ├── NotificationPublisher.java
│ │ └── TestMBean.java
│ │ ├── pojo
│ │ ├── FeedEntity.java
│ │ └── SoFeed.java
│ │ ├── service
│ │ ├── CommonServiceActivator.java
│ │ ├── FeedService.java
│ │ ├── PersistFeed.java
│ │ └── PrintFeed.java
│ │ ├── splitter
│ │ └── SoFeedSplitter.java
│ │ └── transformer
│ │ ├── SoFeedDbTransformer.java
│ │ ├── SoFeedJMSTransformer.java
│ │ └── SoFeedMailTransformer.java
│ └── resources
│ ├── META-INF
│ └── spring
│ │ └── integration
│ │ ├── spring-integration-context.xml
│ │ ├── spring-integration-ftp.xml
│ │ ├── spring-integration-hibernate.xml
│ │ ├── spring-integration-jms.xml
│ │ └── spring-integration-jmx.xml
│ ├── log4j.xml
│ └── settings.properties
├── siexample
├── .classpath
├── .project
├── .settings
│ ├── com.springsource.sts.config.flow.prefs
│ ├── org.eclipse.core.resources.prefs
│ └── org.eclipse.jdt.core.prefs
├── README.txt
├── pom.xml
└── src
│ ├── main
│ ├── java
│ │ └── com
│ │ │ └── cpandey
│ │ │ └── siexample
│ │ │ ├── Aggregator.java
│ │ │ ├── BatchJobLauncher.java
│ │ │ ├── EndpointsMailJmsDb.java
│ │ │ ├── FTPIntegration.java
│ │ │ ├── FileIntegration.java
│ │ │ ├── InboundFileAdapter.java
│ │ │ ├── Resequencer.java
│ │ │ ├── SocialIntegration.java
│ │ │ ├── SpringIntegrationBatchJobLauncher.java
│ │ │ ├── aggregator
│ │ │ ├── CompletionStrategy.java
│ │ │ ├── CorrelationStrategy.java
│ │ │ └── SoFeedAggregator.java
│ │ │ ├── batch
│ │ │ ├── BatchJdbcConfiguration.java
│ │ │ ├── BatchStatusServiceActivator.java
│ │ │ ├── Employee.java
│ │ │ ├── EmployeeFieldSetMapper.java
│ │ │ ├── EmployeeRecordWriter.java
│ │ │ └── FileMessageToJobRequest.java
│ │ │ ├── filter
│ │ │ └── SoFeedFilter.java
│ │ │ ├── pojo
│ │ │ ├── FeedEntity.java
│ │ │ └── SoFeed.java
│ │ │ ├── resequencer
│ │ │ ├── ResequencerCompletionStrategy.java
│ │ │ └── ResequencerCorrelationStrategy.java
│ │ │ ├── service
│ │ │ ├── CommonServiceActivator.java
│ │ │ ├── EmailSender.java
│ │ │ ├── FeedService.java
│ │ │ ├── PersistFeed.java
│ │ │ └── PrintFeed.java
│ │ │ ├── splitter
│ │ │ └── SoFeedSplitter.java
│ │ │ └── transformer
│ │ │ ├── SoFeedDbTransformer.java
│ │ │ ├── SoFeedJMSTransformer.java
│ │ │ └── SoFeedMailTransformer.java
│ └── resources
│ │ ├── H2DB-CreateScript.sql
│ │ ├── H2DB-DropScript.sql
│ │ ├── H2DB-InsertScript.sql
│ │ ├── META-INF
│ │ └── spring
│ │ │ └── integration
│ │ │ ├── common-jpa-context.xml
│ │ │ ├── email-config.xml
│ │ │ ├── employee.input
│ │ │ ├── hibernate-config.xml
│ │ │ ├── jms-config.xml
│ │ │ ├── setting.properties
│ │ │ ├── spring-integration-aggregator.xml
│ │ │ ├── spring-integration-batch.xml
│ │ │ ├── spring-integration-database.xml
│ │ │ ├── spring-integration-endpoints.xml
│ │ │ ├── spring-integration-file.xml
│ │ │ ├── spring-integration-ftp.xml
│ │ │ ├── spring-integration-jms.xml
│ │ │ ├── spring-integration-resequencer.xml
│ │ │ ├── spring-integration-stream.xml
│ │ │ └── spring-integration-twitter.xml
│ │ └── log4j.xml
│ └── test
│ ├── java
│ └── com
│ │ └── cpandey
│ │ └── siexample
│ │ ├── TestFilter.java
│ │ ├── TestSoDBFeedTransformer.java
│ │ ├── TestSoHeaderAddition.java
│ │ └── TestSplitter.java
│ └── resources
│ ├── TestFilter-context.xml
│ ├── TestSoDBFeedTransformer-context.xml
│ ├── TestSoHeaderAddition-context.xml
│ └── TestSplitter-context.xml
├── siexamplehttpinboundoutbound
├── .classpath
├── .project
├── .settings
│ ├── .jsdtscope
│ ├── com.springsource.sts.config.flow.prefs
│ ├── org.eclipse.jdt.core.prefs
│ ├── org.eclipse.m2e.core.prefs
│ ├── org.eclipse.wst.common.component
│ ├── org.eclipse.wst.common.project.facet.core.xml
│ ├── org.eclipse.wst.jsdt.ui.superType.container
│ ├── org.eclipse.wst.jsdt.ui.superType.name
│ └── org.eclipse.wst.validation.prefs
├── README.txt
├── pom.xml
└── src
│ ├── main
│ ├── java
│ │ └── com
│ │ │ └── cpandey
│ │ │ └── siexample
│ │ │ ├── HttpOutBoundClient.java
│ │ │ └── OutboundRequestGateway.java
│ ├── resources
│ │ └── META-INF
│ │ │ └── spring
│ │ │ └── integration
│ │ │ └── http-outbound-config.xml
│ └── webapp
│ │ ├── WEB-INF
│ │ ├── http-inbound-config.xml
│ │ └── web.xml
│ │ ├── index.html
│ │ └── index.jsp
│ └── test
│ └── com
│ └── cpandey
│ └── siexample
│ └── WsInBoundTest.java
└── siexamplewsinboundoutbound
├── .classpath
├── .project
├── .settings
├── .jsdtscope
├── com.springsource.sts.config.flow.prefs
├── org.eclipse.jdt.core.prefs
├── org.eclipse.m2e.core.prefs
├── org.eclipse.wst.common.component
├── org.eclipse.wst.common.project.facet.core.xml
├── org.eclipse.wst.jsdt.ui.superType.container
├── org.eclipse.wst.jsdt.ui.superType.name
└── org.eclipse.wst.validation.prefs
├── README.txt
├── pom.xml
└── src
├── main
├── java
│ └── com
│ │ └── cpandey
│ │ └── siexample
│ │ ├── WsDemoApp.java
│ │ └── WsInboundService.java
├── resources
│ └── META-INF
│ │ └── spring
│ │ └── integration
│ │ └── temperatureConversion.xml
└── webapp
│ ├── WEB-INF
│ ├── web.xml
│ └── ws-inbound-config.xml
│ └── index.html
└── test
└── com
└── cpandey
└── siexample
└── WsInBound.java
/.gitattributes:
--------------------------------------------------------------------------------
1 | # Auto detect text files and perform LF normalization
2 | * text=auto
3 |
4 | # Custom for Visual Studio
5 | *.cs diff=csharp
6 |
7 | # Standard to msysgit
8 | *.doc diff=astextplain
9 | *.DOC diff=astextplain
10 | *.docx diff=astextplain
11 | *.DOCX diff=astextplain
12 | *.dot diff=astextplain
13 | *.DOT diff=astextplain
14 | *.pdf diff=astextplain
15 | *.PDF diff=astextplain
16 | *.rtf diff=astextplain
17 | *.RTF diff=astextplain
18 |
--------------------------------------------------------------------------------
/.gitignore:
--------------------------------------------------------------------------------
1 | # Windows image file caches
2 | Thumbs.db
3 | ehthumbs.db
4 |
5 | # Folder config file
6 | Desktop.ini
7 |
8 | # Recycle Bin used on file shares
9 | $RECYCLE.BIN/
10 |
11 | # Windows Installer files
12 | *.cab
13 | *.msi
14 | *.msm
15 | *.msp
16 |
17 | # Windows shortcuts
18 | *.lnk
19 |
20 | # =========================
21 | # Operating System Files
22 | # =========================
23 |
24 | # OSX
25 | # =========================
26 |
27 | .DS_Store
28 | .AppleDouble
29 | .LSOverride
30 |
31 | # Thumbnails
32 | ._*
33 |
34 | # Files that might appear on external disk
35 | .Spotlight-V100
36 | .Trashes
37 |
38 | # Directories potentially created on remote AFP share
39 | .AppleDB
40 | .AppleDesktop
41 | Network Trash Folder
42 | Temporary Items
43 | .apdisk
44 |
--------------------------------------------------------------------------------
/README.md:
--------------------------------------------------------------------------------
1 | # siessentials
2 |
Code sample for my book Spring Integration Essentials
3 | There are four Maven project, each one have its individual Readme.TXT
4 | Quick Summary
5 | - feedsexample -end to end example for chapter 10
6 | - siexample -contains code for all other chapter, Readme has details for each
7 | - siexamplehttpinboundoutbound -This is a deployable war to show HTTP Inbound adapter
8 | - siexamplewsinboundoutbound -This is a deployable war to show WS Inbound adapter
9 |
--------------------------------------------------------------------------------
/feedsexample/.classpath:
--------------------------------------------------------------------------------
1 |
2 |
3 |
4 |
5 |
6 |
7 |
8 |
9 |
10 |
11 |
12 |
13 |
14 |
15 |
16 |
17 |
18 |
19 |
20 |
21 |
22 |
23 |
24 |
25 |
26 |
27 |
28 |
29 |
30 |
31 |
32 |
--------------------------------------------------------------------------------
/feedsexample/.project:
--------------------------------------------------------------------------------
1 |
2 |
3 | feedsexample
4 |
5 |
6 |
7 |
8 |
9 | org.eclipse.jdt.core.javabuilder
10 |
11 |
12 |
13 |
14 | org.springframework.ide.eclipse.core.springbuilder
15 |
16 |
17 |
18 |
19 | org.eclipse.m2e.core.maven2Builder
20 |
21 |
22 |
23 |
24 |
25 | org.springframework.ide.eclipse.core.springnature
26 | org.eclipse.jdt.core.javanature
27 | org.eclipse.m2e.core.maven2Nature
28 |
29 |
30 |
--------------------------------------------------------------------------------
/feedsexample/.settings/org.eclipse.core.resources.prefs:
--------------------------------------------------------------------------------
1 | eclipse.preferences.version=1
2 | encoding//src/main/java=UTF-8
3 | encoding//src/main/resources=UTF-8
4 | encoding//src/test/java=UTF-8
5 | encoding/=UTF-8
6 |
--------------------------------------------------------------------------------
/feedsexample/.settings/org.eclipse.jdt.core.prefs:
--------------------------------------------------------------------------------
1 | eclipse.preferences.version=1
2 | org.eclipse.jdt.core.compiler.codegen.targetPlatform=1.6
3 | org.eclipse.jdt.core.compiler.compliance=1.6
4 | org.eclipse.jdt.core.compiler.problem.forbiddenReference=warning
5 | org.eclipse.jdt.core.compiler.source=1.6
6 |
--------------------------------------------------------------------------------
/feedsexample/.settings/org.eclipse.m2e.core.prefs:
--------------------------------------------------------------------------------
1 | activeProfiles=
2 | eclipse.preferences.version=1
3 | resolveWorkspaceProjects=true
4 | version=1
5 |
--------------------------------------------------------------------------------
/feedsexample/README.txt:
--------------------------------------------------------------------------------
1 | Build the Maven project to download all dependencies "mvn -X clean package"
2 |
3 | Refer /META-INF/spring/integration/setting.properties for all the values which can be set
4 |
5 | All classes needed to run sample App are inside package com.cpandey.siexample
6 | -select any of those and then "run as Java" program
7 |
8 | Following are the details classes which map to chapter wise samples
9 |
10 | Chapter 1-5
11 | Gateway, Service Activator, Router, Filter, Splitter -EndpointsMailJmsDb.java
12 | Aggregator, ChainingHandler -Aggregator.java
13 | Resequencer, Enricher -Resequencer.java
14 | Chapter 6
15 | FTP/FTPS FTPIntegration
16 | Twitter, SocialIntegration
17 | JMS, EndpointsMailJmsDb
18 | Mail EndpointsMailJmsDb
19 | Database EndpointsMailJmsDb
20 | HTTP -Separate Project, to be deployed inside tomcat : siexamplehttpinboundoutbound
21 | WebService -Separate Project, to be deployed inside tomcat : siexamplewsinboundoutbound
22 | Chapter 7
23 | Spring Batch BatchJobLauncher.java and SpringIntegrationBatchJobLauncher.java
24 | Chapter 8
25 | Testing Files under src/test/java
26 | Chapter 9 and 10
27 | JMX and an End to End example :Separate project : feedsexample
28 |
--------------------------------------------------------------------------------
/feedsexample/pom.xml:
--------------------------------------------------------------------------------
1 |
3 | 4.0.0
4 |
5 | feedsexample
6 | feedsexample
7 | 1.0.0.BUILD-SNAPSHOT
8 | jar
9 |
10 | feedsexample
11 |
12 |
13 | 2.2.1
14 |
15 |
16 |
17 | UTF-8
18 | 4.0.1.RELEASE
19 | 4.0.3.RELEASE
20 | 1.2.17
21 | 4.11
22 | 5.7.0
23 | 4.0.1.Final
24 |
25 |
26 |
27 |
28 | repo.springsource.org.milestone
29 | Spring Framework Maven Milestone Repository
30 | https://repo.springsource.org/milestone
31 |
32 |
33 |
34 |
35 |
36 |
37 | maven-eclipse-plugin
38 | 2.9
39 |
40 |
41 | org.springframework.ide.eclipse.core.springnature
42 |
43 |
44 | org.springframework.ide.eclipse.core.springbuilder
45 |
46 | true
47 | true
48 |
49 |
50 |
51 | org.apache.maven.plugins
52 | maven-compiler-plugin
53 | 3.1
54 |
55 | 1.6
56 | 1.6
57 | -Xlint:all
58 | true
59 | true
60 |
61 |
62 |
63 | org.codehaus.mojo
64 | exec-maven-plugin
65 | 1.2.1
66 |
67 | com.cpandey.siexample.Main
68 |
69 |
70 |
71 |
72 |
73 |
74 |
75 |
76 |
77 | commons-lang
78 | commons-lang
79 | 2.6
80 |
81 |
82 |
83 | junit
84 | junit
85 | ${junit.version}
86 | test
87 |
88 |
89 | org.springframework.integration
90 | spring-integration-test
91 | ${spring.integration.version}
92 |
93 |
94 | org.springframework
95 | spring-test
96 | ${spring.version}
97 | test
98 |
99 |
100 |
101 |
102 |
103 | org.springframework.integration
104 | spring-integration-core
105 | ${spring.integration.version}
106 |
107 |
108 |
109 | org.springframework.integration
110 | spring-integration-feed
111 | ${spring.integration.version}
112 |
113 |
114 | org.springframework.integration
115 | spring-integration-mail
116 | ${spring.integration.version}
117 |
118 |
119 | org.springframework.integration
120 | spring-integration-jms
121 | ${spring.integration.version}
122 |
123 |
124 | org.springframework.integration
125 | spring-integration-stream
126 | ${spring.integration.version}
127 |
128 |
129 | org.springframework.integration
130 | spring-integration-jpa
131 | ${spring.integration.version}
132 |
133 |
134 | org.springframework.integration
135 | spring-integration-ftp
136 | ${spring.integration.version}
137 |
138 |
139 |
140 |
141 | log4j
142 | log4j
143 | ${log4j.version}
144 |
145 |
146 |
147 |
148 | javax.activation
149 | activation
150 | 1.1.1
151 | true
152 |
153 |
154 | javax.mail
155 | mail
156 | 1.4.5
157 |
158 |
159 | org.apache.velocity
160 | velocity
161 | 1.7
162 |
163 |
164 |
165 |
166 |
167 | org.apache.activemq
168 | activemq-core
169 | ${activemq.version}
170 |
171 |
172 | spring-context
173 | org.springframework
174 |
175 |
176 |
177 |
178 | org.springframework
179 | spring-jms
180 | ${spring.version}
181 | compile
182 |
183 |
184 |
185 |
186 |
187 | com.h2database
188 | h2
189 | 1.3.168
190 |
191 |
192 |
193 |
194 | org.hibernate
195 | hibernate-entitymanager
196 | ${hibernate.version}
197 |
198 |
199 |
200 | org.springframework.integration
201 | spring-integration-jdbc
202 | ${spring.integration.version}
203 |
204 |
205 | org.springframework.integration
206 | spring-integration-jmx
207 | ${spring.integration.version}
208 |
209 |
210 |
211 |
212 |
--------------------------------------------------------------------------------
/feedsexample/src/main/java/com/cpandey/siexample/FeedsExample.java:
--------------------------------------------------------------------------------
1 |
2 | package com.cpandey.siexample;
3 |
4 | import org.springframework.context.support.AbstractApplicationContext;
5 | import org.springframework.context.support.ClassPathXmlApplicationContext;
6 |
7 |
8 | /**
9 | * Starts the Spring Context and will initialize the Spring Integration routes.
10 | *
11 | * @author Chandan Pandey
12 | *
13 | */
14 | public final class FeedsExample {
15 | private FeedsExample() { }
16 |
17 | public static void main(final String... args) {
18 | final AbstractApplicationContext context =
19 | new ClassPathXmlApplicationContext("classpath:META-INF/spring/integration/spring-integration-context.xml");
20 | }
21 | }
22 |
--------------------------------------------------------------------------------
/feedsexample/src/main/java/com/cpandey/siexample/aggregator/CompletionStrategy.java:
--------------------------------------------------------------------------------
1 | package com.cpandey.siexample.aggregator;
2 |
3 | import java.util.List;
4 |
5 | import org.apache.log4j.Logger;
6 |
7 | import com.sun.syndication.feed.synd.SyndEntry;
8 |
9 | /**
10 | * Decides based on criteria, whether all the components of the incomplete message
11 | * has been assembled
12 | *
13 | * @author Chandan Pandey
14 | *
15 | */
16 | public class CompletionStrategy {
17 | private static final Logger LOGGER = Logger.getLogger(CompletionStrategy.class);
18 | //Completion strategy is used by aggregator to decide whether all components has
19 | //been aggregated or not method should expect a java.util.List
20 | //Object returning a Boolean value
21 | public boolean checkCompleteness(List messages) {
22 | if(messages!=null){
23 | if(messages.size()>2){
24 | LOGGER.info("All components assembled, releasing aggregated message");
25 | return true;
26 | }
27 | }
28 | return false;
29 | }
30 |
31 | }
32 |
--------------------------------------------------------------------------------
/feedsexample/src/main/java/com/cpandey/siexample/aggregator/CorrelationStrategy.java:
--------------------------------------------------------------------------------
1 | package com.cpandey.siexample.aggregator;
2 |
3 | import java.util.List;
4 |
5 | import org.apache.log4j.Logger;
6 | import org.springframework.messaging.Message;
7 |
8 | import com.sun.syndication.feed.synd.SyndCategoryImpl;
9 | import com.sun.syndication.feed.synd.SyndEntry;
10 |
11 | /**
12 | * Correlates messages for aggregation based on the logic defined.
13 | *
14 | * @author Chandan Pandey
15 | *
16 | */
17 | public class CorrelationStrategy {
18 | private static final Logger LOGGER = Logger.getLogger(CorrelationStrategy.class);
19 |
20 | //aggregator’s method should expect a Message> and return an Object.
21 | public Object groupFeedsBasedOnCategory(Message> message) {
22 | //Which messages will be grouped in a bucket
23 | //-say based on category, based on some ID etc.
24 | if(message!=null){
25 | SyndEntry entry = (SyndEntry)message.getPayload();
26 | List categories=entry.getCategories();
27 | if(categories!=null&&categories.size()>0){
28 | for (SyndCategoryImpl category: categories) {
29 | //for simplicity, lets consider the first category
30 | LOGGER.info("category "+category.getName());
31 | return category.getName();
32 | }
33 | }
34 | }
35 | return null;
36 | }
37 | }
38 |
--------------------------------------------------------------------------------
/feedsexample/src/main/java/com/cpandey/siexample/aggregator/SoFeedAggregator.java:
--------------------------------------------------------------------------------
1 | package com.cpandey.siexample.aggregator;
2 |
3 | import java.util.List;
4 |
5 | import org.apache.log4j.Logger;
6 |
7 | import com.sun.syndication.feed.synd.SyndEntry;
8 | /**
9 | * Decides when all the components of the incomplete message has been delivered
10 | *
11 | * @author Chandan Pandey
12 | *
13 | */
14 | public class SoFeedAggregator {
15 | private static final Logger LOGGER = Logger.getLogger(SoFeedAggregator.class);
16 | public List aggregateAndPublish( List messages) {
17 | LOGGER.info("SoFeedAggregator -Aggregation complete ");
18 | return messages;
19 | }
20 | }
21 |
--------------------------------------------------------------------------------
/feedsexample/src/main/java/com/cpandey/siexample/filter/SoFeedFilter.java:
--------------------------------------------------------------------------------
1 | package com.cpandey.siexample.filter;
2 |
3 | import java.util.List;
4 |
5 | import org.apache.log4j.Logger;
6 | import org.springframework.messaging.Message;
7 |
8 | import com.sun.syndication.feed.synd.SyndCategoryImpl;
9 | import com.sun.syndication.feed.synd.SyndEntry;
10 | /**
11 | * Decides based on criteria, whether all the components of the incomplete message
12 | * has been assembled
13 | *
14 | * @author Chandan Pandey
15 | *
16 | */
17 | public class SoFeedFilter {
18 | private static final Logger LOGGER = Logger.getLogger(SoFeedFilter.class);
19 | public boolean filterFeed(Message message){
20 | SyndEntry entry = message.getPayload();
21 | List categories=entry.getCategories();
22 | if(categories!=null&&categories.size()>0){
23 | for (SyndCategoryImpl category: categories) {
24 | if(category.getName().equalsIgnoreCase("java")){
25 | LOGGER.info("JAVA category feed");
26 | return true;
27 | }
28 | }
29 | }
30 | return false;
31 | }
32 | }
33 |
--------------------------------------------------------------------------------
/feedsexample/src/main/java/com/cpandey/siexample/jmx/ControlBusTest.java:
--------------------------------------------------------------------------------
1 | package com.cpandey.siexample.jmx;
2 |
3 | import org.apache.log4j.Logger;
4 | import org.springframework.jmx.export.annotation.ManagedOperation;
5 | import org.springframework.stereotype.Component;
6 |
7 | @Component
8 | public class ControlBusTest {
9 | private static final Logger LOGGER = Logger.getLogger(ControlBusTest.class);
10 | @ManagedOperation
11 | public void controlTestOperation() {
12 | LOGGER.info("controlTestOperation");
13 | }
14 | }
15 |
--------------------------------------------------------------------------------
/feedsexample/src/main/java/com/cpandey/siexample/jmx/NotificationListener.java:
--------------------------------------------------------------------------------
1 | package com.cpandey.siexample.jmx;
2 |
3 | import org.springframework.context.support.AbstractApplicationContext;
4 | import org.springframework.context.support.ClassPathXmlApplicationContext;
5 |
6 | public class NotificationListener {
7 | public static void main(String[] args) {
8 | final AbstractApplicationContext context =
9 | new ClassPathXmlApplicationContext("classpath:META-INF/spring/integration/spring-integration-context.xml");
10 | try {
11 | Thread.sleep(300000);
12 | } catch (InterruptedException e) {
13 | //do nothing
14 | }
15 | context.stop();
16 |
17 | }
18 | }
19 |
--------------------------------------------------------------------------------
/feedsexample/src/main/java/com/cpandey/siexample/jmx/NotificationPublisher.java:
--------------------------------------------------------------------------------
1 | package com.cpandey.siexample.jmx;
2 |
3 | import org.apache.log4j.Logger;
4 | import org.springframework.context.support.AbstractApplicationContext;
5 | import org.springframework.context.support.ClassPathXmlApplicationContext;
6 | import org.springframework.integration.support.MessageBuilder;
7 | import org.springframework.messaging.MessageChannel;
8 |
9 | public class NotificationPublisher {
10 | private static final Logger LOGGER = Logger.getLogger(NotificationPublisher.class);
11 | public static void main(String[] args) {
12 | final AbstractApplicationContext context =
13 | new ClassPathXmlApplicationContext("classpath:META-INF/spring/integration/spring-integration-context.xml");
14 | try {
15 | Thread.sleep(60000);
16 | } catch (InterruptedException e) {
17 | //do nothing
18 | }
19 | MessageChannel publishNotification = context.getBean("publishNotification", MessageChannel.class);
20 | publishNotification.send(MessageBuilder.withPayload("Sample Message").build());
21 |
22 | MessageChannel triggerOperationChannel = context.getBean("triggerOperationChannel", MessageChannel.class);
23 | triggerOperationChannel.send(MessageBuilder.withPayload("Trigger Method Adapter").build());
24 |
25 | MessageChannel requestOperationChannel = context.getBean("requestOperationChannel", MessageChannel.class);
26 | requestOperationChannel.send(MessageBuilder.withPayload("Trigger Method Gateway").build());
27 |
28 | MessageChannel input = context.getBean("controlBusChannel", MessageChannel.class);
29 | String controlMessage = "@controlBusTest.controlTestOperation()";
30 | LOGGER.info("Sending message: " + controlMessage);
31 | input.send(MessageBuilder.withPayload(controlMessage).build());
32 |
33 | try {
34 | Thread.sleep(180000);
35 | } catch (InterruptedException e) {
36 | //do nothing
37 | }
38 | context.stop();
39 | }
40 | }
41 |
--------------------------------------------------------------------------------
/feedsexample/src/main/java/com/cpandey/siexample/jmx/TestMBean.java:
--------------------------------------------------------------------------------
1 | package com.cpandey.siexample.jmx;
2 |
3 | import javax.management.Notification;
4 | import org.springframework.jmx.export.annotation.ManagedAttribute;
5 | import org.springframework.jmx.export.annotation.ManagedOperation;
6 | import org.springframework.jmx.export.annotation.ManagedResource;
7 | import org.springframework.jmx.export.notification.NotificationPublisher;
8 | import org.springframework.jmx.export.notification.NotificationPublisherAware;
9 | import org.springframework.stereotype.Component;
10 |
11 | @Component
12 | @ManagedResource
13 | public class TestMBean implements NotificationPublisherAware{
14 | private NotificationPublisher notificationPublisher;
15 | private String managedData;
16 |
17 | @ManagedAttribute
18 | public String getManagedData() {
19 | return managedData;
20 | }
21 | @ManagedAttribute
22 | public void setManagedData(String managedData) {
23 | this.managedData = managedData;
24 | }
25 | @ManagedOperation
26 | public Integer testAdd(Integer num1, Integer num2) {
27 | notificationPublisher.sendNotification(new Notification("testAdd", this, 0));
28 | return num1 + num2;
29 | }
30 | @Override
31 | public void setNotificationPublisher(NotificationPublisher notificationPublisher) {
32 | this.notificationPublisher = notificationPublisher;
33 | }
34 | }
35 |
--------------------------------------------------------------------------------
/feedsexample/src/main/java/com/cpandey/siexample/pojo/FeedEntity.java:
--------------------------------------------------------------------------------
1 | package com.cpandey.siexample.pojo;
2 |
3 | import java.util.Date;
4 |
5 | import javax.persistence.Column;
6 | import javax.persistence.Entity;
7 | import javax.persistence.GeneratedValue;
8 | import javax.persistence.GenerationType;
9 | import javax.persistence.Id;
10 | import javax.persistence.Table;
11 | import javax.persistence.Temporal;
12 | import javax.persistence.TemporalType;
13 | /**
14 | *An entity class to store feed data
15 | *
16 | * @author Chandan Pandey
17 | *
18 | */
19 | @Entity
20 | @Table(name="FEED")
21 | public class FeedEntity {
22 |
23 | @Id
24 | @GeneratedValue(strategy=GenerationType.AUTO)
25 | private int id;
26 |
27 | private String title;
28 |
29 | @Temporal(TemporalType.TIMESTAMP)
30 | @Column(name="CREATED_DATE_TIME")
31 | private Date createdDateTime;
32 |
33 | public FeedEntity() {
34 | super();
35 | this.createdDateTime = new Date();
36 | }
37 |
38 | public FeedEntity(String title) {
39 | super();
40 | this.title = title;
41 | this.createdDateTime = new Date();
42 | }
43 |
44 | public int getId() {
45 | return id;
46 | }
47 |
48 | public void setId(int id) {
49 | this.id = id;
50 | }
51 |
52 | public String getTitle() {
53 | return title;
54 | }
55 |
56 | public void setTitle(String title) {
57 | this.title = title;
58 | }
59 |
60 | public Date getCreatedDateTime() {
61 | return createdDateTime;
62 | }
63 |
64 | public void setCreatedDateTime(Date createdDateTime) {
65 | this.createdDateTime = createdDateTime;
66 | }
67 |
68 | @Override
69 | public int hashCode() {
70 | final int prime = 31;
71 | int result = 1;
72 | result = prime * result + ((title == null) ? 0 : title.hashCode());
73 | return result;
74 | }
75 |
76 | @Override
77 | public boolean equals(Object obj) {
78 | if (this == obj) {
79 | return true;
80 | }
81 | if (obj == null) {
82 | return false;
83 | }
84 | if (getClass() != obj.getClass()) {
85 | return false;
86 | }
87 | FeedEntity other = (FeedEntity) obj;
88 | if (title == null) {
89 | if (other.title != null) {
90 | return false;
91 | }
92 | } else if (!title.equals(other.title)) {
93 | return false;
94 | }
95 | return true;
96 | }
97 | }
98 |
--------------------------------------------------------------------------------
/feedsexample/src/main/java/com/cpandey/siexample/pojo/SoFeed.java:
--------------------------------------------------------------------------------
1 | package com.cpandey.siexample.pojo;
2 |
3 | import java.util.List;
4 |
5 | import com.sun.syndication.feed.synd.SyndCategoryImpl;
6 | /**
7 | * Mapping from SyndEntry to Internal Domain class
8 | *
9 | * @author Chandan Pandey
10 | *
11 | */
12 | public class SoFeed {
13 | private String title;
14 | private String description;
15 | private String link;
16 | private String author;
17 |
18 | private List categories;
19 |
20 | public String getTitle() {
21 | return title;
22 | }
23 | public void setTitle(String title) {
24 | this.title = title;
25 | }
26 | public String getDescription() {
27 | return description;
28 | }
29 | public void setDescription(String description) {
30 | this.description = description;
31 | }
32 | public String getLink() {
33 | return link;
34 | }
35 | public void setLink(String link) {
36 | this.link = link;
37 | }
38 | public String getAuthor() {
39 | return author;
40 | }
41 | public void setAuthor(String author) {
42 | this.author = author;
43 | }
44 | public List getCategories() {
45 | return categories;
46 | }
47 | public void setCategories(List categories) {
48 | this.categories = categories;
49 | }
50 | @Override
51 | public String toString() {
52 | StringBuffer str=new StringBuffer();
53 | str.append(title==null?"":title);
54 | str.append(description==null?"":description);
55 | str.append(link==null?"":link);
56 | str.append(author==null?"":author);
57 | if(categories!=null&&categories.size()>0){
58 | for (SyndCategoryImpl category: categories) {
59 | str.append(category.getName());
60 |
61 | }
62 | }
63 | return str.toString();
64 | }
65 | }
66 |
--------------------------------------------------------------------------------
/feedsexample/src/main/java/com/cpandey/siexample/service/CommonServiceActivator.java:
--------------------------------------------------------------------------------
1 | package com.cpandey.siexample.service;
2 | /**
3 | *A common service activator, used by multiple components for testing code
4 | *
5 | * @author Chandan Pandey
6 | *
7 | */
8 | import java.util.Iterator;
9 | import java.util.List;
10 | import java.util.Properties;
11 |
12 | import org.apache.log4j.Logger;
13 | import org.springframework.integration.annotation.MessageEndpoint;
14 | import org.springframework.integration.history.MessageHistory;
15 | import org.springframework.messaging.Message;
16 |
17 | import com.sun.syndication.feed.synd.SyndEntry;
18 |
19 |
20 | @MessageEndpoint
21 | public class CommonServiceActivator {
22 | private static final Logger LOGGER = Logger.getLogger(CommonServiceActivator.class);
23 |
24 | public void printAggregatedFeed(Message> aggregatedMessage ) {
25 | if(aggregatedMessage!=null){
26 | List syndEntries=aggregatedMessage.getPayload();
27 | LOGGER.info("Aggregated entry size "+syndEntries.size());
28 | }
29 | }
30 |
31 | public void printPayLoad(Message> message) {
32 | if(message!=null){
33 | LOGGER.info("Message Payload "+message.getPayload());
34 | }else{
35 | LOGGER.info("Message is null");
36 | }
37 |
38 | }
39 |
40 | public void echoMessageInput(Message> message) {
41 | if(message!=null){
42 | LOGGER.info("Message Input "+message.getPayload());
43 | }else{
44 | LOGGER.info("Message is null");
45 | }
46 | }
47 | public void echoJmsMessageInput(Message> message) {
48 | if(message!=null){
49 | LOGGER.info("JMS Input "+message.getPayload());
50 | }else{
51 | LOGGER.info("Message is null");
52 | }
53 | }
54 |
55 |
56 | public void attributePolled(Message> message) {
57 | if(message!=null){
58 | LOGGER.info("Polled attribute"+message.getPayload());
59 | //Print headers
60 | Iterator messageHistoryItr =message.getHeaders().get(MessageHistory.HEADER_NAME,MessageHistory.class).iterator();
61 | while(messageHistoryItr.hasNext()) {
62 | Properties properties = messageHistoryItr.next();
63 | LOGGER.info(properties);
64 | }
65 | }else{
66 | LOGGER.info("Message is null");
67 | }
68 | }
69 | public void mbeanTreePolled(Message> message) {
70 | if(message!=null){
71 | LOGGER.info("JMS Input "+message.getPayload());
72 | }else{
73 | LOGGER.info("Message is null");
74 | }
75 | }
76 | public void operationInvokedGateway(Message> message) {
77 | if(message!=null){
78 | LOGGER.info("JMS Input "+message.getPayload());
79 | }else{
80 | LOGGER.info("Message is null");
81 | }
82 | }
83 | }
84 |
--------------------------------------------------------------------------------
/feedsexample/src/main/java/com/cpandey/siexample/service/FeedService.java:
--------------------------------------------------------------------------------
1 |
2 | package com.cpandey.siexample.service;
3 |
4 | /**
5 | * This is gateway, definition in spring-integration-context.xml
6 | *
7 | * @author Chandan Pandey
8 | *
9 | */
10 | import java.util.List;
11 |
12 | import com.cpandey.siexample.pojo.FeedEntity;
13 |
14 |
15 | public interface FeedService {
16 |
17 | FeedEntity createFeed(FeedEntity feed);
18 | List readAllFeed();
19 | }
20 |
--------------------------------------------------------------------------------
/feedsexample/src/main/java/com/cpandey/siexample/service/PersistFeed.java:
--------------------------------------------------------------------------------
1 |
2 | package com.cpandey.siexample.service;
3 |
4 | import org.apache.log4j.Logger;
5 | import org.springframework.beans.factory.annotation.Autowired;
6 | import org.springframework.integration.annotation.MessageEndpoint;
7 | import org.springframework.integration.annotation.ServiceActivator;
8 |
9 | import com.cpandey.siexample.pojo.FeedEntity;
10 | import com.cpandey.siexample.pojo.SoFeed;
11 |
12 | /**
13 | * Implementation for print feed gateway
14 | *
15 | * @author Chandan Pandey
16 | *
17 | */
18 |
19 | @MessageEndpoint
20 | public class PersistFeed {
21 |
22 | private static final Logger LOGGER = Logger.getLogger(PersistFeed.class);
23 |
24 | @Autowired FeedService feedService;
25 | @ServiceActivator
26 | public void persistFeedToDb(SoFeed feed) {
27 | //This will write to output channel of gateway
28 | //From there this will be picked by updating adapter
29 | feedService.createFeed(new FeedEntity(feed.getTitle()));
30 | }
31 |
32 | @ServiceActivator
33 | public void printFeed(FeedEntity feed) {
34 | //Print the feed fetched by retrieving adapter
35 | LOGGER.info("Feed Id"+feed.getId()+" Feed Title "+feed.getTitle());
36 | }
37 | }
38 |
--------------------------------------------------------------------------------
/feedsexample/src/main/java/com/cpandey/siexample/service/PrintFeed.java:
--------------------------------------------------------------------------------
1 | package com.cpandey.siexample.service;
2 |
3 | import org.apache.log4j.Logger;
4 | import org.springframework.integration.annotation.MessageEndpoint;
5 | import org.springframework.integration.annotation.ServiceActivator;
6 |
7 | /**
8 | * Utility class to print message
9 | *
10 | * @author Chandan Pandey
11 | *
12 | */
13 |
14 | @MessageEndpoint
15 | public class PrintFeed {
16 |
17 | private static final Logger LOGGER = Logger.getLogger(PrintFeed.class);
18 |
19 | @ServiceActivator
20 | public String upperCase(String input) {
21 | LOGGER.info("Converted to upper case "+input.toUpperCase());
22 | return "Converted to upper case "+input.toUpperCase();
23 | }
24 | }
25 |
--------------------------------------------------------------------------------
/feedsexample/src/main/java/com/cpandey/siexample/splitter/SoFeedSplitter.java:
--------------------------------------------------------------------------------
1 | package com.cpandey.siexample.splitter;
2 |
3 | import java.util.List;
4 |
5 | import com.sun.syndication.feed.synd.SyndEntry;
6 |
7 | /**
8 | * Splitter, receives a list of messages and after splitting it, passes on
9 | * one message at a time to next channel
10 | *
11 | * @author Chandan Pandey
12 | *
13 | */
14 |
15 | public class SoFeedSplitter {
16 | public List splitAndPublish(List message) {
17 | //Return one message from list at a time -this will be picked up by the processor
18 | return message;
19 | }
20 | }
21 |
--------------------------------------------------------------------------------
/feedsexample/src/main/java/com/cpandey/siexample/transformer/SoFeedDbTransformer.java:
--------------------------------------------------------------------------------
1 | package com.cpandey.siexample.transformer;
2 |
3 | import org.apache.log4j.Logger;
4 | import org.springframework.messaging.Message;
5 |
6 | import com.cpandey.siexample.pojo.SoFeed;
7 | import com.sun.syndication.feed.synd.SyndEntry;
8 |
9 | /**
10 | * Transform Feed into entity which can be written to database
11 | *
12 | * @author Chandan Pandey
13 | *
14 | */
15 | public class SoFeedDbTransformer {
16 | private static final Logger LOGGER = Logger.getLogger(SoFeedDbTransformer.class);
17 |
18 | public SoFeed transformFeed(Message message){
19 | SyndEntry entry = message.getPayload();
20 | SoFeed soFeed=new SoFeed();
21 | soFeed.setTitle(entry.getTitle());
22 | soFeed.setDescription(entry.getDescription().getValue());
23 | soFeed.setCategories(entry.getCategories());
24 | soFeed.setLink(entry.getLink());
25 | soFeed.setAuthor(entry.getAuthor());
26 | LOGGER.info("JDBC :: "+soFeed.getTitle());
27 | return soFeed;
28 | }
29 | }
30 |
--------------------------------------------------------------------------------
/feedsexample/src/main/java/com/cpandey/siexample/transformer/SoFeedJMSTransformer.java:
--------------------------------------------------------------------------------
1 | package com.cpandey.siexample.transformer;
2 |
3 | import org.apache.log4j.Logger;
4 | import org.springframework.messaging.Message;
5 |
6 | import com.cpandey.siexample.pojo.SoFeed;
7 | import com.sun.syndication.feed.synd.SyndEntry;
8 | /**
9 | * Transform Feed into String which can be written to JMS queue
10 | *
11 | * @author Chandan Pandey
12 | *
13 | */
14 | public class SoFeedJMSTransformer {
15 | private static final Logger LOGGER = Logger.getLogger(SoFeedJMSTransformer.class);
16 |
17 | public String transformFeed(Message message){
18 | SyndEntry entry = message.getPayload();
19 | SoFeed soFeed=new SoFeed();
20 | soFeed.setTitle(entry.getTitle());
21 | soFeed.setDescription(entry.getDescription().getValue());
22 | soFeed.setCategories(entry.getCategories());
23 | soFeed.setLink(entry.getLink());
24 | soFeed.setAuthor(entry.getAuthor());
25 | //For JSM , return String
26 | LOGGER.info("JMS"+soFeed.getTitle());
27 | return soFeed.toString();
28 | }
29 | }
30 |
--------------------------------------------------------------------------------
/feedsexample/src/main/java/com/cpandey/siexample/transformer/SoFeedMailTransformer.java:
--------------------------------------------------------------------------------
1 | package com.cpandey.siexample.transformer;
2 |
3 | import java.util.Date;
4 |
5 | import org.apache.log4j.Logger;
6 | import org.springframework.mail.MailMessage;
7 | import org.springframework.mail.SimpleMailMessage;
8 | import org.springframework.messaging.Message;
9 |
10 | import com.cpandey.siexample.pojo.SoFeed;
11 | import com.sun.syndication.feed.synd.SyndEntry;
12 | /**
13 | * Transform Feed into MailMessage which can be send as email
14 | *
15 | * @author Chandan Pandey
16 | *
17 | */
18 | public class SoFeedMailTransformer {
19 | private static final Logger LOGGER = Logger.getLogger(SoFeedMailTransformer.class);
20 |
21 | public MailMessage transformFeed(Message message){
22 | SyndEntry entry = message.getPayload();
23 | SoFeed soFeed=new SoFeed();
24 | soFeed.setTitle(entry.getTitle());
25 | soFeed.setDescription(entry.getDescription().getValue());
26 | soFeed.setCategories(entry.getCategories());
27 | soFeed.setLink(entry.getLink());
28 | soFeed.setAuthor(entry.getAuthor());
29 |
30 | //For Mail return MailMessage
31 | MailMessage msg = new SimpleMailMessage();
32 | msg.setTo("emailaddress");
33 | msg.setFrom("emailaddress");
34 | msg.setSubject("Subject");
35 | msg.setSentDate(new Date());
36 | msg.setText("Mail Text");
37 | LOGGER.info("Mail Message"+soFeed.getTitle());
38 |
39 | return msg;
40 | }
41 | }
42 |
--------------------------------------------------------------------------------
/feedsexample/src/main/resources/META-INF/spring/integration/spring-integration-context.xml:
--------------------------------------------------------------------------------
1 |
2 |
21 |
22 |
23 |
24 |
25 |
26 |
27 |
28 |
29 |
30 |
31 |
32 |
33 |
37 |
38 |
39 |
40 |
41 |
42 |
43 |
44 |
45 |
46 |
47 |
48 |
49 |
50 |
51 |
52 |
53 |
54 |
55 |
56 |
57 |
58 |
59 |
60 |
61 |
62 |
63 |
64 |
65 |
66 |
67 |
68 |
69 |
70 |
71 |
72 |
74 |
75 |
76 |
77 |
83 |
84 |
85 |
86 |
87 |
88 |
89 |
90 |
91 |
92 |
93 |
94 |
95 |
97 |
98 |
100 |
101 |
103 |
104 |
105 |
107 |
109 |
111 |
113 |
114 |
115 |
116 |
117 |
118 |
119 |
120 |
121 |
122 |
124 |
125 |
126 | true
127 | true
128 | smtp.gmail.com
129 | 587
130 |
131 |
132 |
133 |
134 |
135 |
136 |
137 |
138 |
142 |
143 |
144 |
145 |
146 |
147 |
148 |
149 |
150 |
151 |
152 |
153 |
157 |
159 |
161 |
162 |
163 |
168 |
169 |
170 |
171 |
176 |
177 |
178 |
179 |
180 |
181 |
182 |
183 |
184 |
185 |
186 |
187 |
188 |
--------------------------------------------------------------------------------
/feedsexample/src/main/resources/META-INF/spring/integration/spring-integration-ftp.xml:
--------------------------------------------------------------------------------
1 |
2 |
9 |
10 |
11 |
12 |
13 |
15 |
16 |
17 |
18 |
19 |
20 |
21 |
22 |
31 |
32 |
33 |
34 |
35 |
--------------------------------------------------------------------------------
/feedsexample/src/main/resources/META-INF/spring/integration/spring-integration-hibernate.xml:
--------------------------------------------------------------------------------
1 |
2 |
15 |
16 |
17 |
18 |
19 |
20 |
21 |
22 |
23 |
24 |
26 |
27 |
28 |
29 |
30 |
31 |
32 |
33 |
34 |
35 |
36 |
37 |
38 |
39 |
40 |
42 |
43 |
44 |
--------------------------------------------------------------------------------
/feedsexample/src/main/resources/META-INF/spring/integration/spring-integration-jms.xml:
--------------------------------------------------------------------------------
1 |
2 |
9 |
10 |
11 |
12 |
13 |
14 |
15 |
16 |
17 |
18 |
21 |
22 |
23 |
24 |
25 |
26 |
27 |
28 |
29 |
30 |
32 |
33 |
34 |
36 |
37 |
38 |
39 |
40 |
41 |
42 |
43 |
--------------------------------------------------------------------------------
/feedsexample/src/main/resources/META-INF/spring/integration/spring-integration-jmx.xml:
--------------------------------------------------------------------------------
1 |
2 |
11 |
12 |
13 |
14 |
15 |
16 |
17 |
18 |
19 |
20 |
21 |
22 |
23 |
24 |
25 |
26 |
27 |
28 |
29 |
32 |
33 |
34 |
35 |
39 |
40 |
41 |
42 |
43 |
47 |
48 |
49 |
50 |
51 |
52 |
53 |
54 |
57 |
58 |
59 |
60 |
61 |
62 |
63 |
67 |
68 |
69 |
70 |
71 |
76 |
77 |
78 |
79 |
82 |
83 |
84 |
85 |
86 |
87 |
88 |
--------------------------------------------------------------------------------
/feedsexample/src/main/resources/log4j.xml:
--------------------------------------------------------------------------------
1 |
2 |
3 |
4 |
5 |
6 |
7 |
8 |
9 |
10 |
11 |
12 |
13 |
14 |
15 |
16 |
17 |
18 |
19 |
20 |
21 |
22 |
23 |
24 |
25 |
26 |
27 |
28 |
29 |
--------------------------------------------------------------------------------
/feedsexample/src/main/resources/settings.properties:
--------------------------------------------------------------------------------
1 | #URL of RSS feed, as example http://stackoverflow.com/feeds -Make sure there are not copyright or legal issues in consumption of feed
2 | feeds.url=http://stackoverflow.com/feeds
3 | #Username for email account
4 | mail.username=yourusername
5 | #Password for email account
6 | mail.password=yourpassword
7 | #FTP server host
8 | ftp.host=localhost
9 | #FTP port
10 | ftp.port=21
11 | #Remote directory on FTP which the listener whould be observing
12 | ftp.remotefolder=/
13 | #Local directory where downloaded file should be dumped
14 | ftp.localfolder=C:\\Chandan\\Projects\\siexample\\ftp\\ftplocalfolder
15 | #Username for connecting to FTP server
16 | ftp.username=ftpusername
17 | #Password for connectin to FTP server
18 | ftp.password=ftppassword
19 | #JMS broker URL
20 | jms.brokerurl=vm://localhost
--------------------------------------------------------------------------------
/siexample/.classpath:
--------------------------------------------------------------------------------
1 |
2 |
3 |
4 |
5 |
6 |
7 |
8 |
9 |
10 |
11 |
12 |
13 |
14 |
15 |
16 |
17 |
18 |
19 |
20 |
21 |
22 |
23 |
24 |
25 |
26 |
27 |
28 |
29 |
30 |
31 |
32 |
--------------------------------------------------------------------------------
/siexample/.project:
--------------------------------------------------------------------------------
1 |
2 |
3 | siexample
4 |
5 |
6 |
7 |
8 |
9 | org.eclipse.jdt.core.javabuilder
10 |
11 |
12 |
13 |
14 | org.springframework.ide.eclipse.core.springbuilder
15 |
16 |
17 |
18 |
19 | org.eclipse.m2e.core.maven2Builder
20 |
21 |
22 |
23 |
24 |
25 | org.springframework.ide.eclipse.core.springnature
26 | org.eclipse.jdt.core.javanature
27 | org.eclipse.m2e.core.maven2Nature
28 |
29 |
30 |
--------------------------------------------------------------------------------
/siexample/.settings/org.eclipse.core.resources.prefs:
--------------------------------------------------------------------------------
1 | eclipse.preferences.version=1
2 | encoding//src/main/java=UTF-8
3 | encoding//src/main/resources=UTF-8
4 | encoding//src/test/java=UTF-8
5 | encoding/=UTF-8
6 |
--------------------------------------------------------------------------------
/siexample/.settings/org.eclipse.jdt.core.prefs:
--------------------------------------------------------------------------------
1 | eclipse.preferences.version=1
2 | org.eclipse.jdt.core.compiler.codegen.targetPlatform=1.6
3 | org.eclipse.jdt.core.compiler.compliance=1.6
4 | org.eclipse.jdt.core.compiler.problem.forbiddenReference=warning
5 | org.eclipse.jdt.core.compiler.source=1.6
6 |
--------------------------------------------------------------------------------
/siexample/README.txt:
--------------------------------------------------------------------------------
1 | Build the Maven project to download all dependencies "mvn -X clean package"
2 |
3 | Refer /META-INF/spring/integration/setting.properties for all the values which can be set
4 |
5 | All classes needed to run sample App aer inside package com.cpandey.siexample
6 | -select any of those and then "run as Java" program
7 |
8 | Following are the details classes which map to chapter wise samples
9 |
10 | Chapter 1-5
11 | Gateway, Service Activator, Router, Filter, Splitter -EndpointsMailJmsDb.java
12 | Aggregator, ChainingHandler -Aggregator.java
13 | Resequencer, Enricher -Resequencer.java
14 | Chapter 6
15 | FTP/FTPS FTPIntegration
16 | Twitter, SocialIntegration
17 | JMS, EndpointsMailJmsDb
18 | Mail EndpointsMailJmsDb
19 | Database EndpointsMailJmsDb
20 | HTTP -Separate Project, to be deployed inside tomcat : siexamplehttpinboundoutbound
21 | WebService -Separate Project, to be deployed inside tomcat : siexamplewsinboundoutbound
22 | Chapter 7
23 | Spring Batch BatchJobLauncher.java and SpringIntegrationBatchJobLauncher.java
24 | Chapter 8
25 | Testing Files under src/test/java
26 | Chapter 9 and 10
27 | JMX and an End to End example :Separate project : feedsexample
28 |
--------------------------------------------------------------------------------
/siexample/pom.xml:
--------------------------------------------------------------------------------
1 |
3 | 4.0.0
4 |
5 | cpandey
6 | siexample
7 | 1.0.0.BUILD-SNAPSHOT
8 | jar
9 |
10 | siexample
11 | http://www.springsource.org/spring-integration
12 |
13 |
14 | 2.2.1
15 |
16 |
17 |
18 | UTF-8
19 | 4.0.1.RELEASE
20 | 4.0.3.RELEASE
21 | 1.2.17
22 | 4.11
23 | 5.7.0
24 | 4.0.1.Final
25 |
26 |
27 |
28 |
29 | repo.springsource.org.milestone
30 | Spring Framework Maven Milestone Repository
31 | https://repo.springsource.org/milestone
32 |
33 |
34 |
35 |
36 |
37 |
38 | maven-eclipse-plugin
39 | 2.9
40 |
41 |
42 | org.springframework.ide.eclipse.core.springnature
43 |
44 |
45 | org.springframework.ide.eclipse.core.springbuilder
46 |
47 | true
48 | true
49 |
50 |
51 |
52 | org.apache.maven.plugins
53 | maven-compiler-plugin
54 | 3.1
55 |
56 | 1.6
57 | 1.6
58 | -Xlint:all
59 | true
60 | true
61 |
62 |
63 |
64 | org.codehaus.mojo
65 | exec-maven-plugin
66 | 1.2.1
67 |
68 | com.cpandey.siexample.Main
69 |
70 |
71 |
72 |
73 |
74 |
75 |
76 |
77 | commons-lang
78 | commons-lang
79 | 2.6
80 |
81 |
82 |
83 | junit
84 | junit
85 | ${junit.version}
86 | test
87 |
88 |
89 | org.springframework.integration
90 | spring-integration-test
91 | ${spring.integration.version}
92 |
93 |
94 | org.springframework
95 | spring-test
96 | ${spring.version}
97 | test
98 |
99 |
100 |
101 |
102 |
103 | org.springframework.integration
104 | spring-integration-core
105 | ${spring.integration.version}
106 |
107 |
108 |
109 | org.springframework.integration
110 | spring-integration-feed
111 | ${spring.integration.version}
112 |
113 |
114 | org.springframework.integration
115 | spring-integration-mail
116 | ${spring.integration.version}
117 |
118 |
119 | org.springframework.integration
120 | spring-integration-jms
121 | ${spring.integration.version}
122 |
123 |
124 | org.springframework.integration
125 | spring-integration-stream
126 | ${spring.integration.version}
127 |
128 |
129 | org.springframework.integration
130 | spring-integration-jpa
131 | ${spring.integration.version}
132 |
133 |
134 | org.springframework.integration
135 | spring-integration-file
136 | ${spring.integration.version}
137 |
138 |
139 | org.springframework.integration
140 | spring-integration-ftp
141 | ${spring.integration.version}
142 |
143 |
144 |
145 |
146 | log4j
147 | log4j
148 | ${log4j.version}
149 |
150 |
151 |
152 |
153 | javax.activation
154 | activation
155 | 1.1.1
156 | true
157 |
158 |
159 | javax.mail
160 | mail
161 | 1.4.5
162 |
163 |
164 | org.apache.velocity
165 | velocity
166 | 1.7
167 |
168 |
169 |
170 |
171 |
172 | org.apache.activemq
173 | activemq-core
174 | ${activemq.version}
175 |
176 |
177 | spring-context
178 | org.springframework
179 |
180 |
181 |
182 |
183 | org.springframework
184 | spring-jms
185 | ${spring.version}
186 | compile
187 |
188 |
189 |
190 |
191 |
192 |
193 |
194 |
195 |
196 |
197 |
198 | com.h2database
199 | h2
200 | 1.3.168
201 |
202 |
203 |
204 |
205 | org.hibernate
206 | hibernate-entitymanager
207 | ${hibernate.version}
208 |
209 |
210 |
211 | org.springframework.integration
212 | spring-integration-jdbc
213 | ${spring.integration.version}
214 |
215 |
216 |
217 |
218 |
219 | org.springframework.integration
220 | spring-integration-twitter
221 | ${spring.integration.version}
222 |
223 |
224 |
225 |
226 | org.springframework.integration
227 | spring-integration-xml
228 | ${spring.integration.version}
229 |
230 |
231 | org.springframework.integration
232 | spring-integration-ws
233 | ${spring.integration.version}
234 |
235 |
236 |
237 | org.springframework.batch
238 | spring-batch-core
239 | 3.0.1.RELEASE
240 |
241 |
242 |
243 | postgresql
244 | postgresql
245 | 9.0-801.jdbc4
246 |
247 |
248 | commons-dbcp
249 | commons-dbcp
250 | 1.4
251 |
252 |
253 | org.springframework.batch
254 | spring-batch-integration
255 | 3.0.1.RELEASE
256 |
257 |
258 |
259 |
--------------------------------------------------------------------------------
/siexample/src/main/java/com/cpandey/siexample/Aggregator.java:
--------------------------------------------------------------------------------
1 |
2 | package com.cpandey.siexample;
3 |
4 | import org.apache.log4j.Logger;
5 | import org.springframework.context.support.AbstractApplicationContext;
6 | import org.springframework.context.support.ClassPathXmlApplicationContext;
7 |
8 |
9 | /**
10 | * Starts the Spring Context and will initialize the Spring Integration routes.
11 | *
12 | * @author Chandan Pandey
13 | *
14 | * Showcase Aggregator and it's related components
15 | *
16 | */
17 | public final class Aggregator {
18 | private static final Logger LOGGER = Logger.getLogger(Aggregator.class);
19 | private Aggregator() { }
20 | public static void main(final String... args) {
21 | final AbstractApplicationContext context =
22 | new ClassPathXmlApplicationContext("classpath:META-INF/spring/integration/spring-integration-aggregator.xml");
23 | LOGGER.info("Context Started");
24 | }
25 | }
26 |
--------------------------------------------------------------------------------
/siexample/src/main/java/com/cpandey/siexample/BatchJobLauncher.java:
--------------------------------------------------------------------------------
1 | package com.cpandey.siexample;
2 |
3 | /**
4 | * Class to launch the batch Job.
5 | *
6 | * @author Chandan Pandey
7 | *
8 | * Spring Bacth Job Support
9 | *
10 | */
11 | import org.springframework.batch.core.Job;
12 | import org.springframework.batch.core.JobExecution;
13 | import org.springframework.batch.core.JobParametersBuilder;
14 | import org.springframework.batch.core.JobParametersInvalidException;
15 | import org.springframework.batch.core.launch.JobLauncher;
16 | import org.springframework.batch.core.repository.JobExecutionAlreadyRunningException;
17 | import org.springframework.batch.core.repository.JobInstanceAlreadyCompleteException;
18 | import org.springframework.batch.core.repository.JobRestartException;
19 | import org.springframework.context.ApplicationContext;
20 | import org.springframework.context.support.ClassPathXmlApplicationContext;
21 |
22 | public class BatchJobLauncher {
23 | public static void main(String[] args) throws JobExecutionAlreadyRunningException, JobRestartException, JobInstanceAlreadyCompleteException, JobParametersInvalidException {
24 | ApplicationContext context = new ClassPathXmlApplicationContext("/META-INF/spring/integration/spring-integration-batch.xml");
25 | Job job = context.getBean("importEmployeeRecords", Job.class);
26 | JobLauncher jobLauncher= context.getBean("jobLauncher", JobLauncher.class);
27 | JobParametersBuilder jobParametersBuilder = new JobParametersBuilder();
28 | jobParametersBuilder.addString("input.file.name", "C:/workspace_sts/siexample/src/main/resources/META-INF/spring/integration/employee.input");
29 | JobExecution execution =jobLauncher.run(job, jobParametersBuilder.toJobParameters());
30 | }
31 | }
32 |
--------------------------------------------------------------------------------
/siexample/src/main/java/com/cpandey/siexample/EndpointsMailJmsDb.java:
--------------------------------------------------------------------------------
1 |
2 | package com.cpandey.siexample;
3 |
4 | import org.apache.log4j.Logger;
5 | import org.springframework.context.support.AbstractApplicationContext;
6 | import org.springframework.context.support.ClassPathXmlApplicationContext;
7 |
8 |
9 | /**
10 | * Starts the Spring Context and will initialize the Spring Integration routes.
11 | *
12 | * @author Chandan Pandey
13 | *
14 | * This will execute examples for common feed adapter, service activator, filter, transformer, router, JMS, Mail and Database
15 | *
16 | */
17 | public final class EndpointsMailJmsDb {
18 | private static final Logger LOGGER = Logger.getLogger(EndpointsMailJmsDb.class);
19 | private EndpointsMailJmsDb() { }
20 | public static void main(final String... args) {
21 | final AbstractApplicationContext context =
22 | new ClassPathXmlApplicationContext("classpath:META-INF/spring/integration/spring-integration-endpoints.xml");
23 | LOGGER.info("Context Started");
24 | }
25 | }
26 |
--------------------------------------------------------------------------------
/siexample/src/main/java/com/cpandey/siexample/FTPIntegration.java:
--------------------------------------------------------------------------------
1 |
2 | package com.cpandey.siexample;
3 |
4 | import org.apache.log4j.Logger;
5 | import org.springframework.context.support.AbstractApplicationContext;
6 | import org.springframework.context.support.ClassPathXmlApplicationContext;
7 |
8 |
9 | /**
10 | * Starts the Spring Context and will initialize the Spring Integration routes.
11 | *
12 | * @author Chandan Pandey
13 | *
14 | * FTP integration support
15 | *
16 | */
17 | public final class FTPIntegration {
18 | private static final Logger LOGGER = Logger.getLogger(FTPIntegration.class);
19 | private FTPIntegration() { }
20 | public static void main(final String... args) {
21 | final AbstractApplicationContext context =
22 | new ClassPathXmlApplicationContext("classpath:META-INF/spring/integration/spring-integration-ftp.xml");
23 | LOGGER.info("Context Started");
24 | }
25 | }
26 |
--------------------------------------------------------------------------------
/siexample/src/main/java/com/cpandey/siexample/FileIntegration.java:
--------------------------------------------------------------------------------
1 |
2 | package com.cpandey.siexample;
3 |
4 | import org.apache.log4j.Logger;
5 | import org.springframework.context.support.AbstractApplicationContext;
6 | import org.springframework.context.support.ClassPathXmlApplicationContext;
7 |
8 |
9 | /**
10 | * Starts the Spring Context and will initialize the Spring Integration routes.
11 | *
12 | * @author Chandan Pandey
13 | *
14 | * Showcase File integration support
15 | *
16 | */
17 | public final class FileIntegration {
18 | private static final Logger LOGGER = Logger.getLogger(FileIntegration.class);
19 | private FileIntegration() { }
20 | public static void main(final String... args) {
21 | final AbstractApplicationContext context =
22 | new ClassPathXmlApplicationContext("classpath:META-INF/spring/integration/spring-integration-file.xml");
23 | LOGGER.info("Context Started");
24 | }
25 | }
26 |
--------------------------------------------------------------------------------
/siexample/src/main/java/com/cpandey/siexample/InboundFileAdapter.java:
--------------------------------------------------------------------------------
1 | package com.cpandey.siexample;
2 |
3 |
4 | import java.io.File;
5 |
6 | import org.springframework.integration.file.FileReadingMessageSource;
7 | import org.springframework.messaging.Message;
8 |
9 | /**
10 | * Test In bound File Manager.
11 | *
12 | * @author Chandan Pandey
13 | *
14 | */
15 | public class InboundFileAdapter {
16 | // set the directory from where the files need to be picked up
17 | File directory = new File("C:\\Chandan\\Projects\\inputfolderforsi");
18 | public void startFileAdatper() {
19 | FileReadingMessageSource fileReadingMessageSource = new FileReadingMessageSource();
20 | fileReadingMessageSource.setDirectory(directory);
21 | Message fileMessage = fileReadingMessageSource.receive();
22 | System.out.println("Received:"+fileMessage);
23 | }
24 | public static void main(String[] args) {
25 | InboundFileAdapter inboundFileAdapterTest = new InboundFileAdapter();
26 | inboundFileAdapterTest.startFileAdatper();
27 | }
28 | }
29 |
--------------------------------------------------------------------------------
/siexample/src/main/java/com/cpandey/siexample/Resequencer.java:
--------------------------------------------------------------------------------
1 |
2 | package com.cpandey.siexample;
3 |
4 | import org.apache.log4j.Logger;
5 | import org.springframework.context.support.AbstractApplicationContext;
6 | import org.springframework.context.support.ClassPathXmlApplicationContext;
7 |
8 |
9 | /**
10 | * Starts the Spring Context and will initialize the Spring Integration routes.
11 | *
12 | * @author Chandan Pandey
13 | *
14 | * Showcase Resequencer and it's related components
15 | *
16 | */
17 | public final class Resequencer {
18 | private static final Logger LOGGER = Logger.getLogger(Resequencer.class);
19 | private Resequencer() { }
20 | public static void main(final String... args) {
21 | final AbstractApplicationContext context =
22 | new ClassPathXmlApplicationContext("classpath:META-INF/spring/integration/spring-integration-resequencer.xml");
23 | LOGGER.info("Context Started");
24 | }
25 | }
26 |
--------------------------------------------------------------------------------
/siexample/src/main/java/com/cpandey/siexample/SocialIntegration.java:
--------------------------------------------------------------------------------
1 |
2 | package com.cpandey.siexample;
3 |
4 | import org.apache.log4j.Logger;
5 | import org.springframework.context.support.AbstractApplicationContext;
6 | import org.springframework.context.support.ClassPathXmlApplicationContext;
7 |
8 |
9 | /**
10 | * Starts the Spring Context and will initialize the Spring Integration routes.
11 | *
12 | * @author Chandan Pandey
13 | *
14 | * Showcase Twitter Integration
15 | *
16 | */
17 | public final class SocialIntegration {
18 | private static final Logger LOGGER = Logger.getLogger(SocialIntegration.class);
19 | private SocialIntegration() { }
20 | public static void main(final String... args) {
21 | final AbstractApplicationContext context =
22 | new ClassPathXmlApplicationContext("classpath:META-INF/spring/integration/spring-integration-twitter.xml");
23 | LOGGER.info("Context Started");
24 | }
25 | }
26 |
--------------------------------------------------------------------------------
/siexample/src/main/java/com/cpandey/siexample/SpringIntegrationBatchJobLauncher.java:
--------------------------------------------------------------------------------
1 | package com.cpandey.siexample;
2 |
3 | import org.springframework.batch.core.JobParametersInvalidException;
4 | import org.springframework.batch.core.repository.JobExecutionAlreadyRunningException;
5 | import org.springframework.batch.core.repository.JobInstanceAlreadyCompleteException;
6 | import org.springframework.batch.core.repository.JobRestartException;
7 | import org.springframework.context.ApplicationContext;
8 | import org.springframework.context.support.ClassPathXmlApplicationContext;
9 |
10 | /**
11 | *
12 | * Spring Integration configuration file to launch a batch job
13 | *
14 | * @author Chandan Pandey
15 | *
16 | */
17 | public class SpringIntegrationBatchJobLauncher {
18 | public static void main(String[] args) throws JobExecutionAlreadyRunningException, JobRestartException, JobInstanceAlreadyCompleteException, JobParametersInvalidException {
19 | ApplicationContext context = new ClassPathXmlApplicationContext("/META-INF/spring/integration/spring-integration-batch.xml");
20 | }
21 | }
22 |
--------------------------------------------------------------------------------
/siexample/src/main/java/com/cpandey/siexample/aggregator/CompletionStrategy.java:
--------------------------------------------------------------------------------
1 | package com.cpandey.siexample.aggregator;
2 |
3 | /**
4 | * Completion Strategy, part of aggregator
5 | *
6 | * @author Chandan Pandey
7 | *
8 | */
9 | import java.util.List;
10 |
11 | import com.sun.syndication.feed.synd.SyndEntry;
12 |
13 | public class CompletionStrategy {
14 | //method should expect a java.util.List Object returning a Boolean value
15 | public boolean checkCompleteness(List messages) {
16 | if(messages!=null){
17 | if(messages.size()>2){
18 | return true;
19 | }
20 | }
21 | return false;
22 | }
23 |
24 | }
25 |
--------------------------------------------------------------------------------
/siexample/src/main/java/com/cpandey/siexample/aggregator/CorrelationStrategy.java:
--------------------------------------------------------------------------------
1 | package com.cpandey.siexample.aggregator;
2 |
3 | /**
4 | * Correlation Strategy, part of Aggregator.
5 | *
6 | * @author Chandan Pandey
7 | *
8 | */
9 | import java.util.List;
10 |
11 | import org.apache.log4j.Logger;
12 | import org.springframework.messaging.Message;
13 |
14 | import com.sun.syndication.feed.synd.SyndCategoryImpl;
15 | import com.sun.syndication.feed.synd.SyndEntry;
16 |
17 | public class CorrelationStrategy {
18 | private static final Logger LOGGER = Logger.getLogger(CorrelationStrategy.class);
19 | // aggregator’s method should expect a Message> and return an Object.
20 | public Object groupFeedsBasedOnCategory(Message> message) {
21 | if(message!=null){
22 | SyndEntry entry = (SyndEntry)message.getPayload();
23 | List categories=entry.getCategories();
24 | if(categories!=null&&categories.size()>0){
25 | for (SyndCategoryImpl category: categories) {
26 | //for simplicity, lets consider the first category
27 | LOGGER.info("category "+category.getName());
28 | return category.getName();
29 | }
30 | }
31 | }
32 | return null;
33 | }
34 | }
35 |
--------------------------------------------------------------------------------
/siexample/src/main/java/com/cpandey/siexample/aggregator/SoFeedAggregator.java:
--------------------------------------------------------------------------------
1 | package com.cpandey.siexample.aggregator;
2 |
3 | /**
4 | * Aggregator Example.
5 | *
6 | * @author Chandan Pandey
7 | *
8 | */
9 | import java.util.List;
10 |
11 | import org.apache.log4j.Logger;
12 |
13 | import com.sun.syndication.feed.synd.SyndEntry;
14 |
15 | public class SoFeedAggregator {
16 | private static final Logger LOGGER = Logger.getLogger(SoFeedAggregator.class);
17 | public List aggregateAndPublish( List messages) {
18 | LOGGER.info("Aggregate");
19 | return messages;
20 | }
21 | }
22 |
--------------------------------------------------------------------------------
/siexample/src/main/java/com/cpandey/siexample/batch/BatchJdbcConfiguration.java:
--------------------------------------------------------------------------------
1 | package com.cpandey.siexample.batch;
2 |
3 | /**
4 | * Configuration class for batch job.
5 | *
6 | * @author Chandan Pandey
7 | *
8 | */
9 | import org.apache.commons.dbcp.BasicDataSource;
10 | import org.springframework.beans.factory.annotation.Value;
11 | import org.springframework.context.annotation.Bean;
12 | import org.springframework.context.annotation.Configuration;
13 | @Configuration
14 | public class BatchJdbcConfiguration {
15 | @Value("${db.driverClassName}")
16 | private String driverClassName;
17 | @Value("${db.url}")
18 | private String url;
19 | @Value("${db.username}")
20 | private String username;
21 | @Value("${db.password}")
22 | private String password;
23 | @Bean(destroyMethod = "close")
24 |
25 | public BasicDataSource dataSource() {
26 | BasicDataSource dataSource = new BasicDataSource();
27 | dataSource.setDriverClassName(driverClassName);
28 | dataSource.setUrl(url);
29 | dataSource.setUsername(username);
30 | dataSource.setPassword(password);
31 | return dataSource;
32 | }
33 | }
34 |
--------------------------------------------------------------------------------
/siexample/src/main/java/com/cpandey/siexample/batch/BatchStatusServiceActivator.java:
--------------------------------------------------------------------------------
1 | package com.cpandey.siexample.batch;
2 |
3 | /**
4 | * Service hooked to Batch Status.
5 | *
6 | * @author Chandan Pandey
7 | *
8 | */
9 | import org.apache.log4j.Logger;
10 | import org.springframework.batch.core.JobExecution;
11 | import org.springframework.integration.annotation.MessageEndpoint;
12 | import org.springframework.messaging.Message;
13 |
14 |
15 | @MessageEndpoint
16 | public class BatchStatusServiceActivator {
17 | private static final Logger LOGGER = Logger.getLogger(BatchStatusServiceActivator.class);
18 | public void printStatus(Message status ) {
19 | if(status!=null){
20 | LOGGER.info("Status :: "+status.getPayload().toString());
21 | }
22 | }
23 | }
24 |
--------------------------------------------------------------------------------
/siexample/src/main/java/com/cpandey/siexample/batch/Employee.java:
--------------------------------------------------------------------------------
1 | package com.cpandey.siexample.batch;
2 |
3 | /**
4 | * @author Chandan Pandey
5 | *
6 | */
7 | public class Employee {
8 | private String name="";
9 | private String address="";
10 | private String designation="";
11 | private String dept="";
12 |
13 | public String getName() {
14 | return name;
15 | }
16 |
17 | public void setName(String name) {
18 | this.name = name;
19 | }
20 |
21 | public String getAddress() {
22 | return address;
23 | }
24 |
25 | public void setAddress(String address) {
26 | this.address = address;
27 | }
28 |
29 | public String getDesignation() {
30 | return designation;
31 | }
32 |
33 | public void setDesignation(String designation) {
34 | this.designation = designation;
35 | }
36 |
37 | public String getDept() {
38 | return dept;
39 | }
40 |
41 | public void setDept(String dept) {
42 | this.dept = dept;
43 | }
44 |
45 | @Override
46 | public String toString() {
47 | return "Name : "+name+" Address : "+address+" Designation : "+designation+" Department : "+dept;
48 | }
49 |
50 | }
51 |
--------------------------------------------------------------------------------
/siexample/src/main/java/com/cpandey/siexample/batch/EmployeeFieldSetMapper.java:
--------------------------------------------------------------------------------
1 | package com.cpandey.siexample.batch;
2 |
3 | import org.springframework.batch.item.file.mapping.FieldSetMapper;
4 | import org.springframework.batch.item.file.transform.FieldSet;
5 | import org.springframework.validation.BindException;
6 |
7 | /**
8 | * @author Chandan Pandey
9 | *
10 | */
11 | public class EmployeeFieldSetMapper implements FieldSetMapper {
12 | @Override
13 | public Employee mapFieldSet(FieldSet fieldSet) throws BindException {
14 | Employee employee = new Employee();
15 | employee.setName(fieldSet.readString("name"));
16 | employee.setDesignation(fieldSet.readString("designation"));
17 | employee.setDept(fieldSet.readString("dept"));
18 | employee.setAddress(fieldSet.readString("address"));
19 | return employee;
20 | }
21 | }
--------------------------------------------------------------------------------
/siexample/src/main/java/com/cpandey/siexample/batch/EmployeeRecordWriter.java:
--------------------------------------------------------------------------------
1 | package com.cpandey.siexample.batch;
2 |
3 | import java.util.List;
4 |
5 | import org.apache.log4j.Logger;
6 | import org.springframework.batch.item.ItemWriter;
7 |
8 | /**
9 | * @author Chandan Pandey
10 | *
11 | */
12 | public class EmployeeRecordWriter implements ItemWriter {
13 | private static final Logger LOGGER = Logger.getLogger(EmployeeRecordWriter.class);
14 |
15 | @Override
16 | public void write(List extends Employee> employees) throws Exception {
17 | if(employees!=null){
18 | for (Employee employee : employees) {
19 | LOGGER.info(employee.toString());
20 | }
21 | }
22 | }
23 | }
24 |
--------------------------------------------------------------------------------
/siexample/src/main/java/com/cpandey/siexample/batch/FileMessageToJobRequest.java:
--------------------------------------------------------------------------------
1 | package com.cpandey.siexample.batch;
2 |
3 | import java.io.File;
4 |
5 | import org.springframework.batch.core.Job;
6 | import org.springframework.batch.core.JobParametersBuilder;
7 | import org.springframework.batch.integration.launch.JobLaunchRequest;
8 | import org.springframework.integration.annotation.Transformer;
9 | import org.springframework.messaging.Message;
10 |
11 | /**
12 | * @author Chandan Pandey
13 | *
14 | */
15 | public class FileMessageToJobRequest {
16 | private Job job;
17 | private String fileParameterName;
18 | public void setFileParameterName(String fileParameterName) {
19 | this.fileParameterName = fileParameterName;
20 | }
21 | public void setJob(Job job) {
22 | this.job = job;
23 | }
24 | @Transformer
25 | public JobLaunchRequest toRequest(Message message) {
26 | JobParametersBuilder jobParametersBuilder = new JobParametersBuilder();
27 | jobParametersBuilder.addString(fileParameterName,message.getPayload().getAbsolutePath());
28 | return new JobLaunchRequest(job,jobParametersBuilder.toJobParameters());
29 | }
30 | }
31 |
--------------------------------------------------------------------------------
/siexample/src/main/java/com/cpandey/siexample/filter/SoFeedFilter.java:
--------------------------------------------------------------------------------
1 | package com.cpandey.siexample.filter;
2 |
3 | import java.util.List;
4 |
5 | import org.springframework.messaging.Message;
6 |
7 | import com.sun.syndication.feed.synd.SyndCategoryImpl;
8 | import com.sun.syndication.feed.synd.SyndEntry;
9 | /**
10 | * A filter component.
11 | *
12 | * @author Chandan Pandey
13 | *
14 | */
15 | public class SoFeedFilter {
16 | public boolean filterFeed(Message message){
17 | SyndEntry entry = message.getPayload();
18 | List categories=entry.getCategories();
19 | if(categories!=null&&categories.size()>0){
20 | for (SyndCategoryImpl category: categories) {
21 | if(category.getName().equalsIgnoreCase("java")){
22 | return true;
23 | }
24 |
25 | }
26 | }
27 | return false;
28 | }
29 | }
30 |
--------------------------------------------------------------------------------
/siexample/src/main/java/com/cpandey/siexample/pojo/FeedEntity.java:
--------------------------------------------------------------------------------
1 | package com.cpandey.siexample.pojo;
2 |
3 | import java.util.Date;
4 |
5 | import javax.persistence.Column;
6 | import javax.persistence.Entity;
7 | import javax.persistence.GeneratedValue;
8 | import javax.persistence.GenerationType;
9 | import javax.persistence.Id;
10 | import javax.persistence.Table;
11 | import javax.persistence.Temporal;
12 | import javax.persistence.TemporalType;
13 |
14 |
15 | @Entity
16 | @Table(name="FEED")
17 | public class FeedEntity {
18 |
19 | @Id
20 | @GeneratedValue(strategy=GenerationType.AUTO)
21 | private int id;
22 |
23 | private String title;
24 |
25 | @Temporal(TemporalType.TIMESTAMP)
26 | @Column(name="CREATED_DATE_TIME")
27 | private Date createdDateTime;
28 |
29 | public FeedEntity() {
30 | super();
31 | this.createdDateTime = new Date();
32 | }
33 |
34 | public FeedEntity(String title) {
35 | super();
36 | this.title = title;
37 | this.createdDateTime = new Date();
38 | }
39 |
40 | public int getId() {
41 | return id;
42 | }
43 |
44 | public void setId(int id) {
45 | this.id = id;
46 | }
47 |
48 |
49 |
50 | public String getTitle() {
51 | return title;
52 | }
53 |
54 | public void setTitle(String title) {
55 | this.title = title;
56 | }
57 |
58 | public Date getCreatedDateTime() {
59 | return createdDateTime;
60 | }
61 |
62 | public void setCreatedDateTime(Date createdDateTime) {
63 | this.createdDateTime = createdDateTime;
64 | }
65 |
66 | @Override
67 | public int hashCode() {
68 | final int prime = 31;
69 | int result = 1;
70 | result = prime * result + ((title == null) ? 0 : title.hashCode());
71 | return result;
72 | }
73 |
74 | @Override
75 | public boolean equals(Object obj) {
76 | if (this == obj) {
77 | return true;
78 | }
79 | if (obj == null) {
80 | return false;
81 | }
82 | if (getClass() != obj.getClass()) {
83 | return false;
84 | }
85 | FeedEntity other = (FeedEntity) obj;
86 | if (title == null) {
87 | if (other.title != null) {
88 | return false;
89 | }
90 | } else if (!title.equals(other.title)) {
91 | return false;
92 | }
93 | return true;
94 | }
95 |
96 | }
97 |
--------------------------------------------------------------------------------
/siexample/src/main/java/com/cpandey/siexample/pojo/SoFeed.java:
--------------------------------------------------------------------------------
1 | package com.cpandey.siexample.pojo;
2 |
3 | import java.util.List;
4 |
5 | import com.sun.syndication.feed.synd.SyndCategoryImpl;
6 |
7 | public class SoFeed {
8 | private String title;
9 | private String description;
10 | private String link;
11 | private String author;
12 |
13 | private List categories;
14 |
15 | public String getTitle() {
16 | return title;
17 | }
18 | public void setTitle(String title) {
19 | this.title = title;
20 | }
21 | public String getDescription() {
22 | return description;
23 | }
24 | public void setDescription(String description) {
25 | this.description = description;
26 | }
27 | public String getLink() {
28 | return link;
29 | }
30 | public void setLink(String link) {
31 | this.link = link;
32 | }
33 | public String getAuthor() {
34 | return author;
35 | }
36 | public void setAuthor(String author) {
37 | this.author = author;
38 | }
39 | public List getCategories() {
40 | return categories;
41 | }
42 | public void setCategories(List categories) {
43 | this.categories = categories;
44 | }
45 | @Override
46 | public String toString() {
47 | StringBuffer str=new StringBuffer();
48 | str.append(title==null?"":title);
49 | str.append(description==null?"":description);
50 | str.append(link==null?"":link);
51 | str.append(author==null?"":author);
52 | if(categories!=null&&categories.size()>0){
53 | for (SyndCategoryImpl category: categories) {
54 | str.append(category.getName());
55 |
56 | }
57 | }
58 |
59 | return str.toString();
60 | }
61 | }
62 |
--------------------------------------------------------------------------------
/siexample/src/main/java/com/cpandey/siexample/resequencer/ResequencerCompletionStrategy.java:
--------------------------------------------------------------------------------
1 | package com.cpandey.siexample.resequencer;
2 |
3 | import java.util.List;
4 |
5 | import com.sun.syndication.feed.synd.SyndEntry;
6 | /**
7 | * Completion strategy for re-sequencer.
8 | *
9 | * @author Chandan Pandey
10 | *
11 | */
12 | public class ResequencerCompletionStrategy {
13 | //method should expect a java.util.List Object returning a Boolean value
14 | public boolean checkCompleteness(List messages) {
15 | if(messages!=null){
16 | if(messages.size()>5){
17 | return true;
18 | }
19 | }
20 | return false;
21 | }
22 |
23 | }
24 |
--------------------------------------------------------------------------------
/siexample/src/main/java/com/cpandey/siexample/resequencer/ResequencerCorrelationStrategy.java:
--------------------------------------------------------------------------------
1 | package com.cpandey.siexample.resequencer;
2 |
3 | import java.util.Calendar;
4 |
5 | import org.apache.log4j.Logger;
6 | import org.springframework.messaging.Message;
7 |
8 | import com.sun.syndication.feed.synd.SyndEntry;
9 | /**
10 | * Correlation Strategy For Re-sequencer
11 | * @author Chandan Pandey
12 | *
13 | */
14 | class ResequencerCorrelationStrategy {
15 | private static final Logger LOGGER = Logger.getLogger(ResequencerCorrelationStrategy.class);
16 |
17 | /**
18 | * This method will group feeds based on category
19 | */
20 | // aggregator’s method should expect a Message> and return an Object.
21 | public Object groupFeedsBasedOnPublishDate(Message> message) {
22 | if(message!=null){
23 | SyndEntry entry = (SyndEntry)message.getPayload();
24 | Calendar publishDate=Calendar.getInstance();
25 | publishDate.setTime(entry.getPublishedDate());
26 | LOGGER.info("DATE"+publishDate.get(Calendar.DATE));
27 | return publishDate.get(Calendar.DATE);
28 |
29 | }
30 | return null;
31 | }
32 | }
33 |
--------------------------------------------------------------------------------
/siexample/src/main/java/com/cpandey/siexample/service/CommonServiceActivator.java:
--------------------------------------------------------------------------------
1 |
2 | package com.cpandey.siexample.service;
3 |
4 | import java.io.File;
5 | import java.util.Iterator;
6 | import java.util.List;
7 |
8 | import org.apache.log4j.Logger;
9 | import org.springframework.integration.annotation.MessageEndpoint;
10 | import org.springframework.messaging.Message;
11 | import org.springframework.messaging.MessageHeaders;
12 |
13 | import com.sun.syndication.feed.synd.SyndCategoryImpl;
14 | import com.sun.syndication.feed.synd.SyndEntry;
15 |
16 | /**
17 | * A common service activator class which have utility methods to cater to many example scenarios.
18 | *
19 | * @author Chandan Pandey
20 | *
21 | */
22 | @MessageEndpoint
23 | public class CommonServiceActivator {
24 | private static final Logger LOGGER = Logger.getLogger(CommonServiceActivator.class);
25 |
26 | public void printAggregatedFeed(Message> aggregatedMessage ) {
27 | if(aggregatedMessage!=null){
28 | List syndEntries=aggregatedMessage.getPayload();
29 | LOGGER.info(syndEntries.size());
30 | }
31 | }
32 |
33 | public void printResequencedFeed(List aggregatedMessage ) {
34 | if(aggregatedMessage!=null){
35 | LOGGER.info(aggregatedMessage.size());
36 | }
37 | }
38 | public void chainedFeed(Message> message) {
39 | MessageHeaders headers=message.getHeaders();
40 |
41 | if(headers!=null){
42 | Iterator itr=headers.keySet().iterator();
43 | while (itr.hasNext()) {
44 | LOGGER.info("Header KEY"+itr.next());
45 | }
46 | }
47 | }
48 | public void printPayLoad(Message> message) {
49 | if(message!=null){
50 | LOGGER.info(message.getPayload());
51 | }else{
52 | LOGGER.info("Message is null");
53 | }
54 |
55 | }
56 | public void printSplitMessage(Message message) {
57 | if(message!=null){
58 | LOGGER.info(message.getPayload());
59 | }else{
60 | LOGGER.info("Message is null");
61 | }
62 |
63 | }
64 | public void printFileName(Message message) {
65 | if(message!=null){
66 | LOGGER.info(message.getPayload());
67 | }else{
68 | LOGGER.info("Message is null");
69 | }
70 | }
71 |
72 | public void echoJmsMessageInput(Message> message) {
73 | if(message!=null){
74 | LOGGER.info(message.getPayload());
75 | }else{
76 | LOGGER.info("Message is null");
77 | }
78 | }
79 |
80 | public void echoMessageInput(Message> message) {
81 | if(message!=null){
82 | LOGGER.info(message.getPayload());
83 | }else{
84 | LOGGER.info("Message is null");
85 | }
86 | }
87 | public void echoMessageOutput(Message> message) {
88 | if(message!=null){
89 | LOGGER.info(message.getPayload());
90 | }else{
91 | LOGGER.info("Message is null");
92 | }
93 | }
94 | public void echoTweets(Message> message) {
95 | if(message!=null){
96 | LOGGER.info("Twitter message :: "+message.getPayload());
97 | }else{
98 | LOGGER.info("Message is null");
99 | }
100 | }
101 | public void echoSearchedTweets(Message> message) {
102 | if(message!=null){
103 | LOGGER.info("Twitter searched message :: "+message.getPayload());
104 | }else{
105 | LOGGER.info("Message is null");
106 | }
107 | }
108 | public void printTailedMessage(Message> message) {
109 | if(message!=null){
110 | LOGGER.info("Tailed message :: "+message.getPayload());
111 | }else{
112 | LOGGER.info("Tailed message is null");
113 | }
114 | }
115 | public void printSqlResult(Message> message) {
116 | if(message!=null){
117 | LOGGER.info("SQL Result :: "+message.getPayload());
118 | }else{
119 | LOGGER.info("SQL Result :: null");
120 | }
121 | }
122 | public void printSqlInsertResult(Message> message) {
123 | if(message!=null){
124 | LOGGER.info("SQL Insert Result :: "+message.getPayload());
125 | }else{
126 | LOGGER.info("SQL Insert Result :: null");
127 | }
128 | }
129 |
130 |
131 | }
132 |
--------------------------------------------------------------------------------
/siexample/src/main/java/com/cpandey/siexample/service/EmailSender.java:
--------------------------------------------------------------------------------
1 | package com.cpandey.siexample.service;
2 |
3 | import javax.mail.internet.InternetAddress;
4 | import javax.mail.internet.MimeMessage;
5 |
6 | import org.apache.commons.lang.StringUtils;
7 | import org.apache.velocity.app.VelocityEngine;
8 | import org.springframework.beans.factory.annotation.Autowired;
9 | import org.springframework.core.io.FileSystemResource;
10 | import org.springframework.mail.javamail.JavaMailSender;
11 | import org.springframework.mail.javamail.MimeMessageHelper;
12 | import org.springframework.mail.javamail.MimeMessagePreparator;
13 | import org.springframework.stereotype.Component;
14 | import org.springframework.ui.velocity.VelocityEngineUtils;
15 | /**
16 | * @author Chandan Pandey
17 | *
18 | */
19 | @Component("emailSender")
20 | public class EmailSender {
21 |
22 | @Autowired
23 | private JavaMailSender mailSender;
24 |
25 | @Autowired
26 | private VelocityEngine velocityEngine;
27 |
28 |
29 | public void sendEmail(final String toEmailAddresses, final String fromEmailAddress,
30 | final String subject) {
31 |
32 | sendEmail(toEmailAddresses, fromEmailAddress, subject, null, null);
33 |
34 | }
35 |
36 | public void sendEmailWithAttachment(final String toEmailAddresses, final String fromEmailAddress,
37 | final String subject, final String attachmentPath,
38 | final String attachmentName) {
39 |
40 | sendEmail(toEmailAddresses, fromEmailAddress, subject, attachmentPath, attachmentName);
41 |
42 | }
43 |
44 | private void sendEmail(final String toEmailAddresses, final String fromEmailAddress,
45 | final String subject, final String attachmentPath,
46 | final String attachmentName) {
47 |
48 | MimeMessagePreparator preparator = new MimeMessagePreparator() {
49 |
50 | public void prepare(MimeMessage mimeMessage) throws Exception {
51 |
52 | MimeMessageHelper message = new MimeMessageHelper(mimeMessage, true);
53 | message.setTo(toEmailAddresses);
54 | message.setFrom(new InternetAddress(fromEmailAddress));
55 | message.setSubject(subject);
56 |
57 | String body = VelocityEngineUtils.mergeTemplateIntoString(
58 | velocityEngine, "templates.vm", "UTF-8", null);
59 | message.setText(body, true);
60 |
61 | if (!StringUtils.isBlank(attachmentPath)) {
62 | FileSystemResource file = new FileSystemResource(attachmentPath);
63 | message.addAttachment(attachmentName, file);
64 | }
65 | }
66 | };
67 | this.mailSender.send(preparator);
68 | }
69 | }
--------------------------------------------------------------------------------
/siexample/src/main/java/com/cpandey/siexample/service/FeedService.java:
--------------------------------------------------------------------------------
1 |
2 | package com.cpandey.siexample.service;
3 |
4 |
5 | import java.util.List;
6 |
7 | import com.cpandey.siexample.pojo.FeedEntity;
8 | /**
9 | * @author Chandan Pandey
10 | *
11 | */
12 |
13 | public interface FeedService {
14 |
15 | FeedEntity createFeed(FeedEntity feed);
16 | List readAllFeed();
17 |
18 |
19 | }
20 |
--------------------------------------------------------------------------------
/siexample/src/main/java/com/cpandey/siexample/service/PersistFeed.java:
--------------------------------------------------------------------------------
1 |
2 | package com.cpandey.siexample.service;
3 |
4 | import org.apache.log4j.Logger;
5 | import org.springframework.beans.factory.annotation.Autowired;
6 | import org.springframework.integration.annotation.MessageEndpoint;
7 | import org.springframework.integration.annotation.ServiceActivator;
8 |
9 | import com.cpandey.siexample.pojo.FeedEntity;
10 | import com.cpandey.siexample.pojo.SoFeed;
11 |
12 | /**
13 | * @author Chandan Pandey
14 | *
15 | */
16 | @MessageEndpoint
17 | public class PersistFeed {
18 | private static final Logger LOGGER = Logger.getLogger(PersistFeed.class);
19 |
20 | @Autowired FeedService feedService;
21 | @ServiceActivator
22 | public void persistFeedToDb(SoFeed feed) {
23 | //This will write to output channel of gateway
24 | //From there this will be picked by updating adapter
25 | feedService.createFeed(new FeedEntity(feed.getTitle()));
26 | }
27 | @ServiceActivator
28 | public void printFeed(FeedEntity feed) {
29 | //This will write to output channel of gateway
30 | //From there this will be picked by updating adapter
31 | LOGGER.info("Feed Id"+feed.getId()+" Feed Title "+feed.getTitle());
32 | }
33 | }
34 |
--------------------------------------------------------------------------------
/siexample/src/main/java/com/cpandey/siexample/service/PrintFeed.java:
--------------------------------------------------------------------------------
1 |
2 | package com.cpandey.siexample.service;
3 |
4 | import org.springframework.integration.annotation.MessageEndpoint;
5 | /**
6 | * @author Chandan Pandey
7 | *
8 | */
9 |
10 | @MessageEndpoint
11 | public class PrintFeed {
12 |
13 |
14 | }
15 |
--------------------------------------------------------------------------------
/siexample/src/main/java/com/cpandey/siexample/splitter/SoFeedSplitter.java:
--------------------------------------------------------------------------------
1 | package com.cpandey.siexample.splitter;
2 |
3 | import java.util.List;
4 |
5 | import org.springframework.messaging.Message;
6 |
7 | import com.sun.syndication.feed.synd.SyndCategoryImpl;
8 | import com.sun.syndication.feed.synd.SyndEntry;
9 | /**
10 | * @author Chandan Pandey
11 | *
12 | */
13 | public class SoFeedSplitter {
14 | public List splitAndPublish(Message message) {
15 | SyndEntry syndEntry=message.getPayload();
16 | List categories= syndEntry.getCategories();
17 | return categories;
18 | }
19 | }
20 |
--------------------------------------------------------------------------------
/siexample/src/main/java/com/cpandey/siexample/transformer/SoFeedDbTransformer.java:
--------------------------------------------------------------------------------
1 | package com.cpandey.siexample.transformer;
2 |
3 | import org.apache.log4j.Logger;
4 | import org.springframework.messaging.Message;
5 |
6 | import com.cpandey.siexample.pojo.SoFeed;
7 | import com.sun.syndication.feed.synd.SyndEntry;
8 | /**
9 | * @author Chandan Pandey
10 | *
11 | */
12 | public class SoFeedDbTransformer {
13 | private static final Logger LOGGER = Logger.getLogger(SoFeedDbTransformer.class);
14 | public SoFeed transformFeed(Message message){
15 | SyndEntry entry = message.getPayload();
16 | SoFeed soFeed=new SoFeed();
17 | soFeed.setTitle(entry.getTitle());
18 | soFeed.setDescription(entry.getDescription().getValue());
19 | soFeed.setCategories(entry.getCategories());
20 | soFeed.setLink(entry.getLink());
21 | soFeed.setAuthor(entry.getAuthor());
22 | LOGGER.info("JDBC"+soFeed.getTitle());
23 | return soFeed;
24 | }
25 | }
26 |
--------------------------------------------------------------------------------
/siexample/src/main/java/com/cpandey/siexample/transformer/SoFeedJMSTransformer.java:
--------------------------------------------------------------------------------
1 | package com.cpandey.siexample.transformer;
2 |
3 | import org.apache.log4j.Logger;
4 | import org.springframework.messaging.Message;
5 |
6 | import com.cpandey.siexample.pojo.SoFeed;
7 | import com.sun.syndication.feed.synd.SyndEntry;
8 | /**
9 | * @author Chandan Pandey
10 | *
11 | */
12 | public class SoFeedJMSTransformer {
13 | private static final Logger LOGGER = Logger.getLogger(SoFeedJMSTransformer.class);
14 |
15 | public String transformFeed(Message message){
16 | SyndEntry entry = message.getPayload();
17 | SoFeed soFeed=new SoFeed();
18 | soFeed.setTitle(entry.getTitle());
19 | soFeed.setDescription(entry.getDescription().getValue());
20 | soFeed.setCategories(entry.getCategories());
21 | soFeed.setLink(entry.getLink());
22 | soFeed.setAuthor(entry.getAuthor());
23 | //For JSM , return String
24 | LOGGER.info("JMS"+soFeed.getTitle());
25 | return soFeed.toString();
26 | }
27 | }
28 |
--------------------------------------------------------------------------------
/siexample/src/main/java/com/cpandey/siexample/transformer/SoFeedMailTransformer.java:
--------------------------------------------------------------------------------
1 | package com.cpandey.siexample.transformer;
2 |
3 | import java.util.Date;
4 |
5 | import org.apache.log4j.Logger;
6 | import org.springframework.mail.MailMessage;
7 | import org.springframework.mail.SimpleMailMessage;
8 | import org.springframework.messaging.Message;
9 |
10 | import com.cpandey.siexample.pojo.SoFeed;
11 | import com.sun.syndication.feed.synd.SyndEntry;
12 | /**
13 | * @author Chandan Pandey
14 | *
15 | */
16 | public class SoFeedMailTransformer {
17 | private static final Logger LOGGER = Logger.getLogger(SoFeedMailTransformer.class);
18 | public MailMessage transformFeed(Message message){
19 | SyndEntry entry = message.getPayload();
20 | SoFeed soFeed=new SoFeed();
21 | soFeed.setTitle(entry.getTitle());
22 | soFeed.setDescription(entry.getDescription().getValue());
23 | soFeed.setCategories(entry.getCategories());
24 | soFeed.setLink(entry.getLink());
25 | soFeed.setAuthor(entry.getAuthor());
26 |
27 | //For Mail return MailMessage
28 | MailMessage msg = new SimpleMailMessage();
29 | msg.setTo("cpandey05@gmail.com");
30 | msg.setFrom("cpandey05@gmail.com");
31 | msg.setSubject("TestMail");
32 | msg.setSentDate(new Date());
33 | msg.setText("Mail Text");
34 | LOGGER.info("Mail Message"+soFeed.getTitle());
35 | return msg;
36 | }
37 | }
38 |
--------------------------------------------------------------------------------
/siexample/src/main/resources/H2DB-CreateScript.sql:
--------------------------------------------------------------------------------
1 | drop table TESTDATA;
2 | DROP TABLE OPENJPA_SEQUENCE_TABLE;
3 |
4 | CREATE TABLE OPENJPA_SEQUENCE_TABLE (ID TINYINT NOT NULL, SEQUENCE_VALUE BIGINT, PRIMARY KEY (ID));
5 | CREATE TABLE TESTDATA (id BIGINT generated by default as identity, name VARCHAR(255), CREATED_DATE_TIME TIMESTAMP, PRIMARY KEY (id));
6 |
7 |
--------------------------------------------------------------------------------
/siexample/src/main/resources/H2DB-DropScript.sql:
--------------------------------------------------------------------------------
1 | drop table OPENJPA_SEQUENCE_TABLE;
2 | drop table TESTDATA;
3 |
--------------------------------------------------------------------------------
/siexample/src/main/resources/H2DB-InsertScript.sql:
--------------------------------------------------------------------------------
1 | insert into TESTDATA(id, name, CREATED_DATE_TIME)
2 | values ('1001', 'Chandan', NOW());
3 |
--------------------------------------------------------------------------------
/siexample/src/main/resources/META-INF/spring/integration/common-jpa-context.xml:
--------------------------------------------------------------------------------
1 |
2 |
15 |
16 |
17 |
18 |
19 |
20 |
21 |
22 |
23 |
24 |
25 |
26 |
27 |
28 |
29 |
30 |
32 |
33 |
34 |
35 |
36 |
37 |
38 |
39 |
40 |
41 |
42 |
43 |
44 |
45 |
46 |
47 |
--------------------------------------------------------------------------------
/siexample/src/main/resources/META-INF/spring/integration/email-config.xml:
--------------------------------------------------------------------------------
1 |
2 |
9 |
10 |
11 |
12 |
13 |
14 |
15 |
16 |
17 | ${mail.smtp.auth}
18 | ${mail.smtp.starttls.enable}
19 | ${mail.smtp.host}
20 | ${mail.smtp.port}
21 |
22 |
23 |
24 |
25 |
26 |
27 |
28 |
29 |
30 | resource.loader=class
31 | class.resource.loader.class=org.apache.velocity.runtime.resource.loader.ClasspathResourceLoader
32 |
33 |
34 |
35 |
36 |
37 |
38 |
--------------------------------------------------------------------------------
/siexample/src/main/resources/META-INF/spring/integration/employee.input:
--------------------------------------------------------------------------------
1 | Chandan, SWEngineer, RnD, India
2 | Pandey, Tester, RnD, India
--------------------------------------------------------------------------------
/siexample/src/main/resources/META-INF/spring/integration/hibernate-config.xml:
--------------------------------------------------------------------------------
1 |
2 |
15 |
16 |
17 |
18 |
20 |
21 |
22 |
23 |
--------------------------------------------------------------------------------
/siexample/src/main/resources/META-INF/spring/integration/jms-config.xml:
--------------------------------------------------------------------------------
1 |
2 |
15 |
16 |
17 |
18 |
20 |
21 |
22 |
23 |
--------------------------------------------------------------------------------
/siexample/src/main/resources/META-INF/spring/integration/setting.properties:
--------------------------------------------------------------------------------
1 | #Give a valid URL from where feeds can be fetched -check for any copyright issue,
2 | # Example http://stackoverflow.com/feeds
3 | feeds.url=urltofetchfeedfrom
4 |
5 | db.password=root
6 | db.username=postgres
7 | db.databaseName=postgres
8 | db.driverClassName=org.postgresql.Driver
9 | db.serverName=localhost:5432
10 | db.url=jdbc:postgresql://${db.serverName}/${db.databaseName}
11 |
12 | twitter.consumerkey=consumerkey
13 | twitter.consumersecret=consumersecret
14 | twitter.accesstoken=accesstoken
15 | twitter.accesstokensecret=accesstokensecret
16 |
17 | mail.smtp.auth=true
18 | mail.smtp.starttls.enable=true
19 | mail.smtp.host=smtp.gmail.com
20 | mail.smtp.port=587
21 | mail.username=username
22 | mail.password=password
23 |
24 | ftp.host=localhost
25 | ftp.port=21
26 | ftp.username=testuser
27 | ftp.password=12345
28 | ftp.local.directory=/somefolder
29 | ftp.remote.directory=/somefolder
30 |
31 | file.inputdirectory=\Projects\inputfolderforsi
32 | file.outputdirectory=\Projects\outputfolderforsi
33 | file.taildirectory=\Projects\tailfolderforsi\test.txt
34 |
--------------------------------------------------------------------------------
/siexample/src/main/resources/META-INF/spring/integration/spring-integration-aggregator.xml:
--------------------------------------------------------------------------------
1 |
2 |
21 |
22 |
23 |
24 |
25 |
26 |
27 |
28 |
29 |
30 |
31 |
32 |
36 |
37 |
38 |
39 |
40 |
41 |
42 |
43 |
44 |
45 |
46 |
47 |
48 |
49 |
50 |
51 |
52 |
53 |
54 |
55 |
56 |
57 |
58 |
59 |
60 |
61 |
62 |
63 |
64 |
65 |
66 |
67 |
68 |
69 |
70 |
71 |
72 |
73 |
79 |
80 |
81 |
82 |
83 |
84 |
85 |
86 |
87 |
88 |
89 |
90 |
91 |
92 |
93 |
94 |
95 |
96 |
97 |
98 |
--------------------------------------------------------------------------------
/siexample/src/main/resources/META-INF/spring/integration/spring-integration-batch.xml:
--------------------------------------------------------------------------------
1 |
17 |
18 |
19 |
20 |
21 |
22 |
23 |
24 |
25 |
26 |
27 |
28 |
29 |
30 |
31 |
32 |
33 |
34 |
35 |
36 |
39 |
40 |
41 |
42 |
43 |
44 |
45 |
46 |
47 |
48 |
49 |
50 |
51 |
52 |
53 |
54 |
55 |
56 |
57 |
58 |
59 |
60 |
61 |
62 |
63 |
64 |
65 |
66 |
67 |
68 |
69 |
70 |
71 |
72 |
73 |
74 |
75 |
76 |
78 |
79 |
80 |
81 |
82 |
83 |
84 |
85 |
86 |
87 |
88 |
89 |
91 |
92 |
93 |
94 |
95 |
96 |
97 |
98 |
99 |
100 |
101 |
102 |
103 |
104 |
105 |
106 |
107 |
108 |
--------------------------------------------------------------------------------
/siexample/src/main/resources/META-INF/spring/integration/spring-integration-database.xml:
--------------------------------------------------------------------------------
1 |
2 |
17 |
18 |
19 |
20 |
21 |
25 |
26 |
27 |
28 |
30 |
31 |
32 |
33 |
36 |
37 |
38 |
39 |
40 |
41 |
45 |
46 |
47 |
48 |
49 |
50 |
51 |
54 |
55 |
56 |
57 |
58 |
60 |
61 |
62 |
63 |
66 |
67 |
68 |
69 |
70 |
71 |
72 |
73 |
74 |
75 |
76 |
--------------------------------------------------------------------------------
/siexample/src/main/resources/META-INF/spring/integration/spring-integration-endpoints.xml:
--------------------------------------------------------------------------------
1 |
2 |
21 |
22 |
23 |
24 |
25 |
26 |
27 |
28 |
29 |
30 |
31 |
32 |
36 |
37 |
38 |
39 |
40 |
41 |
42 |
43 |
44 |
45 |
46 |
47 |
48 |
49 |
50 |
51 |
52 |
53 |
54 |
55 |
56 |
57 |
58 |
59 |
60 |
61 |
62 |
63 |
64 |
65 |
66 |
67 |
68 |
69 |
70 |
71 |
72 |
74 |
75 |
76 |
78 |
79 |
80 |
81 |
82 |
84 |
85 |
87 |
88 |
90 |
91 |
92 |
93 |
94 |
95 |
96 |
97 |
98 |
99 |
--------------------------------------------------------------------------------
/siexample/src/main/resources/META-INF/spring/integration/spring-integration-file.xml:
--------------------------------------------------------------------------------
1 |
2 |
9 |
10 |
11 |
12 |
13 |
14 |
15 |
16 |
17 |
18 |
19 |
21 |
22 |
23 |
24 |
25 |
26 |
27 |
32 |
33 |
37 |
38 |
41 |
42 |
--------------------------------------------------------------------------------
/siexample/src/main/resources/META-INF/spring/integration/spring-integration-ftp.xml:
--------------------------------------------------------------------------------
1 |
2 |
9 |
10 |
11 |
12 |
13 |
14 |
15 |
16 |
17 |
18 |
19 |
21 |
22 |
23 |
24 |
25 |
26 |
27 |
28 |
36 |
38 |
39 |
40 |
41 |
45 |
46 |
47 |
54 |
55 |
56 |
57 |
--------------------------------------------------------------------------------
/siexample/src/main/resources/META-INF/spring/integration/spring-integration-jms.xml:
--------------------------------------------------------------------------------
1 |
2 |
9 |
10 |
11 |
12 |
13 |
14 |
15 |
16 |
17 |
18 |
21 |
22 |
23 |
24 |
25 |
28 |
29 |
30 |
31 |
32 |
33 |
35 |
36 |
37 |
40 |
41 |
42 |
43 |
44 |
45 |
46 |
47 |
48 |
49 |
50 |
51 |
52 |
53 |
54 |
55 |
56 |
57 |
58 |
59 |
60 |
61 |
--------------------------------------------------------------------------------
/siexample/src/main/resources/META-INF/spring/integration/spring-integration-resequencer.xml:
--------------------------------------------------------------------------------
1 |
2 |
21 |
22 |
23 |
24 |
25 |
26 |
27 |
28 |
29 |
30 |
31 |
32 |
36 |
37 |
38 |
39 |
40 |
41 |
42 |
43 |
44 |
45 |
46 |
47 |
48 |
49 |
50 |
51 |
52 |
53 |
54 |
55 |
56 |
57 |
58 |
59 |
60 |
61 |
62 |
63 |
64 |
65 |
66 |
67 |
68 |
69 |
70 |
71 |
72 |
73 |
74 |
80 |
81 |
82 |
83 |
84 |
85 |
86 |
87 |
88 |
89 |
90 |
91 |
92 |
93 |
--------------------------------------------------------------------------------
/siexample/src/main/resources/META-INF/spring/integration/spring-integration-stream.xml:
--------------------------------------------------------------------------------
1 |
2 |
11 |
12 |
13 |
14 |
15 |
16 |
--------------------------------------------------------------------------------
/siexample/src/main/resources/META-INF/spring/integration/spring-integration-twitter.xml:
--------------------------------------------------------------------------------
1 |
2 |
9 |
10 |
11 |
12 |
13 |
14 |
15 |
16 |
17 |
18 |
19 |
20 |
21 |
22 |
23 |
24 |
25 |
31 |
32 |
36 |
37 |
41 |
42 |
43 |
46 |
47 |
48 |
51 |
52 |
55 |
58 |
64 |
65 |
--------------------------------------------------------------------------------
/siexample/src/main/resources/log4j.xml:
--------------------------------------------------------------------------------
1 |
2 |
3 |
4 |
5 |
6 |
7 |
8 |
9 |
10 |
11 |
12 |
13 |
14 |
15 |
16 |
17 |
18 |
19 |
20 |
21 |
22 |
23 |
24 |
25 |
26 |
27 |
28 |
29 |
--------------------------------------------------------------------------------
/siexample/src/test/java/com/cpandey/siexample/TestFilter.java:
--------------------------------------------------------------------------------
1 | package com.cpandey.siexample;
2 |
3 | import static org.junit.Assert.assertNotNull;
4 | import static org.junit.Assert.assertNull;
5 | import static org.junit.Assert.assertThat;
6 | import static org.springframework.integration.test.matcher.HeaderMatcher.hasHeader;
7 | import static org.springframework.integration.test.matcher.HeaderMatcher.hasHeaderKey;
8 | import static org.springframework.integration.test.matcher.PayloadMatcher.hasPayload;
9 |
10 | import java.util.ArrayList;
11 | import java.util.List;
12 |
13 | import org.junit.Test;
14 | import org.junit.runner.RunWith;
15 | import org.springframework.beans.factory.annotation.Autowired;
16 | import org.springframework.integration.channel.QueueChannel;
17 | import org.springframework.integration.support.MessageBuilder;
18 | import org.springframework.messaging.Message;
19 | import org.springframework.messaging.MessageChannel;
20 | import org.springframework.test.context.ContextConfiguration;
21 | import org.springframework.test.context.junit4.SpringJUnit4ClassRunner;
22 |
23 | import com.cpandey.siexample.pojo.SoFeed;
24 | import com.sun.syndication.feed.synd.SyndCategoryImpl;
25 | import com.sun.syndication.feed.synd.SyndContent;
26 | import com.sun.syndication.feed.synd.SyndContentImpl;
27 | import com.sun.syndication.feed.synd.SyndEntry;
28 | import com.sun.syndication.feed.synd.SyndEntryImpl;
29 |
30 | @ContextConfiguration(locations = {"classpath*:**/TestFilter-context.xml"}) // default context name is -context.xml
31 | @RunWith(SpringJUnit4ClassRunner.class)
32 | public class TestFilter {
33 | @Autowired
34 | MessageChannel fetchedFeedChannel;
35 |
36 | @Autowired
37 | QueueChannel filteredFeedChannel;
38 |
39 |
40 | @Test
41 | public void javaMessagePassedThrough() {
42 | SyndEntry entry =new SyndEntryImpl();
43 | entry.setTitle("Test");
44 | SyndContent content=new SyndContentImpl();
45 | content.setValue("TestValue");
46 | entry.setDescription(content);
47 | List catList=new ArrayList();
48 | SyndCategoryImpl category=new SyndCategoryImpl();
49 | category.setName("java");
50 | catList.add(category);
51 | entry.setCategories(catList);
52 | entry.setLink("TestLink");
53 | entry.setAuthor("TestAuthor");
54 |
55 | Message message = MessageBuilder.withPayload(entry).build();
56 | fetchedFeedChannel.send(message);
57 | Message> outMessage = filteredFeedChannel.receive(0);
58 | assertNotNull("Expected an output message", outMessage);
59 | assertThat(outMessage, hasPayload(entry));
60 | }
61 |
62 | @Test
63 | public void nonJavaMessageDropped() {
64 | SyndEntry entry =new SyndEntryImpl();
65 | entry.setTitle("Test");
66 | SyndContent content=new SyndContentImpl();
67 | content.setValue("TestValue");
68 | entry.setDescription(content);
69 | List catList=new ArrayList();
70 | SyndCategoryImpl category=new SyndCategoryImpl();
71 | category.setName("nonjava");
72 | catList.add(category);
73 | entry.setCategories(catList);
74 | entry.setLink("TestLink");
75 | entry.setAuthor("TestAuthor");
76 |
77 | Message message = MessageBuilder.withPayload(entry).build();
78 | fetchedFeedChannel.send(message);
79 | Message> outMessage = filteredFeedChannel.receive(0);
80 | assertNull("Expected no output message", outMessage);
81 | }
82 | }
83 |
--------------------------------------------------------------------------------
/siexample/src/test/java/com/cpandey/siexample/TestSoDBFeedTransformer.java:
--------------------------------------------------------------------------------
1 | package com.cpandey.siexample;
2 |
3 | import static org.junit.Assert.assertEquals;
4 | import static org.junit.Assert.assertNotNull;
5 | import static org.junit.Assert.assertNull;
6 | import static org.junit.Assert.assertThat;
7 | import static org.junit.Assert.assertTrue;
8 | import static org.springframework.integration.test.matcher.PayloadMatcher.hasPayload;
9 |
10 | import java.util.ArrayList;
11 | import java.util.List;
12 |
13 | import org.junit.Test;
14 | import org.junit.runner.RunWith;
15 | import org.springframework.beans.factory.annotation.Autowired;
16 | import org.springframework.integration.channel.QueueChannel;
17 | import org.springframework.integration.support.MessageBuilder;
18 | import org.springframework.integration.transformer.MessageTransformationException;
19 | import org.springframework.messaging.Message;
20 | import org.springframework.messaging.MessageChannel;
21 | import org.springframework.messaging.MessageHandlingException;
22 | import org.springframework.messaging.MessagingException;
23 | import org.springframework.test.context.ContextConfiguration;
24 | import org.springframework.test.context.junit4.SpringJUnit4ClassRunner;
25 |
26 | import com.cpandey.siexample.pojo.SoFeed;
27 | import com.sun.syndication.feed.synd.SyndCategoryImpl;
28 | import com.sun.syndication.feed.synd.SyndContent;
29 | import com.sun.syndication.feed.synd.SyndContentImpl;
30 | import com.sun.syndication.feed.synd.SyndEntry;
31 | import com.sun.syndication.feed.synd.SyndEntryImpl;
32 |
33 | @ContextConfiguration(locations = {"classpath*:**/TestSoDBFeedTransformer-context.xml"}) // default context name is -context.xml
34 | @RunWith(SpringJUnit4ClassRunner.class)
35 | public class TestSoDBFeedTransformer {
36 | @Autowired
37 | MessageChannel filteredFeedChannel;
38 |
39 | @Autowired
40 | QueueChannel transformedChannel;
41 |
42 | @Test
43 | public void messageIsConvertedToEntity() {
44 | SyndEntry entry =new SyndEntryImpl();
45 | entry.setTitle("Test");
46 | SyndContent content=new SyndContentImpl();
47 | content.setValue("TestValue");
48 | entry.setDescription(content);
49 | List catList=new ArrayList();
50 | entry.setCategories(catList);
51 | entry.setLink("TestLink");
52 | entry.setAuthor("TestAuthor");
53 |
54 |
55 | SoFeed expectedSoFeed=new SoFeed();
56 | expectedSoFeed.setTitle(entry.getTitle());
57 | expectedSoFeed.setDescription(entry.getDescription().getValue());
58 | expectedSoFeed.setCategories(entry.getCategories());
59 | expectedSoFeed.setLink(entry.getLink());
60 | expectedSoFeed.setAuthor(entry.getAuthor());
61 |
62 |
63 |
64 | Message message = MessageBuilder.withPayload(entry).build();
65 | filteredFeedChannel.send(message);
66 | Message> outMessage = transformedChannel.receive(0);
67 | SoFeed soFeedReceived=(SoFeed)outMessage.getPayload();
68 | assertNotNull(outMessage);
69 | assertThat(outMessage, hasPayload(soFeedReceived));
70 | outMessage = transformedChannel.receive(0);
71 | assertNull("Only one message expected", outMessage);
72 | }
73 |
74 | @Test(expected = MessageTransformationException.class)
75 | public void errorReportedWhenPayloadIsWrong() {
76 | Message message = MessageBuilder.withPayload("this should fail").build();
77 | filteredFeedChannel.send(message);
78 | }
79 |
80 | }
81 |
--------------------------------------------------------------------------------
/siexample/src/test/java/com/cpandey/siexample/TestSoHeaderAddition.java:
--------------------------------------------------------------------------------
1 | package com.cpandey.siexample;
2 |
3 | import static org.junit.Assert.assertThat;
4 | import static org.springframework.integration.test.matcher.HeaderMatcher.hasHeader;
5 | import static org.springframework.integration.test.matcher.HeaderMatcher.hasHeaderKey;
6 |
7 | import org.junit.Test;
8 | import org.junit.runner.RunWith;
9 | import org.springframework.beans.factory.annotation.Autowired;
10 | import org.springframework.integration.channel.QueueChannel;
11 | import org.springframework.integration.support.MessageBuilder;
12 | import org.springframework.messaging.Message;
13 | import org.springframework.messaging.MessageChannel;
14 | import org.springframework.test.context.ContextConfiguration;
15 | import org.springframework.test.context.junit4.SpringJUnit4ClassRunner;
16 |
17 | @ContextConfiguration(locations = {"classpath*:**/TestSoHeaderAddition-context.xml"}) // default context name is -context.xml
18 | @RunWith(SpringJUnit4ClassRunner.class)
19 | public class TestSoHeaderAddition {
20 | @Autowired
21 | MessageChannel filteredFeedChannel;
22 |
23 | @Autowired
24 | QueueChannel transformedChannel;
25 |
26 | @Test
27 | public void headerIsAddedToEntity() {
28 | Message message = MessageBuilder.withPayload("testheader").build();
29 | filteredFeedChannel.send(message);
30 | Message> outMessage = transformedChannel.receive(0);
31 | assertThat(outMessage, hasHeaderKey("testHeaderKey1"));
32 | assertThat(outMessage, hasHeader("testHeaderKey1", "testHeaderValue1"));
33 | }
34 | }
35 |
--------------------------------------------------------------------------------
/siexample/src/test/java/com/cpandey/siexample/TestSplitter.java:
--------------------------------------------------------------------------------
1 | package com.cpandey.siexample;
2 |
3 | import static org.junit.Assert.assertNotNull;
4 | import static org.junit.Assert.assertNull;
5 | import static org.junit.Assert.assertThat;
6 | import static org.springframework.integration.test.matcher.HeaderMatcher.hasHeader;
7 | import static org.springframework.integration.test.matcher.HeaderMatcher.hasHeaderKey;
8 | import static org.springframework.integration.test.matcher.PayloadMatcher.hasPayload;
9 |
10 | import java.util.ArrayList;
11 | import java.util.List;
12 |
13 | import org.junit.Test;
14 | import org.junit.runner.RunWith;
15 | import org.springframework.beans.factory.annotation.Autowired;
16 | import org.springframework.integration.channel.QueueChannel;
17 | import org.springframework.integration.support.MessageBuilder;
18 | import org.springframework.messaging.Message;
19 | import org.springframework.messaging.MessageChannel;
20 | import org.springframework.test.context.ContextConfiguration;
21 | import org.springframework.test.context.junit4.SpringJUnit4ClassRunner;
22 |
23 | import com.cpandey.siexample.pojo.SoFeed;
24 | import com.sun.syndication.feed.synd.SyndCategoryImpl;
25 | import com.sun.syndication.feed.synd.SyndContent;
26 | import com.sun.syndication.feed.synd.SyndContentImpl;
27 | import com.sun.syndication.feed.synd.SyndEntry;
28 | import com.sun.syndication.feed.synd.SyndEntryImpl;
29 |
30 | @ContextConfiguration(locations = {"classpath*:**/TestSplitter-context.xml"}) // default context name is -context.xml
31 | @RunWith(SpringJUnit4ClassRunner.class)
32 | public class TestSplitter {
33 | @Autowired
34 | MessageChannel filteredFeedChannel;
35 |
36 | @Autowired
37 | QueueChannel splitFeedOutputChannel;
38 |
39 |
40 | @Test
41 | public void javaMessagePassedThrough() {
42 | SyndEntry entry =new SyndEntryImpl();
43 | entry.setTitle("Test");
44 | SyndContent content=new SyndContentImpl();
45 | content.setValue("TestValue");
46 | entry.setDescription(content);
47 | List catList=new ArrayList();
48 | SyndCategoryImpl category1=new SyndCategoryImpl();
49 | category1.setName("java");
50 | category1.setTaxonomyUri("");
51 | SyndCategoryImpl category2=new SyndCategoryImpl();
52 | category2.setName("java");
53 | category2.setTaxonomyUri("");
54 | catList.add(category1);
55 | catList.add(category2);
56 | entry.setCategories(catList);
57 | entry.setLink("TestLink");
58 | entry.setAuthor("TestAuthor");
59 |
60 | Message message = MessageBuilder.withPayload(entry).build();
61 | filteredFeedChannel.send(message);
62 | Message> outMessage1 = splitFeedOutputChannel.receive(0);
63 | Message> outMessage2 = splitFeedOutputChannel.receive(0);
64 | assertNotNull("Expected an output message", outMessage1);
65 | assertNotNull("Expected an output message", outMessage2);
66 | assertThat(outMessage1, hasPayload(category1));
67 | assertThat(outMessage2, hasPayload(category2));
68 | }
69 |
70 | }
71 |
--------------------------------------------------------------------------------
/siexample/src/test/resources/TestFilter-context.xml:
--------------------------------------------------------------------------------
1 |
2 |
7 |
8 |
9 |
10 |
11 |
12 |
13 |
14 |
16 |
17 |
--------------------------------------------------------------------------------
/siexample/src/test/resources/TestSoDBFeedTransformer-context.xml:
--------------------------------------------------------------------------------
1 |
2 |
7 |
8 |
9 |
10 |
11 |
12 |
13 |
14 |
16 |
17 |
--------------------------------------------------------------------------------
/siexample/src/test/resources/TestSoHeaderAddition-context.xml:
--------------------------------------------------------------------------------
1 |
2 |
7 |
8 |
9 |
10 |
11 |
12 |
13 |
14 |
15 |
16 |
17 |
18 |
--------------------------------------------------------------------------------
/siexample/src/test/resources/TestSplitter-context.xml:
--------------------------------------------------------------------------------
1 |
2 |
7 |
8 |
9 |
10 |
11 |
12 |
13 |
14 |
16 |
17 |
--------------------------------------------------------------------------------
/siexamplehttpinboundoutbound/.classpath:
--------------------------------------------------------------------------------
1 |
2 |
3 |
4 |
5 |
6 |
7 |
8 |
9 |
10 |
11 |
12 |
13 |
14 |
15 |
16 |
17 |
18 |
19 |
20 |
21 |
22 |
23 |
24 |
25 |
26 |
27 |
28 |
29 |
30 |
31 |
32 |
33 |
--------------------------------------------------------------------------------
/siexamplehttpinboundoutbound/.project:
--------------------------------------------------------------------------------
1 |
2 |
3 | siexamplehttpinboundoutbound
4 |
5 |
6 |
7 |
8 |
9 | org.eclipse.wst.jsdt.core.javascriptValidator
10 |
11 |
12 |
13 |
14 | org.eclipse.jdt.core.javabuilder
15 |
16 |
17 |
18 |
19 | org.eclipse.wst.common.project.facet.core.builder
20 |
21 |
22 |
23 |
24 | org.eclipse.m2e.core.maven2Builder
25 |
26 |
27 |
28 |
29 | org.eclipse.wst.validation.validationbuilder
30 |
31 |
32 |
33 |
34 |
35 | org.eclipse.jem.workbench.JavaEMFNature
36 | org.eclipse.wst.common.modulecore.ModuleCoreNature
37 | org.eclipse.jdt.core.javanature
38 | org.eclipse.m2e.core.maven2Nature
39 | org.eclipse.wst.common.project.facet.core.nature
40 | org.eclipse.wst.jsdt.core.jsNature
41 |
42 |
43 |
--------------------------------------------------------------------------------
/siexamplehttpinboundoutbound/.settings/.jsdtscope:
--------------------------------------------------------------------------------
1 |
2 |
3 |
4 |
5 |
6 |
7 |
8 |
9 |
10 |
11 |
12 |
13 |
--------------------------------------------------------------------------------
/siexamplehttpinboundoutbound/.settings/com.springsource.sts.config.flow.prefs:
--------------------------------------------------------------------------------
1 | //com.springsource.sts.config.flow.coordinates\:http\://www.springframework.org/schema/integration\:/httpinbound/src/main/resources/META-INF/spring/integration/http-outbound-config.xml=\r\n\r\n\r\n\r\n\r\n\r\n\r\n\r\n\r\n\r\n\r\n\r\n\r\n\r\n
2 | //com.springsource.sts.config.flow.coordinates\:http\://www.springframework.org/schema/integration\:/httpinbound/src/main/webapp/WEB-INF/http-inbound-config.xml=\r\n\r\n\r\n\r\n\r\n\r\n\r\n\r\n\r\n\r\n\r\n\r\n\r\n\r\n
3 | eclipse.preferences.version=1
4 |
--------------------------------------------------------------------------------
/siexamplehttpinboundoutbound/.settings/org.eclipse.jdt.core.prefs:
--------------------------------------------------------------------------------
1 | eclipse.preferences.version=1
2 | org.eclipse.jdt.core.compiler.codegen.inlineJsrBytecode=enabled
3 | org.eclipse.jdt.core.compiler.codegen.targetPlatform=1.5
4 | org.eclipse.jdt.core.compiler.compliance=1.5
5 | org.eclipse.jdt.core.compiler.problem.assertIdentifier=error
6 | org.eclipse.jdt.core.compiler.problem.enumIdentifier=error
7 | org.eclipse.jdt.core.compiler.problem.forbiddenReference=warning
8 | org.eclipse.jdt.core.compiler.source=1.5
9 |
--------------------------------------------------------------------------------
/siexamplehttpinboundoutbound/.settings/org.eclipse.m2e.core.prefs:
--------------------------------------------------------------------------------
1 | activeProfiles=
2 | eclipse.preferences.version=1
3 | resolveWorkspaceProjects=true
4 | version=1
5 |
--------------------------------------------------------------------------------
/siexamplehttpinboundoutbound/.settings/org.eclipse.wst.common.component:
--------------------------------------------------------------------------------
1 |
2 |
3 |
4 |
5 |
6 |
7 |
8 |
9 |
10 |
11 |
--------------------------------------------------------------------------------
/siexamplehttpinboundoutbound/.settings/org.eclipse.wst.common.project.facet.core.xml:
--------------------------------------------------------------------------------
1 |
2 |
3 |
4 |
5 |
6 |
7 |
8 |
--------------------------------------------------------------------------------
/siexamplehttpinboundoutbound/.settings/org.eclipse.wst.jsdt.ui.superType.container:
--------------------------------------------------------------------------------
1 | org.eclipse.wst.jsdt.launching.baseBrowserLibrary
--------------------------------------------------------------------------------
/siexamplehttpinboundoutbound/.settings/org.eclipse.wst.jsdt.ui.superType.name:
--------------------------------------------------------------------------------
1 | Window
--------------------------------------------------------------------------------
/siexamplehttpinboundoutbound/.settings/org.eclipse.wst.validation.prefs:
--------------------------------------------------------------------------------
1 | disabled=06target
2 | eclipse.preferences.version=1
3 |
--------------------------------------------------------------------------------
/siexamplehttpinboundoutbound/README.txt:
--------------------------------------------------------------------------------
1 | Build the Maven project to download all dependencies "mvn -X clean package"
2 |
3 | Refer /META-INF/spring/integration/setting.properties for all the values which can be set
4 |
5 | All classes needed to run sample App aer inside package com.cpandey.siexample
6 | -select any of those and then "run as Java" program
7 |
8 | Following are the details classes which map to chapter wise samples
9 |
10 | Chapter 1-5
11 | Gateway, Service Activator, Router, Filter, Splitter -EndpointsMailJmsDb.java
12 | Aggregator, ChainingHandler -Aggregator.java
13 | Resequencer, Enricher -Resequencer.java
14 | Chapter 6
15 | FTP/FTPS FTPIntegration
16 | Twitter, SocialIntegration
17 | JMS, EndpointsMailJmsDb
18 | Mail EndpointsMailJmsDb
19 | Database EndpointsMailJmsDb
20 | HTTP -Separate Project, to be deployed inside tomcat : siexamplehttpinboundoutbound
21 | WebService -Separate Project, to be deployed inside tomcat : siexamplewsinboundoutbound
22 | Chapter 7
23 | Spring Batch BatchJobLauncher.java and SpringIntegrationBatchJobLauncher.java
24 | Chapter 8
25 | Testing Files under src/test/java
26 | Chapter 9 and 10
27 | JMX and an End to End example :Separate project : feedsexample
28 |
--------------------------------------------------------------------------------
/siexamplehttpinboundoutbound/pom.xml:
--------------------------------------------------------------------------------
1 |
3 | 4.0.0
4 | httpinbound
5 | httpinbound
6 | war
7 | 0.0.1-SNAPSHOT
8 | httpinbound Maven Webapp
9 | http://maven.apache.org
10 |
11 | 4.0.1.RELEASE
12 | 4.0.3.RELEASE
13 | 1.2.17
14 |
15 |
16 |
17 | junit
18 | junit
19 | 3.8.1
20 | test
21 |
22 |
23 | org.springframework.integration
24 | spring-integration-http
25 | ${spring.integration.version}
26 |
27 |
28 | org.springframework
29 | spring-webmvc
30 | ${spring.version}
31 |
32 |
33 | log4j
34 | log4j
35 | ${log4j.version}
36 |
37 |
38 |
39 |
40 | httpinbound
41 |
42 |
43 |
--------------------------------------------------------------------------------
/siexamplehttpinboundoutbound/src/main/java/com/cpandey/siexample/HttpOutBoundClient.java:
--------------------------------------------------------------------------------
1 | package com.cpandey.siexample;
2 |
3 | import org.apache.log4j.Logger;
4 |
5 | import org.springframework.context.ApplicationContext;
6 | import org.springframework.context.support.ClassPathXmlApplicationContext;
7 | /**
8 | * @author Chandan Pandey
9 | *
10 | */
11 | public class HttpOutBoundClient {
12 |
13 | private static Logger logger = Logger.getLogger(HttpOutBoundClient.class);
14 |
15 | public static void main(String[] args) {
16 | //refer WEB-INF/http-inbound-config.xml for further configuration
17 | ApplicationContext context = new ClassPathXmlApplicationContext("/META-INF/spring/integration/http-outbound-config.xml");
18 | OutboundRequestGateway outboundRequestGateway = context.getBean("outboundRequestGateway", OutboundRequestGateway.class);
19 | String reply = outboundRequestGateway.echoResponse("Hello");
20 | logger.info("OutboundRequestGateway");
21 | logger.info("OutboundRequestGateway Replied with: " + reply);
22 | }
23 |
24 | }
25 |
--------------------------------------------------------------------------------
/siexamplehttpinboundoutbound/src/main/java/com/cpandey/siexample/OutboundRequestGateway.java:
--------------------------------------------------------------------------------
1 | package com.cpandey.siexample;
2 | /**
3 | * @author Chandan Pandey
4 | *
5 | */
6 | public interface OutboundRequestGateway {
7 |
8 | String echoResponse(String request);
9 |
10 | }
11 |
--------------------------------------------------------------------------------
/siexamplehttpinboundoutbound/src/main/resources/META-INF/spring/integration/http-outbound-config.xml:
--------------------------------------------------------------------------------
1 |
2 |
9 |
10 |
13 |
14 |
15 |
16 |
20 |
21 |
--------------------------------------------------------------------------------
/siexamplehttpinboundoutbound/src/main/webapp/WEB-INF/http-inbound-config.xml:
--------------------------------------------------------------------------------
1 |
2 |
12 |
13 |
16 |
17 |
18 |
19 |
20 |
21 |
--------------------------------------------------------------------------------
/siexamplehttpinboundoutbound/src/main/webapp/WEB-INF/web.xml:
--------------------------------------------------------------------------------
1 |
2 |
3 | testhttpinbound
4 |
5 | testhttpinbound
6 | org.springframework.web.servlet.DispatcherServlet
7 |
8 | contextConfigLocation
9 | /WEB-INF/http-inbound-config.xml
10 |
11 | 1
12 |
13 |
14 | testhttpinbound
15 | /*
16 |
17 |
--------------------------------------------------------------------------------
/siexamplehttpinboundoutbound/src/main/webapp/index.html:
--------------------------------------------------------------------------------
1 | Successfull! -TRY out.
--------------------------------------------------------------------------------
/siexamplehttpinboundoutbound/src/main/webapp/index.jsp:
--------------------------------------------------------------------------------
1 |
2 |
3 | Hi There!
4 |
5 |
6 |
--------------------------------------------------------------------------------
/siexamplehttpinboundoutbound/src/test/com/cpandey/siexample/WsInBoundTest.java:
--------------------------------------------------------------------------------
1 | package com.cpandey.siexample;
2 | import static org.hamcrest.CoreMatchers.equalTo;
3 | import static org.junit.Assert.assertThat;
4 |
5 | import javax.xml.transform.Source;
6 |
7 | import org.apache.log4j.Logger;
8 | import org.junit.Test;
9 | import org.springframework.ws.client.core.WebServiceTemplate;
10 | import org.springframework.xml.transform.StringResult;
11 | import org.springframework.xml.transform.StringSource;
12 |
13 | public class WsInBoundTest {
14 |
15 | private static Logger logger = Logger.getLogger(WsInBoundTest.class);
16 | private static final String WS_URI = "http://localhost:8080/siexamplewsinbound/testwsservice";
17 | private final WebServiceTemplate template = new WebServiceTemplate();
18 |
19 | @Test
20 | public void testWebServiceRequestAndResponse() {
21 | StringResult result = new StringResult();
22 | Source payload = new StringSource(
23 | "" +
24 | "testwsinbound");
25 |
26 | template.sendSourceAndReceiveToResult(WS_URI, payload, result);
27 | logger.info("RESULT: " + result.toString());
28 | assertThat(result.toString(), equalTo(
29 | "" +
30 | "response:testwsinbound"));
31 | }
32 | }
33 |
--------------------------------------------------------------------------------
/siexamplewsinboundoutbound/.classpath:
--------------------------------------------------------------------------------
1 |
2 |
3 |
4 |
5 |
6 |
7 |
8 |
9 |
10 |
11 |
12 |
13 |
14 |
15 |
16 |
17 |
18 |
19 |
20 |
21 |
22 |
23 |
24 |
25 |
26 |
27 |
28 |
--------------------------------------------------------------------------------
/siexamplewsinboundoutbound/.project:
--------------------------------------------------------------------------------
1 |
2 |
3 | siexamplewsinboundoutbound
4 |
5 |
6 |
7 |
8 |
9 | org.eclipse.wst.jsdt.core.javascriptValidator
10 |
11 |
12 |
13 |
14 | org.eclipse.jdt.core.javabuilder
15 |
16 |
17 |
18 |
19 | org.eclipse.wst.common.project.facet.core.builder
20 |
21 |
22 |
23 |
24 | org.eclipse.m2e.core.maven2Builder
25 |
26 |
27 |
28 |
29 | org.eclipse.wst.validation.validationbuilder
30 |
31 |
32 |
33 |
34 |
35 | org.eclipse.jem.workbench.JavaEMFNature
36 | org.eclipse.wst.common.modulecore.ModuleCoreNature
37 | org.eclipse.jdt.core.javanature
38 | org.eclipse.m2e.core.maven2Nature
39 | org.eclipse.wst.common.project.facet.core.nature
40 | org.eclipse.wst.jsdt.core.jsNature
41 |
42 |
43 |
--------------------------------------------------------------------------------
/siexamplewsinboundoutbound/.settings/.jsdtscope:
--------------------------------------------------------------------------------
1 |
2 |
3 |
4 |
5 |
6 |
7 |
8 |
9 |
10 |
11 |
12 |
13 |
14 |
--------------------------------------------------------------------------------
/siexamplewsinboundoutbound/.settings/com.springsource.sts.config.flow.prefs:
--------------------------------------------------------------------------------
1 | //com.springsource.sts.config.flow.coordinates\:http\://www.springframework.org/schema/integration\:/siexamplewsinbound/src/main/webapp/WEB-INF/spring-ws-config.xml=\r\n\r\n\r\n\r\n\r\n\r\n\r\n\r\n\r\n\r\n\r\n\r\n\r\n\r\n
2 | //com.springsource.sts.config.flow.coordinates\:http\://www.springframework.org/schema/integration\:/siexamplewsinbound/src/main/webapp/WEB-INF/ws-inbound-config.xml=\r\n\r\n\r\n\r\n\r\n\r\n\r\n\r\n\r\n\r\n\r\n\r\n\r\n\r\n
3 | //com.springsource.sts.config.flow.coordinates\:http\://www.springframework.org/schema/integration\:/siexamplewsinboundoutbound/src/main/webapp/WEB-INF/ws-inbound-config.xml=\r\n\r\n\r\n\r\n\r\n\r\n\r\n\r\n\r\n\r\n\r\n\r\n\r\n\r\n
4 | eclipse.preferences.version=1
5 |
--------------------------------------------------------------------------------
/siexamplewsinboundoutbound/.settings/org.eclipse.jdt.core.prefs:
--------------------------------------------------------------------------------
1 | eclipse.preferences.version=1
2 | org.eclipse.jdt.core.compiler.codegen.inlineJsrBytecode=enabled
3 | org.eclipse.jdt.core.compiler.codegen.targetPlatform=1.5
4 | org.eclipse.jdt.core.compiler.compliance=1.5
5 | org.eclipse.jdt.core.compiler.problem.assertIdentifier=error
6 | org.eclipse.jdt.core.compiler.problem.enumIdentifier=error
7 | org.eclipse.jdt.core.compiler.problem.forbiddenReference=warning
8 | org.eclipse.jdt.core.compiler.source=1.5
9 |
--------------------------------------------------------------------------------
/siexamplewsinboundoutbound/.settings/org.eclipse.m2e.core.prefs:
--------------------------------------------------------------------------------
1 | activeProfiles=
2 | eclipse.preferences.version=1
3 | resolveWorkspaceProjects=true
4 | version=1
5 |
--------------------------------------------------------------------------------
/siexamplewsinboundoutbound/.settings/org.eclipse.wst.common.component:
--------------------------------------------------------------------------------
1 |
2 |
3 |
4 |
5 |
6 |
7 |
8 |
9 |
10 |
11 |
12 |
--------------------------------------------------------------------------------
/siexamplewsinboundoutbound/.settings/org.eclipse.wst.common.project.facet.core.xml:
--------------------------------------------------------------------------------
1 |
2 |
3 |
4 |
5 |
6 |
7 |
8 |
--------------------------------------------------------------------------------
/siexamplewsinboundoutbound/.settings/org.eclipse.wst.jsdt.ui.superType.container:
--------------------------------------------------------------------------------
1 | org.eclipse.wst.jsdt.launching.baseBrowserLibrary
--------------------------------------------------------------------------------
/siexamplewsinboundoutbound/.settings/org.eclipse.wst.jsdt.ui.superType.name:
--------------------------------------------------------------------------------
1 | Window
--------------------------------------------------------------------------------
/siexamplewsinboundoutbound/.settings/org.eclipse.wst.validation.prefs:
--------------------------------------------------------------------------------
1 | disabled=06target
2 | eclipse.preferences.version=1
3 |
--------------------------------------------------------------------------------
/siexamplewsinboundoutbound/README.txt:
--------------------------------------------------------------------------------
1 | Build the Maven project to download all dependencies "mvn -X clean package"
2 |
3 | Refer /META-INF/spring/integration/setting.properties for all the values which can be set
4 |
5 | All classes needed to run sample App aer inside package com.cpandey.siexample
6 | -select any of those and then "run as Java" program
7 |
8 | Following are the details classes which map to chapter wise samples
9 |
10 | Chapter 1-5
11 | Gateway, Service Activator, Router, Filter, Splitter -EndpointsMailJmsDb.java
12 | Aggregator, ChainingHandler -Aggregator.java
13 | Resequencer, Enricher -Resequencer.java
14 | Chapter 6
15 | FTP/FTPS FTPIntegration
16 | Twitter, SocialIntegration
17 | JMS, EndpointsMailJmsDb
18 | Mail EndpointsMailJmsDb
19 | Database EndpointsMailJmsDb
20 | HTTP -Separate Project, to be deployed inside tomcat : siexamplehttpinboundoutbound
21 | WebService -Separate Project, to be deployed inside tomcat : siexamplewsinboundoutbound
22 | Chapter 7
23 | Spring Batch BatchJobLauncher.java and SpringIntegrationBatchJobLauncher.java
24 | Chapter 8
25 | Testing Files under src/test/java
26 | Chapter 9 and 10
27 | JMX and an End to End example :Separate project : feedsexample
28 |
--------------------------------------------------------------------------------
/siexamplewsinboundoutbound/pom.xml:
--------------------------------------------------------------------------------
1 |
3 | 4.0.0
4 | siexamplewsinbound
5 | siexamplewsinbound
6 | war
7 | 0.0.1-SNAPSHOT
8 | siexamplewsinbound Maven Webapp
9 | http://maven.apache.org
10 |
11 | 4.0.1.RELEASE
12 | 4.0.3.RELEASE
13 | 1.2.17
14 | 4.11
15 | 1.3.19
16 | 1.1.1
17 |
18 |
19 |
20 | junit
21 | junit
22 | 3.8.1
23 | test
24 |
25 |
26 | org.springframework.integration
27 | spring-integration-xml
28 | ${spring.integration.version}
29 |
30 |
31 | org.springframework.integration
32 | spring-integration-ws
33 | ${spring.integration.version}
34 |
35 |
36 |
37 | org.springframework.integration
38 | spring-integration-stream
39 | ${spring.integration.version}
40 |
41 |
42 | com.sun.xml.messaging.saaj
43 | saaj-impl
44 | ${saaj.version}
45 |
46 |
47 | javax.activation
48 | activation
49 | ${javax-activation.version}
50 |
51 |
52 | org.springframework
53 | spring-test
54 | ${spring.version}
55 |
56 |
57 | log4j
58 | log4j
59 | ${log4j.version}
60 |
61 |
62 |
63 | junit
64 | junit
65 | ${junit.version}
66 |
67 |
68 |
69 | siexamplewsinbound
70 |
71 |
72 |
--------------------------------------------------------------------------------
/siexamplewsinboundoutbound/src/main/java/com/cpandey/siexample/WsDemoApp.java:
--------------------------------------------------------------------------------
1 | package com.cpandey.siexample;
2 |
3 | import org.springframework.context.support.ClassPathXmlApplicationContext;
4 | import org.springframework.integration.support.MessageBuilder;
5 | import org.springframework.integration.support.channel.BeanFactoryChannelResolver;
6 | import org.springframework.messaging.Message;
7 | import org.springframework.messaging.MessageChannel;
8 | import org.springframework.messaging.core.DestinationResolver;
9 |
10 | /**
11 | * @author Chandan Pandey
12 | *
13 | */
14 | public class WsDemoApp {
15 | public static void main(String[] args) {
16 | ClassPathXmlApplicationContext context =
17 | new ClassPathXmlApplicationContext("/META-INF/spring/integration/temperatureConversion.xml");
18 | DestinationResolver channelResolver = new BeanFactoryChannelResolver(context);
19 |
20 | // Compose the XML message according to the server's schema
21 | String requestXml =
22 | "" +
23 | " 90.0" +
24 | "";
25 |
26 | // Create the Message object
27 | Message message = MessageBuilder.withPayload(requestXml).build();
28 |
29 | // Send the Message to the handler's input channel
30 | MessageChannel channel = channelResolver.resolveDestination("fahrenheitChannel");
31 | channel.send(message);
32 | }
33 |
34 | }
35 |
--------------------------------------------------------------------------------
/siexamplewsinboundoutbound/src/main/java/com/cpandey/siexample/WsInboundService.java:
--------------------------------------------------------------------------------
1 | package com.cpandey.siexample;
2 |
3 | import javax.xml.transform.Source;
4 | import javax.xml.transform.dom.DOMSource;
5 |
6 | import org.springframework.integration.xml.source.DomSourceFactory;
7 | /**
8 | * @author Chandan Pandey
9 | *
10 | */
11 | public class WsInboundService {
12 | //refer WEB-INF/ws-inbound-config.xml for configurations
13 | public Source issueResponseFor(DOMSource request) {
14 | return new DomSourceFactory().createSource(
15 | "" +"response:"+
16 | request.getNode().getTextContent() + "");
17 | }
18 | }
19 |
--------------------------------------------------------------------------------
/siexamplewsinboundoutbound/src/main/resources/META-INF/spring/integration/temperatureConversion.xml:
--------------------------------------------------------------------------------
1 |
2 |
15 |
16 |
19 |
20 |
21 |
22 |
23 |
24 |
25 |
26 |
27 |
28 |
29 |
30 |
--------------------------------------------------------------------------------
/siexamplewsinboundoutbound/src/main/webapp/WEB-INF/web.xml:
--------------------------------------------------------------------------------
1 |
2 |
3 | ws:inbound-gateway sample
4 |
5 |
6 | springwsinbound
7 | org.springframework.ws.transport.http.MessageDispatcherServlet
8 |
9 | contextConfigLocation
10 | WEB-INF/ws-inbound-config.xml
11 |
12 | 1
13 |
14 |
15 |
16 | springwsinbound
17 | /testwsservice
18 |
19 |
20 |
21 | index.html
22 |
23 |
24 |
25 |
--------------------------------------------------------------------------------
/siexamplewsinboundoutbound/src/main/webapp/WEB-INF/ws-inbound-config.xml:
--------------------------------------------------------------------------------
1 |
2 |
9 |
10 |
11 |
12 |
13 |
14 |
15 |
16 |
17 |
18 |
19 |
20 |
21 |
22 |
23 |
24 |
25 |
--------------------------------------------------------------------------------
/siexamplewsinboundoutbound/src/main/webapp/index.html:
--------------------------------------------------------------------------------
1 | Successfull --Try out!
--------------------------------------------------------------------------------
/siexamplewsinboundoutbound/src/test/com/cpandey/siexample/WsInBound.java:
--------------------------------------------------------------------------------
1 | package com.cpandey.siexample;
2 | import static org.hamcrest.CoreMatchers.equalTo;
3 | import static org.junit.Assert.assertThat;
4 |
5 | import javax.xml.transform.Source;
6 |
7 | import org.apache.log4j.Logger;
8 | import org.junit.Test;
9 | import org.springframework.ws.client.core.WebServiceTemplate;
10 | import org.springframework.xml.transform.StringResult;
11 | import org.springframework.xml.transform.StringSource;
12 |
13 | public class WsInBound {
14 |
15 | private static Logger logger = Logger.getLogger(WsInBound.class);
16 | private static final String WS_URI = "http://localhost:8080/siexamplewsinbound/testwsservice";
17 | private final WebServiceTemplate template = new WebServiceTemplate();
18 |
19 | @Test
20 | public void testWebServiceRequestAndResponse() {
21 | StringResult result = new StringResult();
22 | Source payload = new StringSource(
23 | "" +
24 | "testwsinbound");
25 |
26 | template.sendSourceAndReceiveToResult(WS_URI, payload, result);
27 | logger.info("RESULT: " + result.toString());
28 | assertThat(result.toString(), equalTo(
29 | "" +
30 | "response:testwsinbound"));
31 | }
32 | }
33 |
--------------------------------------------------------------------------------