Convert Figma logo to code with AI

spring-projects logospring-integration

Spring Integration provides an extension of the Spring programming model to support the well-known Enterprise Integration Patterns (EIP)

1,534
1,098
1,534
128

Top Related Projects

Spring Boot

5,496

Apache Camel is an open source integration framework that empowers you to quickly and easily integrate various systems consuming or producing data.

28,317

Mirror of Apache Kafka

47,834

RxJava – Reactive Extensions for the JVM – a library for composing asynchronous and event-based programs using observable sequences for the Java VM.

13,024

Build highly concurrent, distributed, and resilient message-driven applications on the JVM

13,537

Quarkus: Supersonic Subatomic Java.

Quick Overview

Spring Integration is an extension of the Spring Framework that supports Enterprise Integration Patterns. It enables lightweight messaging within Spring-based applications and supports integration with external systems via declarative adapters. The project aims to provide a simple model for building enterprise integration solutions while maintaining the separation of concerns that is essential for producing maintainable, testable code.

Pros

  • Seamless integration with other Spring projects and the Spring ecosystem
  • Extensive support for various messaging patterns and protocols
  • Declarative configuration using annotations or XML
  • High flexibility and extensibility for custom integration scenarios

Cons

  • Steep learning curve for developers new to Enterprise Integration Patterns
  • Can be overkill for simple integration scenarios
  • Configuration can become complex for large-scale applications
  • Performance overhead compared to direct point-to-point integrations

Code Examples

  1. Simple message flow using Java DSL:
@Bean
public IntegrationFlow myFlow() {
    return IntegrationFlows.from("inputChannel")
        .<String, String>transform(String::toUpperCase)
        .channel("outputChannel")
        .get();
}
  1. HTTP inbound gateway:
@Bean
public IntegrationFlow httpInboundGateway() {
    return IntegrationFlows.from(Http.inboundGateway("/api/data")
            .requestMapping(m -> m.methods(HttpMethod.POST))
            .requestPayloadType(String.class))
        .handle("myService", "processData")
        .get();
}
  1. File adapter with transformer:
@Bean
public IntegrationFlow fileReadingFlow() {
    return IntegrationFlows
        .from(Files.inboundAdapter(new File("/input/directory"))
            .autoCreateDirectory(true)
            .patternFilter("*.txt"))
        .transform(Files.toStringTransformer())
        .channel("processChannel")
        .get();
}

Getting Started

To start using Spring Integration, add the following dependency to your Maven pom.xml:

<dependency>
    <groupId>org.springframework.integration</groupId>
    <artifactId>spring-integration-core</artifactId>
    <version>5.5.15</version>
</dependency>

Enable Spring Integration in your Spring Boot application:

@SpringBootApplication
@EnableIntegration
public class MyApplication {
    public static void main(String[] args) {
        SpringApplication.run(MyApplication.class, args);
    }
}

Create a simple integration flow:

@Configuration
public class IntegrationConfig {
    @Bean
    public IntegrationFlow myFlow() {
        return IntegrationFlows.from("inputChannel")
            .<String, String>transform(String::toUpperCase)
            .channel("outputChannel")
            .get();
    }
}

Competitor Comparisons

Spring Boot

Pros of Spring Boot

  • Simplified configuration with auto-configuration and starter dependencies
  • Faster development and deployment with embedded servers
  • Comprehensive production-ready features like health checks and metrics

Cons of Spring Boot

  • Can be "opinionated," potentially limiting flexibility for complex scenarios
  • Larger application size due to included dependencies
  • Steeper learning curve for understanding auto-configuration mechanisms

Code Comparison

Spring Boot:

@SpringBootApplication
public class Application {
    public static void main(String[] args) {
        SpringApplication.run(Application.class, args);
    }
}

Spring Integration:

@Configuration
@EnableIntegration
public class IntegrationConfig {
    @Bean
    public MessageChannel inputChannel() {
        return new DirectChannel();
    }
}

Spring Boot focuses on rapid application development with minimal configuration, while Spring Integration specializes in enterprise integration patterns and message-driven architectures. Spring Boot's code is more concise due to its auto-configuration features, whereas Spring Integration requires more explicit configuration but offers greater control over messaging components.

Both projects are part of the Spring ecosystem and can be used together, with Spring Boot often serving as the foundation for applications that incorporate Spring Integration for specific integration needs.

5,496

Apache Camel is an open source integration framework that empowers you to quickly and easily integrate various systems consuming or producing data.

Pros of Camel

  • More extensive component library with over 300 components for various integrations
  • Domain-specific language (DSL) for defining routes, making integration logic more readable
  • Supports multiple programming languages and runtimes beyond Java

Cons of Camel

  • Steeper learning curve due to its extensive feature set and DSL
  • Can be overkill for simpler integration scenarios
  • Less tight integration with the Spring ecosystem

Code Comparison

Spring Integration:

