网站首页 > 博客文章 正文
Message Endpoints概念介绍
Spring Integration是基于管道-过滤器架构的,Message Endpoint是过滤器中的一部分。在简介中提到过,endpoint主要是用来关联框架与应用业务代码的,就像MVC模型中controller只需要与url绑定即可获取到请求数据进行业务处理一样,endpoint只需要与message channel进行映射即可。
这里将与同学们共同学习Spring Integration提供的一些Endpoint类型。
Message Transformer
消息转换器用于转换消息内容及消息结构体,可以对消息内容进行修改。如:报文格式转化(JSON-XML互转),报文格式化,数据脱敏,报文头修改等。
Message Filter
消息过滤器用于处理消息是否需要传递,可以用来进行权限及认证控制、限流控制等。
Message Router
消息路由器用于决定消息下一步发送到哪个通道,一般根据报文内容或消息元数据来确定。
Splitter
分流器可以将一个消息分成多个消息,并且可以将这些消息分发给不同的输出通道。
Aggregator
聚合器与分流器相反,用于将多个消息聚合为一个消息,但是聚合器要比分流器复杂得多,因为为了聚合不同的消息需要维护待聚合消息的状态,以此决定一组消息是否完成了聚合或者是否已经超时。Spring Integration提供了CorrelationStrategy和ReleaseStrategy两种策略、超时配置以及一个丢弃通道,用于决定当聚合超时候是否发送部分消息。
Service Activator
Service Activator用于调用service对象的方法,在调用过程中activator提取请求消息的payload作为参数去调用service的方法,当service方法有返回值时将会被封装成Message对象并发送到输出通道。因此在配置Service Activator时需要配置消息输入通道及消息输出通道(如果有返回值),如果没有配置输出通道,也可以通过消息头中的"Return Address"来指定输出通道。
Channel Adapter
Channel Adapter用来提供不同协议消息的适配。
Endpoint Bean Names
Endpoint有多种配置方式:
Service Activator:
<int:service-activator id = "someService" ... />
@Component
public class SomeComponent {
@ServiceActivator(inputChannel = ...)
public String someMethod(...) {
...
}
}
@Component
public class SomeComponent {
@EndpointId("someService")
@ServiceActivator(inputChannel = ...)
public String someMethod(...) {
...
}
}
@Configuration
public class SomeConfiguration {
@Bean
@ServiceActivator(inputChannel = ...)
public MessageHandler someHandler() {
...
}
}
@Configuration
public class SomeConfiguration {
@Bean("someService.handler") ①
@EndpointId("someService") ②
@ServiceActivator(inputChannel = ...)
public MessageHandler someHandler() {
...
}
}
Channel Adapter:
<int:inbound-channel-adapter id = "someAdapter" ... />
@EndpointId("someAdapter")
@InboundChannelAdapter(channel = "channel", poller = @Poller(fixedDelay = "5000" ))
public String pojoSource() {
...
}
@Bean("someAdapter.source")
@EndpointId("someAdapter")
@InboundChannelAdapter(channel = "channel", poller = @Poller(fixedDelay = "5000" ))
public MessageSource<?> source() {
return () -> {
...
};
}
猜你喜欢
- 2024-11-04 SpringBoot系列教程22-整合SpringMVC之HttpMessageConverters
- 2024-11-04 前端部分面试总结(前端面试知识点总结)
- 2024-11-04 学习笔记-身份认证攻击漏洞,文件上传漏洞
- 2024-11-04 java和js实现 RSA+AES接口验签和参数加密 非对称加密非对称加密
- 2024-11-04 工业以太网基础知识介绍—网络体系及标准
- 2024-11-04 「网工必备」网络协议模型和各层作用,带你10分钟get新技能
- 2024-11-04 HTTP协议(http协议的作用)
- 2024-11-04 计算机网络|计算机网络体系结构(计算机网络体系结构知识点)
- 2024-11-04 用于EDI的应用大大提高了效率,减少了纸张的使用
- 2024-11-04 Java安全编码军规(java安全编码规范考试题答案)
你 发表评论:
欢迎- 最近发表
- 标签列表
-
- powershellfor (55)
- messagesource (56)
- aspose.pdf破解版 (56)
- promise.race (63)
- 2019cad序列号和密钥激活码 (62)
- window.performance (66)
- qt删除文件夹 (72)
- mysqlcaching_sha2_password (64)
- ubuntu升级gcc (58)
- nacos启动失败 (64)
- ssh-add (70)
- jwt漏洞 (58)
- macos14下载 (58)
- yarnnode (62)
- abstractqueuedsynchronizer (64)
- source~/.bashrc没有那个文件或目录 (65)
- springboot整合activiti工作流 (70)
- jmeter插件下载 (61)
- 抓包分析 (60)
- idea创建mavenweb项目 (65)
- vue回到顶部 (57)
- qcombobox样式表 (68)
- vue数组concat (56)
- tomcatundertow (58)
- pastemac (61)
本文暂时没有评论,来添加一个吧(●'◡'●)