0

Below is what I am trying to achieve:

  1. Pick a file from source directory.
  2. Copy that file into a destination directory.
  3. Post a message onto a weblogic queue from where a different application picks the file name and processes it from the destination directory.

Problem is every time the weblogic server is restarted(due to code deployment), Camel-JMS route hangs and stops working until the Camel route/Servicemix server is restarted.

Below is code for my Camel route:

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

Is there a property/configuration in Camel JMS which can be set to handle restarting of JMS server so that camel automatically connects to the weblogic queues every time it is restarted?

  • Its likely more of a JEE app server configuration with the JMS queue connection factory and all of that you use, and lookup using JNDI. It may have some cache settings, refresh settings, or timeouts etc. – Claus Ibsen Sep 04 '18 at 15:23
  • Thanks Claus for your inputs. Our servicemix was running on Windows OS before and we have migrated it to RedHat Linux recently and after that the problem disappeared. – Amit Chauhan Nov 09 '18 at 14:44

0 Answers0