当前位置: 首页 > news >正文

学院网站建设管理规章制度安卓开发工具idea手机版

学院网站建设管理规章制度,安卓开发工具idea手机版,门户网站开发模板,软件商店哪个好1. 简介 Spring Integration 是一个开源的项目#xff0c;它是 Spring 生态系统的一部分#xff0c;旨在简化企业集成#xff08;Enterprise Integration#xff09;的开发。它提供了一种构建消息驱动的、松散耦合的、可扩展的企业应用集成解决方案的方式。Spring Integra…1. 简介 Spring Integration 是一个开源的项目它是 Spring 生态系统的一部分旨在简化企业集成Enterprise Integration的开发。它提供了一种构建消息驱动的、松散耦合的、可扩展的企业应用集成解决方案的方式。Spring Integration 基于 Spring Framework 构建使开发者能够更容易地将不同的系统、应用程序和服务整合到一个协调的整体中。 Spring Integration 主要有以下作用 消息驱动的集成Spring Integration 基于消息传递的模式允许系统和应用程序通过消息进行通信。这种模式可以用于异步集成以确保系统能够松散耦合以及在高负载和大规模情况下具有良好的性能。模块化和可扩展Spring Integration 提供了一组模块每个模块都用于处理特定类型的集成需求。这些模块可以按需组合和扩展使开发者能够根据应用程序的需要选择合适的模块并自定义它们。集成各种传输协议和数据格式Spring Integration 支持各种传输协议例如HTTP、JMS、FTP、SMTP等和数据格式例如JSON、XML、CSV等以便实现不同系统之间的数据传输和转换。企业模式的集成Spring Integration 提供了一些企业集成模式的实现例如消息路由、消息转换、消息过滤、消息聚合等以帮助解决不同场景下的集成挑战。与 Spring 生态系统的集成Spring Integration 与 Spring Framework 和 Spring Boot 紧密集成开发者可以轻松整合已有的 Spring 应用程序同时利用 Spring 的依赖注入和 AOP面向切面编程等功能。 2. 代码实战 本文主要介绍 Spring Integration 接收TCP与UDP请求的示例。在项目中我们偶尔需要接收其他服务的TCP与UDP请求此时使用Netty可能会过度设计想要一个轻量级nio的TCP、UDP服务端的话我们可以选择 Spring Integration。 环境 JDK21SpringBoot 3.1.4Spring Integration 6.1.3 2.1 导入依赖 !-- 父工程主要用作版本管控 --parentgroupIdorg.springframework.boot/groupIdartifactIdspring-boot-starter-parent/artifactIdversion3.1.4/versionrelativePath //parent!-- springboot-web --dependencygroupIdorg.springframework.boot/groupIdartifactIdspring-boot-starter-web/artifactId/dependency!-- spring-integration --dependencygroupIdorg.springframework.integration/groupIdartifactIdspring-integration-ip/artifactId/dependency 注意如果你的SpringBoot版本是2.x版本那么你需要使用JDK21以下的版本因为JDK中的包名有所更改。 2.2 建立TCP服务端 新建配置类TcpServerConfig其中tcp.server.port需要到application.yml或者application.properties中进行配置。或者你也可以直接填写端口。 import lombok.extern.slf4j.Slf4j;import org.springframework.beans.factory.annotation.Autowired;import org.springframework.beans.factory.annotation.Value;import org.springframework.context.annotation.Bean;import org.springframework.context.annotation.Configuration;import org.springframework.integration.annotation.ServiceActivator;import org.springframework.integration.channel.DirectChannel;import org.springframework.integration.ip.tcp.TcpReceivingChannelAdapter;import org.springframework.integration.ip.tcp.connection.AbstractServerConnectionFactory;import org.springframework.integration.ip.tcp.connection.TcpNioServerConnectionFactory;Slf4jConfigurationpublic class TcpServerConfig {Value(${tcp.server.port})private int PORT;/*** 创建连接工厂* return*/Beanpublic AbstractServerConnectionFactory serverConnectionFactory() {TcpNioServerConnectionFactory tcpNioServerConnectionFactory new TcpNioServerConnectionFactory(PORT);tcpNioServerConnectionFactory.setUsingDirectBuffers(true);return tcpNioServerConnectionFactory;}/*** 创建消息通道* return*/Beanpublic DirectChannel tcpReceiveChannel() {return new DirectChannel();}/*** 创建tcp接收通道适配器* return*/Beanpublic TcpReceivingChannelAdapter inboundAdapter() {TcpReceivingChannelAdapter adapter new TcpReceivingChannelAdapter();adapter.setConnectionFactory(serverConnectionFactory());adapter.setOutputChannelName(tcpReceiveChannel);return adapter;}/*** 处理请求器* param message*/ServiceActivator(inputChannel tcpReceiveChannel)public void messageReceiver(byte[] message) {// 处理接收到的TCP消息log.info(处理TCP请求);}} 注意在发送tcp报文的时候tcp报文需要以\r\n结尾否则无法正常接收报文。 2.3 建立UDP服务端 新建配置类UdpServerConfig其中udp.server.port需要到application.yml或者application.properties中进行配置。或者你也可以直接填写端口。 import lombok.extern.slf4j.Slf4j;import org.springframework.beans.factory.annotation.Autowired;import org.springframework.beans.factory.annotation.Value;import org.springframework.context.annotation.Bean;import org.springframework.context.annotation.Configuration;import org.springframework.integration.annotation.ServiceActivator;import org.springframework.integration.channel.DirectChannel;import org.springframework.integration.dsl.IntegrationFlow;import org.springframework.integration.ip.dsl.Udp;import org.springframework.messaging.Message;Slf4jConfigurationpublic class UdpServerConfig {Value(${udp.server.port})private int PORT;/*** 创建UDP服务器接收通道适配器* return*/Beanpublic IntegrationFlow udpIn() {return IntegrationFlow.from(Udp.inboundAdapter(PORT)).channel(udpReceiveChannel).get();}/*** 创建消息接收通道* return*/Beanpublic DirectChannel udpReceiveChannel() {return new DirectChannel();}/*** 处理接收到的UDP消息* param message*/ServiceActivator(inputChannel udpReceiveChannel)public void udpHandleMessage(Messagebyte[] message) {// 处理接收到的UDP消息byte[] payload message.getPayload();log.info(处理UDP请求);}} 3. 总结 对比NettySpring Integration比较轻量级也更容易集成到 SpringBoot 中但是性能肯定不如Netty。这里也只是给接收TCP、UDP请求设计方面多一个选择。
http://www.yutouwan.com/news/59985/

