每次重新启动链接的JMS Weblogic服务器时,Camel-JMS都会挂起

时间:2018-08-30 14:53:35

标签: apache-camel camel-jms

以下是我要实现的目标:

  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队列?

0 个答案:

没有答案