最近使用Spring Integration,集成进一个项目,大致是做渠道管理需要转发http请求,多对多适配。权重随机推送,最多三次。
看了很多文章例子
比如这个,https://blog.youkuaiyun.com/w_x_z_/article/details/53316618
还有这个,https://www.cnblogs.com/pekkle/p/7906919.html
还是copy一些过来吧
使用Spring-Integration不仅节省了很多配置,还增加了可用性。
更多关于Spring-Integration的介绍可参照官网:http://spring.io/projects/spring-integration。
样例已上传至Github:https://github.com/hackyoMa/spring-integration-http-demo
项目基于Spring Boot2.0。
依赖:
<dependency> <groupId>org.springframework.integration</groupId> <artifactId>spring-integration-http</artifactId> <scope>compile</scope> <exclusions> <exclusion> <artifactId>jackson-module-kotlin</artifactId> <groupId>com.fasterxml.jackson.module</groupId> </exclusion> </exclusions> </dependency> <dependency> <groupId>com.alibaba</groupId> <artifactId>fastjson</artifactId> <version>1.2.47</version> </dependency>
配置文件application.properties:
server.port=8080 receive.path=/receiveGateway forward.path=https://oapi.dingtalk.com/robot/send?access_token=xxx
主类:
package com.integration.http; import org.springframework.boot.SpringApplication; import org.springframework.boot.autoconfigure.SpringBootApplication; import org.springframework.context.annotation.ImportResource; @SpringBootApplication @ImportResource(locations = "classpath:http-inbound-config.xml") public class HttpApp