Spring Integration 系统集成

Spring Integration 提供了基于EIP的企业集成解决方案,重点解决系统间的异步消息交互问题。核心组件包括Message(消息)、Channel(通道)和Message EndPoint(消息端点)。Message由消息体和头构成,Channel分为可轮询和可订阅类型,常见的有PublishSubscribeChannel、QueueChannel等。Message EndPoint如Service Activator用于调用Spring Bean处理消息,Router和Filter则负责消息的路由和过滤。此外,还包括用于系统集成的各种适配器、网关和转换器。
摘要由CSDN通过智能技术生成

Spring Ingegration 提供了基于Spring的EIP(Enterprise Integration Patterns,企业集成模式)的实现。Spring Integration 主要解决的问题是不同系统之间交互的问题,通过异步消息驱动来达到系统交互时系统之间的松耦合。

Spring Integration 主要有Message、Channel、Message EndPoint组成。

Message

Message是用来在不同部分之间传递的数据。Message有两部分组成:消息体(payload)与消息头(header)。消息体可以是任何数据类型;消息头表示的元数据就是解释消息体的内容。

/**
 * A generic message representation with headers and body.
 *
 * @author Mark Fisher
 * @author Arjen Poutsma
 * @since 4.0
 * @see org.springframework.messaging.support.MessageBuilder
 */
public interface Message<T> {

    /**
     * Return the message payload.
     */
    T getPayload();

    /**
     * Return message headers for the message (never {
   @code null} but may be empty).
     */
    MessageHeaders getHeaders();

}

Channel

在消息系统中,消息发送者发送消息到通道(Channel),消息接受者从通道(Channel)接收消息。

1、顶级接口

(1) MessageChannel

MessageChannel 是Spring Integration消息通道的顶级接口:

public interface MessageChannel {

    /**
     * Constant for sending a message without a prescribed timeout.
     */
    long INDEFINITE_TIMEOUT = -1;


    /**
     * Send a {@link Message} to this channel. If the message is sent successfully,
     * the method returns {@code true}. If the message cannot be sent due to a
     * non-fatal reason, the method returns {@code false}. The method may also
     * throw a RuntimeException in case of non-recoverable errors.
     * <p>This method may block indefinitely, depending on the implementation.
     * To provide a maximum wait time, use {@link #send(Message, long)}.
     *
  • 2
    点赞
  • 15
    收藏
    觉得还不错? 一键收藏
  • 1
    评论
评论 1
添加红包

请填写红包祝福语或标题

红包个数最小为10个

红包金额最低5元

当前余额3.43前往充值 >
需支付:10.00
成就一亿技术人!
领取后你会自动成为博主和红包主的粉丝 规则
hope_wisdom
发出的红包
实付
使用余额支付
点击重新获取
扫码支付
钱包余额 0

抵扣说明:

1.余额是钱包充值的虚拟货币,按照1:1的比例进行支付金额的抵扣。
2.余额无法直接购买下载,可以购买VIP、付费专栏及课程。

余额充值