How to integrate legacy executables into Spring In

2019-08-10 03:21发布

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条回答
Explosion°爆炸
2楼-- · 2019-08-10 03:37

Something like this:

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

?

查看更多
登录 后发表回答