{"id":35226447,"url":"https://github.com/spring-guides/gs-integration","last_synced_at":"2026-03-17T20:02:36.019Z","repository":{"id":9154582,"uuid":"10948842","full_name":"spring-guides/gs-integration","owner":"spring-guides","description":"Integrating Data :: Learn how to build an application that uses Spring Integration to fetch data, process it, and write it to a file.","archived":false,"fork":false,"pushed_at":"2026-02-19T00:00:35.000Z","size":956,"stargazers_count":14,"open_issues_count":0,"forks_count":46,"subscribers_count":20,"default_branch":"main","last_synced_at":"2026-02-19T06:17:35.059Z","etag":null,"topics":["spring-integration"],"latest_commit_sha":null,"homepage":"http://spring.io/guides/gs/integration/","language":"Java","has_issues":true,"has_wiki":null,"has_pages":null,"mirror_url":null,"source_name":null,"license":"apache-2.0","status":null,"scm":"git","pull_requests_enabled":true,"icon_url":"https://github.com/spring-guides.png","metadata":{"files":{"readme":"README.adoc","changelog":null,"contributing":"CONTRIBUTING.adoc","funding":null,"license":"LICENSE.txt","code_of_conduct":null,"threat_model":null,"audit":null,"citation":null,"codeowners":null,"security":null,"support":null,"governance":null,"roadmap":null,"authors":null,"dei":null,"publiccode":null,"codemeta":null,"zenodo":null,"notice":null,"maintainers":null,"copyright":null,"agents":null,"dco":null,"cla":null}},"created_at":"2013-06-25T20:09:44.000Z","updated_at":"2026-02-19T00:00:39.000Z","dependencies_parsed_at":"2026-02-19T02:04:14.071Z","dependency_job_id":null,"html_url":"https://github.com/spring-guides/gs-integration","commit_stats":null,"previous_names":[],"tags_count":19,"template":false,"template_full_name":null,"purl":"pkg:github/spring-guides/gs-integration","repository_url":"https://repos.ecosyste.ms/api/v1/hosts/GitHub/repositories/spring-guides%2Fgs-integration","tags_url":"https://repos.ecosyste.ms/api/v1/hosts/GitHub/repositories/spring-guides%2Fgs-integration/tags","releases_url":"https://repos.ecosyste.ms/api/v1/hosts/GitHub/repositories/spring-guides%2Fgs-integration/releases","manifests_url":"https://repos.ecosyste.ms/api/v1/hosts/GitHub/repositories/spring-guides%2Fgs-integration/manifests","owner_url":"https://repos.ecosyste.ms/api/v1/hosts/GitHub/owners/spring-guides","download_url":"https://codeload.github.com/spring-guides/gs-integration/tar.gz/refs/heads/main","sbom_url":"https://repos.ecosyste.ms/api/v1/hosts/GitHub/repositories/spring-guides%2Fgs-integration/sbom","scorecard":null,"host":{"name":"GitHub","url":"https://github.com","kind":"github","repositories_count":286080680,"owners_count":30630027,"icon_url":"https://github.com/github.png","version":null,"created_at":"2022-05-30T11:31:42.601Z","updated_at":"2026-03-17T17:32:55.572Z","status":"ssl_error","status_checked_at":"2026-03-17T17:32:38.732Z","response_time":56,"last_error":"SSL_read: unexpected eof while reading","robots_txt_status":"success","robots_txt_updated_at":"2025-07-24T06:49:26.215Z","robots_txt_url":"https://github.com/robots.txt","online":false,"can_crawl_api":true,"host_url":"https://repos.ecosyste.ms/api/v1/hosts/GitHub","repositories_url":"https://repos.ecosyste.ms/api/v1/hosts/GitHub/repositories","repository_names_url":"https://repos.ecosyste.ms/api/v1/hosts/GitHub/repository_names","owners_url":"https://repos.ecosyste.ms/api/v1/hosts/GitHub/owners"}},"keywords":["spring-integration"],"created_at":"2025-12-30T01:14:50.219Z","updated_at":"2026-03-17T20:02:36.014Z","avatar_url":"https://github.com/spring-guides.png","language":"Java","funding_links":[],"categories":[],"sub_categories":[],"readme":":images: https://raw.githubusercontent.com/spring-guides/gs-integration/main/images\n:toc:\n:icons: font\n:source-highlighter: prettify\n:project_id: gs-integration\n\nThis guide walks you through the process of using Spring Integration to create a simple\napplication that retrieves data from an RSS Feed (Spring Blog), manipulates the data, and\nthen writes it to a file. This guide uses traditional Spring Integration XML\nconfiguration. Other guides show how to use Java Configuration and DSL with and without\nLambda expressions.\n\n== What You Will Build\n\nYou will create a flow with Spring Integration by using traditional XML configuration.\n\n== What You Need\n\ninclude::https://raw.githubusercontent.com/spring-guides/getting-started-macros/main/prereq_editor_jdk_buildtools.adoc[]\n\ninclude::https://raw.githubusercontent.com/spring-guides/getting-started-macros/main/how_to_complete_this_guide.adoc[]\n\n[[scratch]]\n== Starting with Spring Initializr\n\nYou can use this https://start.spring.io/#!type=maven-project\u0026groupId=com.example\u0026artifactId=integration\u0026name=integration\u0026description=Demo%20project%20for%20Spring%20Boot\u0026packageName=com.example.integration\u0026dependencies=integration[pre-initialized project] and click Generate to download a ZIP file. This project is configured to fit the examples in this tutorial.\n\nTo manually initialize the project:\n\n. Navigate to https://start.spring.io.\nThis service pulls in all the dependencies you need for an application and does most of the setup for you.\n. Choose either Gradle or Maven and the language you want to use. This guide assumes that you chose Java.\n. Click *Dependencies* and select *Spring Integration*.\n. Click *Generate*.\n. Download the resulting ZIP file, which is an archive of a web application that is configured with your choices.\n\nNOTE: If your IDE has the Spring Initializr integration, you can complete this process from your IDE.\n\nNOTE: You can also fork the project from Github and open it in your IDE or other editor.\n\n== Add to the Build Files\n\nFor this example, you need to add two dependencies:\n\n* `spring-integration-feed`\n* `spring-integration-file`\n\nThe following listing shows the final `pom.xml` file:\n\n====\n[src,xml]\n----\ninclude::complete/pom.xml[]\n----\n====\n\nThe following listing shows the final `build.gradle` file:\n\n====\n[src,java]\n----\ninclude::complete/build.gradle[]\n----\n====\n\n[[initial]]\n== Define an Integration Flow\n\nFor this guide's sample application, you will define a Spring Integration flow that:\n\n* Reads blog posts from the RSS feed at spring.io.\n* Transforms them into an easily readable `String` consisting of the post title and the URL for the post.\n* Appends that `String` to the end of a file (`/tmp/si/SpringBlog`).\n\nTo define an integration flow, you can create a Spring XML configuration with a handful of\nelements from Spring Integration's XML namespaces. Specifically, for the desired\nintegration flow, you work with elements from these Spring Integration namespaces: core,\nfeed, and file. (Getting the last two is why we had to modify the build files provided by\nthe Spring Initializr.)\n\nThe following XML configuration file (from\n`src/main/resources/integration/integration.xml`) defines the integration flow:\n\n====\n[source,xml]\n----\ninclude::complete/src/main/resources/integration/integration.xml[]\n----\n====\n\nThree integration elements are in play here:\n\n* `\u003cfeed:inbound-channel-adapter\u003e`: An inbound adapter that retrieves the posts, one per\npoll. As configured here, it polls every five seconds. The posts are placed into a channel\nnamed `news` (corresponding to the adapter's ID).\n* `\u003cint:transformer\u003e`: Transforms entries (`com.rometools.rome.feed.synd.SyndEntry`) in\nthe `news` channel, extracting the entry's title (`payload.title`) and link\n(`payload.link`) and concatenating them into a readable `String` (and adding a newline).\nThe `String` is then sent to the output channel named `file`.\n* `\u003cfile:outbound-channel-adapter\u003e`: An outbound channel adapter that writes content from\nits channel (named `file`) to a file. Specifically, as configured here, it appends\nanything in the `file` channel to a file at `/tmp/si/SpringBlog`.\n\nThe following image shows this simple flow:\n\nimage::{images}/blogToFile.png[A flow that reads RSS feed entries, transforms them to a String, and appends them to a file.]\n\nIgnore the `auto-startup` attribute for now. We revisit that later when we discuss\ntesting. For now, notice that it is, by default, `true`, which means the posts are fetched\nwhen the application starts. Also note the property placeholder in the\n`filename-generator-expression`. It means that the default is `SpringBlog` but can be\noverridden with a property.\n\n== Make the Application Executable\n\nAlthough it is common to configure a Spring Integration flow within a larger application\n(perhaps even a web application), there is no reason that it cannot be defined in a\nsimpler standalone application. That is what you will do next: Create a main class that\nkicks off the integration flow and that declares a handful of beans to support the\nintegration flow. You will also build the application into a standalone executable JAR\nfile. We use Spring Boot's `@SpringBootApplication` annotation to create the application\ncontext. Since this guide uses the XML namespace for the integration flow, you must use\nthe `@ImportResource` annotation to load it into the application context. The following\nlisting (from `src/main/java/com/example/integration/IntegrationApplication.java`) shows\nthe application file:\n\n====\n[source,java,tabsize=2]\n----\ninclude::complete/src/main/java/com/example/integration/IntegrationApplication.java[]\n----\n====\n\ninclude::https://raw.githubusercontent.com/spring-guides/getting-started-macros/main/build_an_executable_jar_subhead.adoc[]\ninclude::https://raw.githubusercontent.com/spring-guides/getting-started-macros/main/build_an_executable_jar_with_both.adoc[]\n\n[[run]]\n== Run the application\n\nNow you can run the application from the jar by running the following command:\n\n====\n[source,bash]\n----\njava -jar build/libs/{project_id}-0.0.1-SNAPSHOT.jar\n\n... app starts up ...\n----\n====\n\nOnce the application starts, it connects to the RSS feed and starts fetching blog posts.\nThe application processes those posts through the integration flow you defined, ultimately\nappending the post information to a file at `/tmp/si/SpringBlog`.\n\nAfter the application has been running for awhile, you should be able to view the file at\n`/tmp/si/SpringBlog` to see the data from a handful of posts. On a UNIX-based operating\nsystem, you can also `tail` the file to see the results, as they are written, by running\nthe following command:\n\n====\n[source,bash]\n----\ntail -f /tmp/si/SpringBlog\n----\n====\n\nYou should see something like the following sample output (though the actual news will\ndiffer):\n\n====\n[source,bash]\n----\nSpring Integration Java DSL 1.0 GA Released @ https://spring.io/blog/2014/11/24/spring-integration-java-dsl-1-0-ga-released\nThis Week in Spring - November 25th, 2014 @ https://spring.io/blog/2014/11/25/this-week-in-spring-november-25th-2014\nSpring Integration Java DSL: Line by line tutorial @ https://spring.io/blog/2014/11/25/spring-integration-java-dsl-line-by-line-tutorial\nSpring for Apache Hadoop 2.1.0.M2 Released @ https://spring.io/blog/2014/11/14/spring-for-apache-hadoop-2-1-0-m2-released\n----\n====\n\n== Testing\n\nExamine the `complete` project and you will see a test case, in\n`src/test/java/com/example/integration/FlowTests.java`:\n\n====\n[source,java,tabsize=2]\n----\ninclude::complete/src/test/java/com/example/integration/FlowTests.java[]\n----\n====\n\nThis test uses Spring Boot's test support to set a property named `auto.startup` to\n`false`. It is generally not a good idea to rely on a network connection for tests,\nespecially in a CI environment. Instead, we prevent the feed adapter from starting and\ninject a `SyndEntry` into the `news` channel for processing by the rest of the flow. The\ntest also sets the `feed.file.name` so that the test writes to a different file. Then it:\n\n- Verifies that the adapter is stopped.\n- Creates a test `SyndEntry`.\n- Deletes the test output file (if it is present).\n- Sends the message.\n- Verifies that the file exists.\n- Reads the file and verifies that the data is as expected.\n\n== Summary\n\nCongratulations! You have developed a simple application that uses Spring Integration to\nfetch blog posts from spring.io, process them, and write them to a file.\n\n== See Also\n\nThe following guide may also be helpful:\n\n* https://spring.io/guides/gs/spring-boot/[Building an Application with Spring Boot]\n\ninclude::https://raw.githubusercontent.com/spring-guides/getting-started-macros/main/footer.adoc[]\n","project_url":"https://awesome.ecosyste.ms/api/v1/projects/github.com%2Fspring-guides%2Fgs-integration","html_url":"https://awesome.ecosyste.ms/projects/github.com%2Fspring-guides%2Fgs-integration","lists_url":"https://awesome.ecosyste.ms/api/v1/projects/github.com%2Fspring-guides%2Fgs-integration/lists"}