0

以下是我想要实现的目标:

  1. 从源目录中选择一个文件。
  2. 将该文件复制到目标目录中。
  3. 将消息发布到 weblogic 队列中,不同的应用程序从该队列中选择文件名并从目标目录处理它。

问题是每次重新启动 weblogic 服务器时(由于代码部署),Camel-JMS 路由都会挂起并停止工作,直到重新启动 Camel 路由/Servicemix 服务器。

下面是我的骆驼路线的代码:

<?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:camel="http://camel.apache.org/schema/spring"
       xsi:schemaLocation="
       http://www.springframework.org/schema/beans http://www.springframework.org/schema/beans/spring-beans.xsd
       http://camel.apache.org/schema/spring http://camel.apache.org/schema/spring/camel-spring.xsd">

    <!-- file name filter for Outgoing data file from weblogic -->
    <bean id="outFilter" class="org.apache.camel.component.file.AntPathMatcherGenericFileFilter">
            <property name="includes" value="**/*TEST*.csv"/>
    </bean> 

    <bean id="jndiTemplate" class="org.springframework.jndi.JndiTemplate">
        <property name="environment">
            <props>
                <prop key="java.naming.factory.initial">weblogic.jndi.WLInitialContextFactory</prop>
                <prop key="java.naming.provider.url">t3://<<servername>>:<<serverport>></prop>
                <prop key="java.naming.security.principal">admin</prop>
                <prop key="java.naming.security.credentials">admin123</prop>
            </props>
        </property>
    </bean>

    <bean id="jndiFactoryBean" class="org.springframework.jndi.JndiObjectFactoryBean">
        <property name="jndiName"             value="weblogic.jms.ConnectionFactory"/>
        <property name="jndiTemplate"         ref="jndiTemplate"/>
        <property name="lookupOnStartup"     value="false"/>
        <property name="proxyInterface"     value="javax.jms.ConnectionFactory"/>
    </bean>

    <bean id="jndiDestinationResolver" class="org.springframework.jms.support.destination.JndiDestinationResolver">
        <property name="jndiTemplate" ref="jndiTemplate"/>
    </bean>

    <bean id="jmsConfiguration" class="org.apache.camel.component.jms.JmsConfiguration">
        <property name="connectionFactory" ref="jndiFactoryBean"/>
        <property name="destinationResolver" ref="jndiDestinationResolver"/>
    </bean>

    <bean id="jms" class="org.apache.camel.component.jms.JmsComponent">
        <property name="configuration" ref="jmsConfiguration" />
    </bean>

    <!-- Camel Context for WebLogic Environment -->
    <camelContext xmlns="http://camel.apache.org/schema/spring" id="weblogic-uat-camelcontext">

        <route id="testJMS">
            <from uri="file:///C:/input&amp;filter=#outFilter"/>
            <log message="File transfer begin"/>
            <doTry>
                <to uri="file:///C:/output"/>
                <setBody>  
                    <simple>${header.CamelFileName}</simple>  
                </setBody>  
                <log message="The message contains file name ${body}" />  
                <to uri="jms:queue:jms/SampleQueue?jmsMessageType=Text"/>
                <doCatch>
                    <exception>java.io.IOException</exception>
                    <handled>
                        <constant>false</constant>
                    </handled> 
                    <log message="{{file.transferFailedMessage}}"/>
                </doCatch>            
            </doTry>
            <onCompletion onCompleteOnly="true">
                <log message="File transfer complete"/>
            </onCompletion>
        </route>

    </camelContext>
</beans>

Camel JMS 中是否有一个属性/配置可以设置为处理 JMS 服务器的重新启动,以便骆驼每次重新启动时自动连接到 weblogic 队列?

4

0 回答 0