【发布时间】:2014-12-09 06:14:24
【问题描述】:
我在 Spring 集成中有一些要解决的问题,我是 Spring 集成的新手。
场景是处理三个 dbf 文件并提取数据并将其作为 JSON 发送到 HTTP REST 服务,如果该服务在 3 分钟内没有响应,则应等待 10 分钟并再次尝试。其余服务将以 json 回复。
现在我有三到四件事无法解决:
- 我需要阅读来自 rest 服务的回复,并根据该回复决定是重试还是完成该过程。 (如果我发送消息休息并且没有响应也应该重试)
- 例如,我需要从动态文件夹名称中获取多个文件({wherever}/20140101/HERE 将找到三个 DBF 文件)。有没有可能将文件夹名称作为模式或特定格式的日期?并且文件适配器可以处理多个文件或逐个文件。
- 有任何可能通过spring集成处理dbf文件并将其转换为json
在我的spring集成配置下:
<?xml version="1.0" encoding="UTF-8"?>
<beans xmlns="http://www.springframework.org/schema/beans"
xmlns:xsi="http://www.w3.org/2001/XMLSchema-instance"
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
http://www.springframework.org/schema/integration/file http://www.springframework.org/schema/integration/file/spring-integration-file.xsd
http://www.springframework.org/schema/task http://www.springframework.org/schema/task/spring-task.xsd
http://www.springframework.org/schema/integration/http http://www.springframework.org/schema/integration/http/spring-integration-http.xsd"
xmlns:int="http://www.springframework.org/schema/integration"
xmlns:int-file="http://www.springframework.org/schema/integration/file"
xmlns:int-http="http://www.springframework.org/schema/integration/http"
xmlns:task="http://www.springframework.org/schema/task">
<int:service-activator input-channel="filesInChannelDBF"
output-channel="requestChannel" >
<bean class="com.mm.integration.serviceactivator.FileProcessor" />
</int:service-activator>
<int:channel id="requestChannel" />
<int-http:outbound-gateway request-channel="requestChannel"
url="http://localhost:8090/receiveGateway" http-method="POST" />
<int-file:inbound-channel-adapter id="filesInChannelDBF"
directory="file:input" filename-pattern="FILENAME*">
<int:poller id="poller" fixed-rate="100" task-executor="executor" />
</int-file:inbound-channel-adapter>
<task:executor id="executor" pool-size="10" />
</beans>
这里是我的 pom:
<project xmlns="http://maven.apache.org/POM/4.0.0" xmlns:xsi="http://www.w3.org/2001/XMLSchema instance" xsi:schemaLocation="http://maven.apache.org/POM/4.0.0 http://maven.apache.org/xsd/maven- 4.0.0.xsd">
<modelVersion>4.0.0</modelVersion>
<groupId>com.mm.integration</groupId>
<artifactId>XXXX</artifactId>
<version>0.0.1-SNAPSHOT</version>
<parent>
<groupId>org.springframework.boot</groupId>
<artifactId>spring-boot-starter-parent</artifactId>
<version>1.1.9.RELEASE</version>
</parent>
<dependencies>
<dependency>
<groupId>org.springframework.boot</groupId>
<artifactId>spring-boot-starter-web</artifactId>
</dependency>
<dependency>
<groupId>org.springframework.boot</groupId>
<artifactId>spring-boot-starter-integration</artifactId>
</dependency>
<dependency>
<groupId>org.springframework.boot</groupId>
<artifactId>spring-boot-starter-logging</artifactId>
</dependency>
</dependencies>
<build>
<plugins>
<plugin>
<groupId>org.springframework.boot</groupId>
<artifactId>spring-boot-maven-plugin</artifactId>
</plugin>
</plugins>
</build>
</project>
这里是我的春季入口点。
@RestController
@EnableAutoConfiguration
@EnableIntegration
@ImportResource("classpath:spring/config/concurrentFileProcessing-config.xml")
public class MainApp {
@RequestMapping(value="/receiveGateway" , method=RequestMethod.POST)
public String testGateway(String jSon){
System.out.println("Starting process the message [reciveing]");
return "{HelloMessage: \"Hello\"}";
}
public static void main(String[] args) throws Exception {
SpringApplication.run(MainApp.class, args);
}
}
【问题讨论】:
标签: java spring rest soa spring-integration