Spring Integration

Spring Boot 为使用 {url-spring-integration-site}[Spring Integration] 提供了许多便捷功能,包括 spring-boot-starter-integration “Starter”。Spring Integration 提供对消息传递以及其他传输(如 HTTP、TCP 等)的抽象。如果您的类路径上有 Spring Integration,它将通过 @EnableIntegration 注释进行初始化。

Spring Boot offers several conveniences for working with {url-spring-integration-site}[Spring Integration], including the spring-boot-starter-integration “Starter”. Spring Integration provides abstractions over messaging and also other transports such as HTTP, TCP, and others. If Spring Integration is available on your classpath, it is initialized through the @EnableIntegration annotation.

Spring Integration 轮询逻辑依赖 on the auto-configured TaskScheduler。可以使用 spring.integration.poller.* 配置属性定制默认 PollerMetadata(每秒轮询无限数量的消息)。

Spring Integration polling logic relies on the auto-configured TaskScheduler. The default PollerMetadata (poll unbounded number of messages every second) can be customized with spring.integration.poller.* configuration properties.

Spring Boot 还会配置一些由其他 Spring Integration 模块的存在触发的功能。如果类路径上还有 spring-integration-jmx,那么消息处理统计信息将通过 JMX 发布。如果 spring-integration-jdbc 可用,则可以在启动时创建默认数据库模式,如下所示:

Spring Boot also configures some features that are triggered by the presence of additional Spring Integration modules. If spring-integration-jmx is also on the classpath, message processing statistics are published over JMX. If spring-integration-jdbc is available, the default database schema can be created on startup, as shown in the following line:

spring:
  integration:
    jdbc:
      initialize-schema: "always"

如果 spring-integration-rsocket 可用,开发人员可使用 "spring.rsocket.server.*" 属性配置 RSocket 服务器,并将其用于处理传入 RSocket 消息的 IntegrationRSocketEndpointRSocketOutboundGateway 组件。此基础结构可处理 Spring Integration RSocket 通道适配器和 @MessageMapping 处理程序(已配置 "spring.integration.rsocket.server.message-mapping-enabled")。

If spring-integration-rsocket is available, developers can configure an RSocket server using "spring.rsocket.server.*" properties and let it use IntegrationRSocketEndpoint or RSocketOutboundGateway components to handle incoming RSocket messages. This infrastructure can handle Spring Integration RSocket channel adapters and @MessageMapping handlers (given "spring.integration.rsocket.server.message-mapping-enabled" is configured).

Spring Boot 还可以使用配置属性自动配置 ClientRSocketConnector

Spring Boot can also auto-configure an ClientRSocketConnector using configuration properties:

# Connecting to a RSocket server over TCP
spring:
  integration:
    rsocket:
      client:
        host: "example.org"
        port: 9898
# Connecting to a RSocket Server over WebSocket
spring:
  integration:
    rsocket:
      client:
        uri: "ws://example.org"

有关详细信息,请参见 {code-spring-boot-autoconfigure-src}/integration/IntegrationAutoConfiguration.java[IntegrationAutoConfiguration] 和 {code-spring-boot-autoconfigure-src}/integration/IntegrationProperties.java[IntegrationProperties] 类。

See the {code-spring-boot-autoconfigure-src}/integration/IntegrationAutoConfiguration.java[IntegrationAutoConfiguration] and {code-spring-boot-autoconfigure-src}/integration/IntegrationProperties.java[IntegrationProperties] classes for more details.