我想开发一个应用程序,使用它我希望能够将zip文件发送到在单独的服务器上运行的消息队列。我已经使用ActiveMQ成功实现了消息传递位,并且队列已启动并侦听服务器端的消息。 我有一个类似的应用程序,它将json文件作为消息发送到队列,并且工作正常。我试图根据前者如何实施来编写我的应用程序。如何轮询目录中的文件并使用spring集成将文件发送到消息队列
下面是我的Spring集成配置的一部分:
<int-file:inbound-channel-adapter id="filesIn" directory="${harvest.directory}" filename-pattern="*.zip">
<int:poller id="poller" fixed-rate="${harvest.pollRate}" max-messages-per-poll="${harvest.queueCapacity}" />
</int-file:inbound-channel-adapter>
<int:transformer id="copyFiles" input-channel="filesIn"
output-channel="routingChannel" ref="transformationHandler" method="handleFile"/>
<int-jms:outbound-channel-adapter id="jmsOut" destination="requestQueue" channel="filesIn"/>
.
.
.
<bean id="connectionFactory" class="org.apache.activemq.ActiveMQConnectionFactory">
<property name="brokerURL" value="${activemq.url}" />
</bean>
<bean id="requestQueue" class="org.apache.activemq.command.ActiveMQQueue">
<constructor-arg value="myQueue"/>
</bean>
正如你可以看到有一个变压器。但在我的情况下,如果可能的话,我没有什么可以改变的,也很乐意放弃变压器。我只需要能够轮询一个目录中的zip文件,并且每当有一个时,就将它发送到名为myQueue
的队列。不幸的是,从filesIn
入站通道适配器接收文件并使用jmsOut
出站通道适配器发送到队列的方法似乎不起作用。
我不确定这是否是正确的方法或者是否可行。有人能告诉我这里出了什么问题,我该怎么办?