我有一个下面的spring集成xml,我在其中向队列发送消息,该消息最终被消耗并显示在控制台上,但现在我想自定义它可以说最终会写入消息(换句话说)这些消息需要记录在一个文本文件中,该文本文件应该保存在我的文件夹的C:驱动器中,文件名是messageslog.txt
请告知我如何在spring集成中添加此类功能以实现此功能我已经知道在Spring集成中,类似文件出站通道适配器将有所帮助
下面是我的spring 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>
答案 0 :(得分:0)
input
更改为<publish-subscribe-channel/>
order="1"
order="2"
默认情况下,仅当发送到JMS成功时才会调用文件适配器。
output
似乎没有消费者;但是,为了避免邮件丢失,output
NOT 应该是QueueChannel
,只需删除<queue/>
元素(并且您不需要轮询)。< / p>