正在显示
5 个修改的文件
包含
73 行增加
和
36 行删除
@@ -7,19 +7,32 @@ package com.tianbo.imfClient; | @@ -7,19 +7,32 @@ package com.tianbo.imfClient; | ||
7 | import org.mybatis.spring.annotation.MapperScan; | 7 | import org.mybatis.spring.annotation.MapperScan; |
8 | import org.springframework.boot.SpringApplication; | 8 | import org.springframework.boot.SpringApplication; |
9 | import org.springframework.boot.autoconfigure.SpringBootApplication; | 9 | import org.springframework.boot.autoconfigure.SpringBootApplication; |
10 | +import org.springframework.boot.web.client.RestTemplateBuilder; | ||
11 | +import org.springframework.cloud.client.discovery.EnableDiscoveryClient; | ||
12 | +import org.springframework.cloud.client.loadbalancer.LoadBalanced; | ||
13 | +import org.springframework.context.annotation.Bean; | ||
14 | +import org.springframework.context.annotation.ComponentScan; | ||
10 | import org.springframework.scheduling.annotation.EnableScheduling; | 15 | import org.springframework.scheduling.annotation.EnableScheduling; |
11 | import org.springframework.transaction.annotation.EnableTransactionManagement; | 16 | import org.springframework.transaction.annotation.EnableTransactionManagement; |
17 | +import org.springframework.web.client.RestTemplate; | ||
12 | 18 | ||
13 | @SpringBootApplication | 19 | @SpringBootApplication |
14 | @EnableScheduling | 20 | @EnableScheduling |
15 | -//@EnableEurekaClient | 21 | +@EnableDiscoveryClient |
16 | @EnableTransactionManagement | 22 | @EnableTransactionManagement |
17 | @MapperScan("com.tianbo.imfClient.dao") | 23 | @MapperScan("com.tianbo.imfClient.dao") |
24 | +@ComponentScan({"com.tianbo.imfClient"}) | ||
18 | public class ImfClientApplication { | 25 | public class ImfClientApplication { |
19 | 26 | ||
20 | public static void main(String[] args) { | 27 | public static void main(String[] args) { |
21 | SpringApplication.run(ImfClientApplication.class, args); | 28 | SpringApplication.run(ImfClientApplication.class, args); |
22 | } | 29 | } |
23 | 30 | ||
31 | + @Bean | ||
32 | + @LoadBalanced | ||
33 | + RestTemplate restTemplate(RestTemplateBuilder builder){ | ||
34 | + | ||
35 | + return builder.build(); | ||
36 | + } | ||
24 | } | 37 | } |
25 | 38 |
1 | -package com.tianbo.imfClient; | 1 | +package com.tianbo.imfClient.schedul; |
2 | 2 | ||
3 | import com.caac.imf.api.IMFClient; | 3 | import com.caac.imf.api.IMFClient; |
4 | -import com.tianbo.imfClient.handle.IMFSaveHandle; | ||
5 | -import com.tianbo.imfClient.schedul.IMF_Task; | ||
6 | import org.apache.log4j.Logger; | 4 | import org.apache.log4j.Logger; |
5 | +import org.springframework.beans.factory.annotation.Autowired; | ||
6 | +import org.springframework.boot.web.client.RestTemplateBuilder; | ||
7 | +import org.springframework.stereotype.Component; | ||
8 | +import org.springframework.web.client.RestOperations; | ||
7 | 9 | ||
10 | +@Component | ||
8 | public class IMF_Reader extends Thread{ | 11 | public class IMF_Reader extends Thread{ |
9 | protected static final Logger logger = Logger.getLogger(IMF_Reader.class); | 12 | protected static final Logger logger = Logger.getLogger(IMF_Reader.class); |
10 | - private IMFClient client; | ||
11 | public static boolean isrunning; | 13 | public static boolean isrunning; |
14 | + protected IMF_Reader imf_reader; | ||
15 | + | ||
16 | + | ||
17 | + @Autowired | ||
18 | + private RestOperations restTemplate; | ||
12 | 19 | ||
13 | - public IMF_Reader(IMFClient client) { | ||
14 | - this.client = client; | ||
15 | - } | ||
16 | 20 | ||
17 | @Override | 21 | @Override |
18 | public void run() { | 22 | public void run() { |
19 | try{ | 23 | try{ |
20 | isrunning =true; | 24 | isrunning =true; |
21 | while(true) { | 25 | while(true) { |
26 | + IMFClient client = IMF_Task.client; | ||
27 | + if (null==restTemplate){ | ||
28 | + RestTemplateBuilder builder = new RestTemplateBuilder(); | ||
29 | + restTemplate = builder.build(); | ||
30 | + } | ||
22 | if (IMF_Task.LOGIN_OK) { | 31 | if (IMF_Task.LOGIN_OK) { |
23 | - String message = this.client.getMSG(); | 32 | + String message = client.getMSG(); |
24 | if (message != null) { | 33 | if (message != null) { |
25 | - IMFSaveHandle imfSaveHandle = new IMFSaveHandle(); | ||
26 | - imfSaveHandle.handle(message); | 34 | + //调用spring cloud 其他服务接口处理 |
35 | + restTemplate.put("http://fimsagentserver/msgAgent",message); | ||
36 | +// IMFSaveHandle imfSaveHandle = new IMFSaveHandle(); | ||
37 | +// imfSaveHandle.handle(message); | ||
27 | } | 38 | } |
28 | 39 | ||
29 | } else { | 40 | } else { |
1 | -package com.tianbo.imfClient; | 1 | +package com.tianbo.imfClient.schedul; |
2 | 2 | ||
3 | import com.caac.imf.api.IMFClient; | 3 | import com.caac.imf.api.IMFClient; |
4 | -import com.tianbo.imfClient.schedul.IMF_Task; | ||
5 | import com.tianbo.util.Date.DateUtil; | 4 | import com.tianbo.util.Date.DateUtil; |
6 | import com.tianbo.util.IO.FileTool; | 5 | import com.tianbo.util.IO.FileTool; |
7 | import com.tianbo.util.XML.MakeImfMeta; | 6 | import com.tianbo.util.XML.MakeImfMeta; |
@@ -2,13 +2,14 @@ package com.tianbo.imfClient.schedul; | @@ -2,13 +2,14 @@ package com.tianbo.imfClient.schedul; | ||
2 | 2 | ||
3 | import com.caac.imf.api.IMFClient; | 3 | import com.caac.imf.api.IMFClient; |
4 | import com.caac.imf.api.IMFClientFactory; | 4 | import com.caac.imf.api.IMFClientFactory; |
5 | -import com.tianbo.imfClient.IMF_Reader; | ||
6 | -import com.tianbo.imfClient.IMF_Sender; | ||
7 | import com.tianbo.util.IO.FileTool; | 5 | import com.tianbo.util.IO.FileTool; |
8 | import org.apache.log4j.Logger; | 6 | import org.apache.log4j.Logger; |
9 | import org.apache.log4j.PropertyConfigurator; | 7 | import org.apache.log4j.PropertyConfigurator; |
8 | +import org.springframework.beans.factory.annotation.Autowired; | ||
10 | import org.springframework.scheduling.annotation.Scheduled; | 9 | import org.springframework.scheduling.annotation.Scheduled; |
11 | import org.springframework.stereotype.Component; | 10 | import org.springframework.stereotype.Component; |
11 | +import org.springframework.web.client.RestOperations; | ||
12 | + | ||
12 | import java.text.SimpleDateFormat; | 13 | import java.text.SimpleDateFormat; |
13 | 14 | ||
14 | @Component | 15 | @Component |
@@ -22,15 +23,29 @@ public class IMF_Task { | @@ -22,15 +23,29 @@ public class IMF_Task { | ||
22 | public static String loginpass; | 23 | public static String loginpass; |
23 | public static String isNeedSend = "N"; | 24 | public static String isNeedSend = "N"; |
24 | 25 | ||
26 | + @Autowired | ||
27 | + private RestOperations restTemplate; | ||
28 | + | ||
25 | 29 | ||
26 | -// @Scheduled(fixedRate = 5000) | ||
27 | - public static void start() throws Exception { | 30 | + @Scheduled(fixedRate = 5000) |
31 | + public void start() throws Exception { | ||
28 | PropertyConfigurator.configure("config/log4j.properties"); | 32 | PropertyConfigurator.configure("config/log4j.properties"); |
29 | client = IMFClientFactory.createInstance(); | 33 | client = IMFClientFactory.createInstance(); |
30 | loginname= FileTool.readProperties("loginname"); | 34 | loginname= FileTool.readProperties("loginname"); |
31 | loginpass= FileTool.readProperties("loginpass"); | 35 | loginpass= FileTool.readProperties("loginpass"); |
32 | isNeedSend= FileTool.readProperties("isNeedSend"); | 36 | isNeedSend= FileTool.readProperties("isNeedSend"); |
33 | 37 | ||
38 | + logger.info(restTemplate); | ||
39 | + restTemplate.put("http://fimsagentserver/msgAgent","<MSG>\n" + | ||
40 | + "\t<META>\n" + | ||
41 | + "\t\t<SNDR>FIMS</SNDR>\n" + | ||
42 | + "\t\t<RCVR/>\n" + | ||
43 | + "\t\t<SEQN>315756</SEQN>\n" + | ||
44 | + "\t\t<DDTM>20190401020521</DDTM>\n" + | ||
45 | + "\t\t<TYPE>DFOE</TYPE>\n" + | ||
46 | + "\t\t<STYP>DFDL</STYP>\n" + | ||
47 | + "\t</META>" + | ||
48 | + "</MSG>"); | ||
34 | 49 | ||
35 | //登录 | 50 | //登录 |
36 | if (!LOGIN_OK) { | 51 | if (!LOGIN_OK) { |
@@ -39,7 +54,7 @@ public class IMF_Task { | @@ -39,7 +54,7 @@ public class IMF_Task { | ||
39 | 54 | ||
40 | //启动读取线程 | 55 | //启动读取线程 |
41 | if (client != null) { | 56 | if (client != null) { |
42 | - IMF_Reader reader = new IMF_Reader(client); | 57 | + IMF_Reader reader = new IMF_Reader(); |
43 | 58 | ||
44 | if (!IMF_Reader.isrunning) { | 59 | if (!IMF_Reader.isrunning) { |
45 | reader.start(); | 60 | reader.start(); |
@@ -9,10 +9,26 @@ web.upload-path=upload/ | @@ -9,10 +9,26 @@ web.upload-path=upload/ | ||
9 | springboot.mvc.static-path-pattern=/** | 9 | springboot.mvc.static-path-pattern=/** |
10 | spring.resources.static-locations=classpath:/META-INF/resources/,classpath:/static,classpath:/resources/,classpath:/templates/,file:${web.upload-path} | 10 | spring.resources.static-locations=classpath:/META-INF/resources/,classpath:/static,classpath:/resources/,classpath:/templates/,file:${web.upload-path} |
11 | 11 | ||
12 | +#springcloud 基本配置 | ||
13 | + | ||
14 | +#eureka主机名,会在控制页面中显示 | ||
15 | +spring.cloud.features.enabled=true | ||
16 | +spring.cloud.discovery.enabled=true | ||
17 | +spring.cloud.service-registry.auto-registration.enabled=true | ||
18 | +eureka.instance.hostname=${spring.cloud.client.ip-address} | ||
19 | +#eureka服务器页面中status的请求路径 | ||
20 | +eureka.instance.status-page-url=http://${eureka.instance.hostname}:${server.port}/index | ||
12 | 21 | ||
22 | +#eureka注册中心服务器地址 | ||
23 | +eureka.client.service-url.defaultZone=http://127.0.0.1:19527/eureka/ | ||
24 | +eureka.instance.prefer-ip-address=true | ||
25 | +eureka.instance.instance-id=${spring.cloud.client.ip-address}:${server.port} | ||
26 | +eureka.client.registry-fetch-interval-seconds=30 | ||
27 | +eureka.instance.lease-renewal-interval-in-seconds=15 | ||
28 | +eureka.instance.lease-expiration-duration-in-seconds=45 | ||
13 | 29 | ||
14 | #服务名 | 30 | #服务名 |
15 | -spring.application.name=tianbo.base.dev.devkit | 31 | +spring.application.name=fimsAgentClient |
16 | 32 | ||
17 | spring.jackson.serialization.fail-on-empty-beans=false | 33 | spring.jackson.serialization.fail-on-empty-beans=false |
18 | 34 | ||
@@ -27,23 +43,6 @@ spring.jackson.default-property-inclusion=always | @@ -27,23 +43,6 @@ spring.jackson.default-property-inclusion=always | ||
27 | 43 | ||
28 | spring.mvc.view.suffix=.html | 44 | spring.mvc.view.suffix=.html |
29 | 45 | ||
30 | -#springcloud 基本配置 | ||
31 | - | ||
32 | -#eureka主机名,会在控制页面中显示 | ||
33 | -spring.cloud.features.enabled=false | ||
34 | -spring.cloud.discovery.enabled=false | ||
35 | -spring.cloud.service-registry.auto-registration.enabled=false | ||
36 | -#eureka.instance.hostname=${spring.cloud.client.ip-address} | ||
37 | -#eureka服务器页面中status的请求路径 | ||
38 | -#eureka.instance.status-page-url=http://${eureka.instance.hostname}:${server.port}/index | ||
39 | -#eureka注册中心服务器地址 | ||
40 | -#eureka.client.service-url.defaultZone=http://10.50.3.82:19527/eureka/ | ||
41 | -#eureka.instance.prefer-ip-address=true | ||
42 | -#eureka.instance.instance-id=${spring.cloud.client.ip-address}:${server.port} | ||
43 | -#eureka.client.registry-fetch-interval-seconds=30 | ||
44 | -#eureka.instance.lease-renewal-interval-in-seconds=15 | ||
45 | -#eureka.instance.lease-expiration-duration-in-seconds=45 | ||
46 | - | ||
47 | #spring.datasource oracle | 46 | #spring.datasource oracle |
48 | spring.datasource.type=com.alibaba.druid.pool.DruidDataSource | 47 | spring.datasource.type=com.alibaba.druid.pool.DruidDataSource |
49 | #spring.datasource.driver-class-name=oracle.jdbc.OracleDriver | 48 | #spring.datasource.driver-class-name=oracle.jdbc.OracleDriver |
-
请 注册 或 登录 后发表评论