Spring Integration基本用法

本文介绍如何使用Spring Integration实现数据处理。通过配置application.xml,创建SplitService、Param、RouterService和DoConsumerService,根据dataType字段将数据路由到不同通道(oldChannel和newChannel),其中dataType为0的数据流向oldChannel,为1的数据流向newChannel,并在消费时打印信息。

摘要生成于 C知道 ,由 DeepSeek-R1 满血版支持, 前往体验 >

关于Spring-Integration的介绍这里不需要赘述,现在我们需要实现的是发送一个param,里面有两个参数dataType和data,dataType是0和1除外的舍弃,剩余dataType=0的数据往oldChannel通道发,剩余dataType=1的数据往newChannel通道发,消费数据并且打印

1,配置文件 : application.xml

<beans:beans 

    xmlns="http://www.springframework.org/schema/integration"
    xmlns:xsi="http://www.w3.org/2001/XMLSchema-instance"
    xmlns:beans="http://www.springframework.org/schema/beans"
         
    xsi:schemaLocation="http://www.springframework.org/schema/beans  
            http://www.springframework.org/schema/beans/spring-beans.xsd  
            http://www.springframework.org/schema/integration  
            http://www.springframework.org/schema/integration/spring-integration.xsd">

<!-- 要输入的信息往这个通道里塞即可 -->
<channel id="inputChannel" />


<!--  这个过滤器可以过滤一些非法信息,重组消息体等  -->
<splitter input-channel="inputChannel" ref="splitService" output-channel="afterSplitChannel" />


<!-- 路由转发,重新转发到另外的通道去 getDist
评论 1
添加红包

请填写红包祝福语或标题

红包个数最小为10个

红包金额最低5元

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

抵扣说明:

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

余额充值