0
我有一个弹簧下集成xml,其中我发送消息到队列中,并且该消息最终被消耗并显示在控制台上,但现在我想定制它可以说那些消息是在文本文件中应该最终写入(换句话说,这些消息需要被记录)并且该文本文件应该保存在我的文件夹的C:驱动器中文件的名称是messageslog.txt将队列的消息记录到文本文件
请告知如何我可以在春天集成本身添加这样的功能,以acheieve这个功能我已经知道,在春天集成东西像文件出站通道适配器将帮助
下面是我的sprin克integtaion XML
<?xml version="1.0" encoding="UTF-8"?>
<beans xmlns="http://www.springframework.org/schema/beans"
xmlns:xsi="http://www.w3.org/2001/XMLSchema-instance" xmlns:int="http://www.springframework.org/schema/integration"
xmlns:jms="http://www.springframework.org/schema/integration/jms"
xmlns:context="http://www.springframework.org/schema/context"
xsi:schemaLocation="http://www.springframework.org/schema/jms http://www.springframework.org/schema/jms/spring-jms-3.0.xsd
http://www.springframework.org/schema/integration http://www.springframework.org/schema/integration/spring-integration-2.0.xsd
http://www.springframework.org/schema/integration/jms http://www.springframework.org/schema/integration/jms/spring-integration-jms-2.0.xsd
http://www.springframework.org/schema/beans http://www.springframework.org/schema/beans/spring-beans-3.0.xsd
http://www.springframework.org/schema/context http://www.springframework.org/schema/context/spring-context-3.0.xsd">
<int:poller id="poller" default="true">
<int:interval-trigger interval="200" />
</int:poller>
<int:channel id="output">
<int:queue capacity="10" />
</int:channel>
<bean id="tibcoEMSJndiTemplate" class="org.springframework.jndi.JndiTemplate">
<property name="environment">
<props>
<prop key="java.naming.factory.initial">com.tibco.tibjms.naming.TibjmsInitialContextFactory</prop>
<prop key="java.naming.provider.url">tcp://labc.net:7033</prop>
<prop key="java.naming.security.principal">wer</prop>
<prop key="java.naming.security.credentials">wer</prop>
</props>
</property>
</bean>
<bean id="tibcoEMSConnFactory" class="org.springframework.jndi.JndiObjectFactoryBean">
<property name="jndiTemplate">
<ref bean="tibcoEMSJndiTemplate" />
</property>
<property name="jndiName">
<value>GenericConnectionFactory</value>
</property>
</bean>
<bean id="tibcosendJMSTemplate" class="org.springframework.jms.core.JmsTemplate">
<property name="connectionFactory">
<ref local="tibcoEMSConnFactory" />
</property>
<property name="defaultDestinationName">
<value>test.data</value>
</property>
<property name="pubSubDomain">
<value>false</value>
</property>
<property name="receiveTimeout">
<value>120000</value>
</property>
</bean>
<int:channel id="input">
</int:channel>
<jms:outbound-channel-adapter channel="input"
destination-name="test.data" connection-factory="tibcoEMSConnFactory" />
<jms:message-driven-channel-adapter
channel="output" destination-name="test.data" connection-factory="tibcoEMSConnFactory" />
</beans>
谢谢,请你解释一下为什么输入通道应该改变为发布订阅通道,以及如果我将jms出站通道适配器的值设置为order = 1,那么编程方面会有什么好处。在此先感谢 – user1620642 2015-04-01 11:54:22
您需要一个pub-sub频道,因为jms出站适配器没有“回复”可以发送到任何地方。因此,我们使用pub/sub,以便消费者(订阅者)按顺序获取消息。它们将按照它们声明的顺序被调用,但我更喜欢使用显式的'order =“...”'属性来让其他人清楚地看到jms先被调用的配置,然后是文件适配器。 – 2015-04-01 12:32:25