How to integrate legacy executables into Spring Integration application?

守給你的承諾、 提交于 2020-01-06 01:58:09

问题


I have some legacy programs in C that work based on the input file and the result go to the output file. Both files are specified in the program arguments. So the call looks like the following:

prj.exe  a.dat a.out

Based on Artem Bilan suggestion I created the project with the following Spring Configuration file. It works in terms of invoking executable! However, I still have the problem with the outbound channel. First, it contains nothing and I am getting the error "unsupported Message payload type". Second, what is more important, I need to process the output file a.out by a Java program. What is the best way to organize this workflow? Is it possible to substitute the useless in this case inbound-channel-adapter to something useful?

<int-file:inbound-channel-adapter id="producer-file-adapter"
    channel="inboundChannel" directory="file:/Users/anarinsky/springint/chem"
    prevent-duplicates="true">
    <int:poller fixed-rate="5000" />
</int-file:inbound-channel-adapter>

<int:channel id="inboundChannel" />
<int:channel id="outboundChannel" />
<int:service-activator input-channel="inboundChannel"  output-channel="outboundChannel"
expression="new ProcessBuilder('/Users/anarinsky/springint/chem/prj', '/Users/anarinsky/springint/chem/a.dat', '/Users/anarinsky/springint/chem/a.out').start()">
</int:service-activator>

<int-file:outbound-channel-adapter
    channel="outboundChannel" id="consumer-file-adapter"
    directory="file:/Users/anarinsky/springint/chem"/>

回答1:


Something like this:

<int:service-activator expression="new ProcessBuilder('prj.exe', 'a.dat', 'a.out').start()"/>

?



来源:https://stackoverflow.com/questions/35366345/how-to-integrate-legacy-executables-into-spring-integration-application

易学教程内所有资源均来自网络或用户发布的内容,如有违反法律规定的内容欢迎反馈
该文章没有解决你所遇到的问题?点击提问,说说你的问题,让更多的人一起探讨吧!