You signed in with another tab or window. Reload to refresh your session.You signed out in another tab or window. Reload to refresh your session.You switched accounts on another tab or window. Reload to refresh your session.Dismiss alert
Copy file name to clipboardExpand all lines: README.adoc
+30-3Lines changed: 30 additions & 3 deletions
Display the source diff
Display the rich diff
Original file line number
Diff line number
Diff line change
@@ -18,7 +18,7 @@ This guide walks you through the process of using Spring Integration to create a
18
18
19
19
== What you'll build
20
20
21
-
You'll create a flow using Spring Integration.
21
+
You'll create a flow with Spring Integration using traditional XML configuration.
22
22
23
23
== What you'll need
24
24
@@ -59,9 +59,15 @@ This simple flow is illustrated like this:
59
59
60
60
image::images/blogToFile.png[A flow that reads RSS feed entries, transforms them to a String, and appends them to a file.]
61
61
62
+
Ignore the `auto-startup` attribute for now; we'll revisit that later when discussing testing; just notice that it will be `true` by default which means the posts will be fetched when the application starts.
63
+
Also note the property placeholder in the `filename-generator-expression`; this means the default will be `SpringBlog` but can be overridden with a property
64
+
62
65
== Make the application executable
63
66
64
-
Although it is common to configure a Spring Integration flow within a larger application, perhaps even a web application, there's no reason that it can't be defined in a simpler standalone application. That's what you do next, creating a main class that kicks off the integration flow and also declares a handful of beans to support the integration flow. You also build the application into a standalone executable JAR file. We use Spring Boot's `SpringApplication` to create the application context.
67
+
Although it is common to configure a Spring Integration flow within a larger application, perhaps even a web application, there's no reason that it can't be defined in a simpler standalone application.
68
+
That's what you do next, creating a main class that kicks off the integration flow and also declares a handful of beans to support the integration flow. You also build the application into a standalone executable JAR file.
69
+
We use Spring Boot's `SpringApplication` to create the application context.
70
+
Since this guide uses an the XML namespace for the integration flow, notice that we use `@ImportResource` to load it into the application context.
65
71
66
72
67
73
`src/main/java/hello/Application.java`
@@ -100,8 +106,29 @@ Spring Integration Java DSL: Line by line tutorial @ https://spring.io/blog/2014
100
106
Spring for Apache Hadoop 2.1.0.M2 Released @ https://spring.io/blog/2014/11/14/spring-for-apache-hadoop-2-1-0-m2-released
101
107
....
102
108
109
+
== Testing
110
+
111
+
Examine the `complete` project and you will see a test case.
This uses Spring Boot's test support to set a property `auto.startup` to `false`.
120
+
It is generally not a good idea to rely on a network connection for tests, especially in a CI environment.
121
+
So, instead, we prevent the feed adapter from starting and inject a `SyndEntry` into the `news` channel for processing by the rest of the flow.
122
+
The test also sets the `feed.file.name` so the test writes to a different file; then:
123
+
124
+
- verifies the adapter is stopped
125
+
- creates a test `SyndEntry`
126
+
- deletes the test output file (if it's present)
127
+
- sends the message
128
+
- verifies the file exists
129
+
- reads the file and verifies that the data is as expected
130
+
103
131
== Summary
104
132
Congratulations! You have developed a simple application that uses Spring Integration to fetch blog posts from spring.io, process them, and write them to a file.
0 commit comments