Announcement Announcement Module
Collapse
No announcement yet.
Application doesn't start if it not able to connect to jnp url Page Title Module
Move Remove Collapse
X
Conversation Detail Module
Collapse
  • Filter
  • Time
  • Show
Clear All
new posts

  • Application doesn't start if it not able to connect to jnp url

    Hi,

    I have an application which reads from a queue in different application runing on different machine. My application doesn't start when the other application is down as its not able to connect to the machine on the port where it has its queue.

    Following are the configs.
    Code:
    <?xml version="1.0" encoding="UTF-8"?>
    <!DOCTYPE beans PUBLIC "-//SPRING//DTD BEAN//EN" "http://www.springframework.org/dtd/spring-beans-2.0.dtd">
    <beans>
     <!-- JNDI configuration -->
    	<bean id="jndiTemplate"
    		class="org.springframework.jndi.JndiTemplate">
    		<property name="environment">
    			<props>
    				<prop key="java.naming.factory.initial">
    					org.jnp.interfaces.NamingContextFactory
    				</prop>
    				<prop key="java.naming.provider.url">@jnpUrl@</prop>
    				<prop key="java.naming.factory.url.pkgs">
    					org.jnp.interfaces:org.jboss.naming
    				</prop>
    			</props>
    		</property>
    	</bean>
    	
    	<!-- JMS Connection factory -->
    	<bean id="jmsConnectionFactory"
    		class="org.springframework.jndi.JndiObjectFactoryBean">
    		<property name="jndiTemplate">
    			<ref bean="jndiTemplate" />
    		</property>
    		<property name="jndiName">
    			<value>QueueConnectionFactory</value>
    		</property>
    	</bean>
    	
    
    	<!-- JMS Destination -->
    	<bean id="destination"
    		class="org.springframework.jndi.JndiObjectFactoryBean">
    		<property name="jndiTemplate">
    			<ref bean="jndiTemplate" />
    		</property>
    		<property name="jndiName">
    			<value>queue/defaultQueue</value>
    		</property>
    	</bean>
    
    	<!-- this is the Message Driven POJO (MDP) -->
    	<bean id="defaultMessageListener"
    		class="com.xyz.default.jms.consumer.OnDemandDefaultProcessor">
    		<property name="onDemandDefaultControllerService" ref="onDemandDefaultControllerService"/>
    		<property name="configurationFactory" ref="configurationFactory"/>
        </bean>
    
    	<!-- and this is the message listener container -->
    	<bean id="listenerContainer"
    		class="org.springframework.jms.listener.DefaultMessageListenerContainer102">
    		<property name="concurrentConsumers" value="1" />
    		<property name="connectionFactory" ref="jmsConnectionFactory" />
    		<property name="destination" ref="destination" />
    		<property name="messageListener" ref="defaultMessageListener" />
    	</bean>	
    
    </beans>
    I would like to get the application started even if the other application is down and poll later to check if it has come and start processing messages if found into the queue.

    Please let me know if anyone has got around this problem.

    Thanks & Regards,
    Irfan

  • #2
    You can define the beans as prototypes and poll them from the application classes via, for example, ObjectFactory

    Comment


    • #3
      Hi Denis,

      Could you please explain it a bit more?

      Thanks & Regards,
      Irfan

      Comment


      • #4
        The idea is not to try to instantiate on startup the bean that may be not possible to create. I.e. if your bean needs to have direct references to remote application services and the application is down, you can't create the bean. So, just defer its instantiation until you detect that remote application is up.

        Comment

        Working...
        X