@Bean
public IntegrationFlow fileFlow() {
    return IntegrationFlows.from(Files.inboundAdapter(new File("/input")))
        .filter(new AcceptOnceFileListFilter<>())
        .handle(Files.outboundAdapter(new File("/output")))
        .get();
}

Camel:

from("file:input")
    .filter(new FileOnceFilter())
    .to("file:output");

Both frameworks provide ways to define integration flows, but Camel's DSL is more concise and readable for complex scenarios. Spring Integration leverages the Spring ecosystem, making it a natural choice for Spring-based applications. Camel offers more flexibility and a wider range of components, making it suitable for diverse integration needs across different platforms.

28,317

Mirror of Apache Kafka

Pros of Kafka

  • High throughput and scalability for distributed streaming
  • Built-in partitioning and replication for fault tolerance
  • Native support for stream processing with Kafka Streams

Cons of Kafka

  • Steeper learning curve and more complex setup
  • Less integration with Spring ecosystem
  • Requires additional infrastructure (ZooKeeper)

Code Comparison

Spring Integration:

@Bean
public IntegrationFlow flow() {
    return IntegrationFlows.from(Kafka.messageDrivenChannelAdapter(
            consumerFactory(), KafkaMessageDrivenChannelAdapter.ListenerMode.record, "topic"))
        .handle(System.out::println)
        .get();
}

Kafka:

Properties props = new Properties();
props.put("bootstrap.servers", "localhost:9092");
props.put("group.id", "test");
props.put("key.deserializer", StringDeserializer.class.getName());
props.put("value.deserializer", StringDeserializer.class.getName());
KafkaConsumer<String, String> consumer = new KafkaConsumer<>(props);
consumer.subscribe(Arrays.asList("topic"));

Spring Integration focuses on integrating various systems and protocols within the Spring ecosystem, providing a higher-level abstraction for message-driven architectures. Kafka, on the other hand, is a distributed streaming platform that excels in high-throughput, fault-tolerant data pipelines. While Spring Integration offers easier integration with Spring applications, Kafka provides more robust scalability and stream processing capabilities. The choice between the two depends on specific project requirements and existing infrastructure.

47,834

RxJava – Reactive Extensions for the JVM – a library for composing asynchronous and event-based programs using observable sequences for the Java VM.

Pros of RxJava

  • More lightweight and focused on reactive programming
  • Extensive operator set for complex data transformations
  • Better suited for mobile and Android development

Cons of RxJava

  • Steeper learning curve for developers new to reactive programming
  • Less integration with enterprise Java ecosystems
  • Limited support for backpressure handling compared to Spring Integration

Code Comparison

RxJava:

Observable.just("Hello", "World")
    .map(String::toUpperCase)
    .subscribe(System.out::println);

Spring Integration:

@Bean
public IntegrationFlow flow() {
    return IntegrationFlows.from("inputChannel")
        .<String, String>transform(String::toUpperCase)
        .channel("outputChannel")
        .get();
}

RxJava focuses on reactive streams and functional programming, offering a concise API for asynchronous operations. Spring Integration provides a more comprehensive framework for enterprise integration patterns, including message routing, transformation, and channel adapters.

RxJava excels in scenarios requiring complex event processing and is popular in Android development. Spring Integration shines in enterprise environments, offering seamless integration with other Spring projects and supporting various messaging protocols.

Choose RxJava for reactive programming in lightweight applications or mobile development. Opt for Spring Integration when building enterprise-grade integration solutions or working within the Spring ecosystem.

13,024

Build highly concurrent, distributed, and resilient message-driven applications on the JVM

Pros of Akka

  • Built-in support for distributed systems and clustering
  • Actor model provides better scalability and concurrency handling
  • More flexible and lightweight for building reactive systems

Cons of Akka

  • Steeper learning curve, especially for developers new to the actor model
  • Less integration with Spring ecosystem and other Java frameworks
  • Smaller community and ecosystem compared to Spring Integration

Code Comparison

Spring Integration:

@Bean
public IntegrationFlow fileReadingFlow() {
    return IntegrationFlows.from(Files.inboundAdapter(new File("/input")))
            .filter(new SimplePatternFileListFilter("*.txt"))
            .transform(Files.toStringTransformer())
            .handle(System.out::println)
            .get();
}

Akka:

class FileProcessor extends Actor {
  val watcher = context.actorOf(Props[FileWatcher])
  
  def receive = {
    case FileCreated(file) if file.getName.endsWith(".txt") =>
      val content = scala.io.Source.fromFile(file).mkString
      println(content)
  }
}

Both Spring Integration and Akka are powerful frameworks for building distributed systems, but they have different approaches. Spring Integration focuses on enterprise integration patterns and works well within the Spring ecosystem, while Akka emphasizes the actor model and reactive programming principles. The choice between them depends on specific project requirements and team expertise.

13,537

Quarkus: Supersonic Subatomic Java.

Pros of Quarkus

  • Faster startup time and lower memory footprint, optimized for cloud-native and serverless environments
  • Native compilation support for creating lightweight, self-contained executables
  • Reactive programming model with built-in support for event-driven architectures

