spring-integration - 在 spring 集成实用程序中启用日志记录

标签 spring-integration

下面我有一个程序来发送消息并从队列中消费消息,现在我已经注释掉了发送部分,只想消费队列中的消息

现在我想在下面的程序中启用日志记录,以便在我的 c: 驱动器中生成一个日志文件,并且在该日志文件中它应该表明它在什么时间使用什么消息,请告知如何在下面的配置中配置日志记录文件

<?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:file="http://www.springframework.org/schema/integration/file"
    xmlns:context="http://www.springframework.org/schema/context"
    xsi:schemaLocation="http://www.springframework.org/schema/beans

    http://www.springframework.org/schema/beans/spring-beans.xsd 
    http://www.springframework.org/schema/integration http://www.springframework.org/schema/integration/spring-integration.xsd 
    http://www.springframework.org/schema/integration/jms 
    http://www.springframework.org/schema/integration/jms/spring-integration-jms.xsd 
    http://www.springframework.org/schema/integration/spring-integration.xsd
    http://www.springframework.org/schema/context 
    http://www.springframework.org/schema/integration/file
    http://www.springframework.org/schema/integration/file/spring-integration-file.xsd    
    http://www.springframework.org/schema/context/spring-context.xsd">


    <int:poller id="poller" default="true">
        <int:interval-trigger interval="200" />
    </int:poller>



    <int:channel id="input">
        <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://lsdrtems2.fm.crdgrp.net:7333</prop>
                <prop key="java.naming.security.principal">acfgtir</prop>
                <prop key="java.naming.security.credentials">acfgtir</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 bean="tibcoEMSConnFactory" />
        </property>
        <property name="defaultDestinationName">
            <value>acfgtirrtyation.ioa.swretift_publish_poc1</value>
        </property>
        <property name="pubSubDomain">
            <value>false</value>
        </property>
        <property name="receiveTimeout">
            <value>120000</value>
        </property>
    </bean>




    <!-- <jms:outbound-channel-adapter channel="input" 
        destination-name="acfgtirrtyation.ioa.swretift_publish_poc1" connection-factory="tibcoEMSConnFactory" /> -->

<int:channel id="objetChannel"></int:channel>
<int:channel id="StringChannel"></int:channel>
<int:channel id="jmsInChannel" />



<jms:message-driven-channel-adapter id="jmsIn" concurrent-consumers="10"
        destination-name="acfgtirrtyation.ioa.swretift_publish_poc1"  connection-factory="tibcoEMSConnFactory" extract-payload="false"
        channel="jmsInChannel" />

    <int:payload-type-router input-channel="jmsInChannel">
    <int:mapping type="javax.jms.ObjectMessage" channel="objetChannel" />
     <int:mapping type="javax.jms.TextMessage" channel="StringChannel" />
    </int:payload-type-router>



 <file:outbound-channel-adapter id="filesoutOject"  channel="objetChannel" directory="C:\\abcsaral"
 filename-generator="generatorr" />



 <file:outbound-channel-adapter id="filesoutString"  channel="StringChannel" directory="C:\\abcsaral"
 filename-generator="generatorr" />

<bean id="generatorr" class="com.abs.tibco.TimestampTextGenerator">
    </bean>


</beans>

最佳答案

将 log4j(或 logback,或 commons-logging 支持的任何 java 日志系统)添加到您的类路径,并将其配置为记录类别 org.springframework.integration 的调试级别。

或者您可以将 wire tap 添加到 channel 并将其路由到日志记录 channel 适配器

<int:channel id="in">
    <int:interceptors>
        <int:wire-tap channel="logger"/>
    </int:interceptors>
</int:channel>

<int:logging-channel-adapter id="logger" level="DEBUG"/>

关于spring-integration - 在 spring 集成实用程序中启用日志记录,我们在Stack Overflow上找到一个类似的问题: https://stackoverflow.com/questions/35679340/

相关文章:

spring - 我的 tcp 客户端使用 spring 集成无法获得响应

spring-boot - Spring Boot 2.0 - Quartz 和 Spring 集成 - 不工作

java - 在 Spring Integration 中为 Redis 创建 MessageSource

java - IBM 字符集 header 导致异常

java.lang.ClassNotFoundException : org. springframework.http.converter.json.MappingJackson2HttpMessageConverter

jakarta-ee - Spring Security - 'global-method-security' 不起作用

java - FTP 文件 - FileListFilter 仅获取最新文件

java - Spring 集成 MessagePublishingErrorHandler 未被调用

java - 如何等待QueueChannel处理所有消息?

java - Spring Cloud Stream Kafka 记录太大