相关文章:

  • 网站建设老李教学网站软件开发的一般流程是什么
  • 长沙网站制作品牌电子简历表格手机版
  • 网站建设卩金手指科杰网络举报网站
  • 永州市建设工程质量安全监督站官方网站互联网营销师是什么
  • 网站建设展板什么是网页设计读书笔记
  • 山西建设机械网站wordpress自定义分享
  • 滨州网站建设hskj360宜州设计公司
  • 企业为什么需要网站整合营销概念
  • 石家庄做网站和宣传的浙江外发加工网
  • 做群头像的网站在线制作爱站网排行榜
  • 网站建设的总体设计厦门网站建设 九来
  • 网站备案审批号7一12岁手工简单又实用
  • 优秀的网站举例wordpress 轮播插件
  • 企业建站公司哪里找店面设计模板
  • 广州建外贸网站网站开发的技术有
  • 网站换代理超级优化
  • 电脑制作网站总么做游标卡尺 东莞网站建设
  • 创建一个网站临沂做网站的公司哪里有
  • 网站开发步骤说明书是什么农村电商平台简介
  • 邵阳网站开发公司推荐河南省建筑一体化平台官网
  • 铜仁建设厅官方网站深圳网站设计招聘网
  • 宁波哪里做网站深圳网站建设排名
  • 大岭山网站建设公司上海软件定制开发
  • 做电商网站货源网络营销公司全网推广公司
  • 怎样做营销型网站推广pptwordpress如何上传产品
  • 最新网站开发需求文档顺德乐从网站建设
  • 厦门市建设管理协会网站网络推广方式的研究
  • 在百度做网站怎么做wordpress适合百度吗
  • 滨州住房和城乡建设部网站房产信息查询系统入口
  • 网站建设学习教程it外包工作怎么样