Cons of Quarkus

  • Smaller ecosystem and community compared to Spring Integration
  • Steeper learning curve for developers familiar with traditional Java frameworks
  • Limited support for legacy systems and some enterprise integration patterns

Code Comparison

Spring Integration:

@Bean
public IntegrationFlow fileFlow() {
    return IntegrationFlows.from(Files.inboundAdapter(new File("/input")))
            .filter(File.class, p -> p.getName().endsWith(".txt"))
            .handle(Files.outboundAdapter(new File("/output")))
            .get();
}

Quarkus:

@ApplicationScoped
public class FileProcessor {
    @Incoming("input")
    @Outgoing("output")
    public String processFile(String content) {
        return content.toUpperCase();
    }
}

The Spring Integration example demonstrates a file processing flow using a declarative approach, while the Quarkus example showcases a reactive messaging pattern with simpler annotations for input and output channels.

Convert Figma logo designs to code with AI

Visual Copilot

Introducing Visual Copilot: A new AI model to turn Figma designs to high quality code using your components.

Try Visual Copilot

README

Spring Integration

Build Status Revved up by Develocity

Extends the Spring programming model to support the well-known Enterprise Integration Patterns. Spring Integration enables lightweight messaging within Spring-based applications and supports integration with external systems via declarative adapters. Those adapters provide a higher-level of abstraction over Spring’s support for remoting, messaging, and scheduling. Spring Integration’s primary goal is to provide a simple model for building enterprise integration solutions while maintaining the separation of concerns that is essential for producing maintainable, testable code.

Using the Spring Framework encourages developers to code using interfaces and use dependency injection (DI) to provide a Plain Old Java Object (POJO) with the dependencies it needs to perform its tasks. Spring Integration takes this concept one step further, where POJOs are wired together using a messaging paradigm and individual components may not be aware of other components in the application. Such an application is built by assembling fine-grained reusable components to form a higher level of functionality. With careful design, these flows can be modularized and also reused at an even higher level.

In addition to wiring together fine-grained components, Spring Integration provides a wide selection of channel adapters and gateways to communicate with external systems. Channel Adapters are used for one-way integration (send or receive); gateways are used for request/reply scenarios (inbound or outbound).

Installation and Getting Started

First, you need dependencies in your POM/Gradle:

<dependency>
    <groupId>org.springframework.integration</groupId>
    <artifactId>spring-integration-core</artifactId>
</dependency>

which is also pulled transitively if you deal with target protocol channel adapters. For example for Apache Kafka support you need just this:

<dependency>
    <groupId>org.springframework.integration</groupId>
    <artifactId>spring-integration-kafka</artifactId>
</dependency>

For annotations or Java DSL configuration you need to enable Spring Integration in the application context:

@EnableIntegration
@Configuration
public class ExampleConfiguration {
    
}

Code of Conduct

Please see our Code of conduct.

Reporting Security Vulnerabilities

Please see our Security policy.

Documentation

The Spring Integration maintains reference documentation (published and source), GitHub wiki pages, and an API reference. There are also guides and tutorials across Spring projects.

Checking out and Building

To check out the project and build from the source, do the following:

git clone git://github.com/spring-projects/spring-integration.git
cd spring-integration
./gradlew clean test

or

./gradlew clean testAll

The latter runs additional tests (those annotated with @LongRunningIntegrationTest); it is a more thorough test but takes quite a lot longer to run.

The test results are captured in build/reports/tests/test (or .../testAll) under each module (in HTML format).

Add --continue to the command to perform a complete build, even if there are failing tests in some modules; otherwise the build will stop after the current module(s) being built are completed.

NOTE: While Spring Integration runs with Java SE 17 or higher, a Java 17 compiler is required to build the project.

To build and install jars into your local Maven cache:

./gradlew build publishToMavenLocal

To build api Javadoc (results will be in build/api):

./gradlew api

To build the reference documentation (results will be in build/site):

./gradlew antora

To build complete distribution including -dist, -docs, and -schema zip files (results will be in build/distributions):

./gradlew dist

Using Eclipse or Spring Tool Suite (with BuildShip Plugin)

If you have the BuildShip plugin installed,

File -> Import -> Gradle -> Existing Gradle Project

Using Eclipse or Spring Tool Suite (when the BuildShip Plugin is not installed)

To generate Eclipse metadata (.classpath and .project files, etc.), do the following:

./gradlew eclipse

Once complete, you may then import the projects into Eclipse as usual:

File -> Import -> General -> Existing projects into workspace

Browse to the 'spring-integration' root directory. All projects should import free of errors.

Using IntelliJ IDEA

To import the project into IntelliJ IDEA:

File -> Open... -> and select build.gradle from spring-integration project root directory

Guidelines

See also Contributor Guidelines.

Resources

For more information, please visit the Spring Integration website at: https://spring.io/projects/spring-integration