Issue Details (XML | Word | Printable)

Key: MULE-3853
Type: Bug Bug
Status: Open Open
Priority: Major Major
Assignee: Unassigned
Reporter: Jamie Johnson
Votes: 0
Watchers: 0
Operations

If you were logged in you would be able to see more operations.
Mule

Retry Policy ignored if JBoss is not running at startup

Created: 17/Oct/08 03:52 PM   Updated: 24/Nov/08 03:21 PM
Component/s: Transport: JMS
Affects Version/s: 2.1.1
Fix Version/s: 2.1.x Backlog

Time Tracking:
Not Specified

Environment: Windows 2003, Linux
Issue Links:
Block
 
Related
 

Labels:
User impact: Medium
Effort points: 0.5
Log Output:
Exception stack is:
1. Connection refused: connect (java.net.ConnectException)
  java.net.PlainSocketImpl:-2 (http://java.sun.com/j2se/1.5.0/docs/api/java/net/ConnectException.html)
2. javax.naming.ServiceUnavailableException: Failed to connect to server localhost:1099 [Root exception is java.net.ConnectException: Connection refused: connect] (javax.naming.ServiceUnavailableException) org.jnp.interfaces.NamingContext:248 (http://java.sun.com/j2se/1.5.0/docs/api/javax/naming/ServiceUnavailableException.html)
3. javax.naming.CommunicationException: Failed to connect to server localhost:1099 [Root exception is javax.naming.ServiceUnavailableException: Failed to connect to server localhost:1099 [Root exception is java.net.ConnectException: Connection refused: connect]] (javax.naming.CommunicationException) org.jnp.interfaces.NamingContext:274 (http://java.sun.com/j2se/1.5.0/docs/api/javax/naming/CommunicationException.html)
4. javax.naming.CommunicationException: Could not obtain connection to any of these urls: localhost:1099 and discovery failed with error: javax.naming.CommunicationException: Receive timed out [Root exception is java.net.SocketTimeoutExcept
ion: Receive timed out] [Root exception is javax.naming.CommunicationException:Failed to connect to server localhost:1099 [Root exception is javax.naming.ServiceUnavailableException: Failed to connect to server localhost:1099 [Root exception is java.net.ConnectException: Connection refused: connect]]] (javax.naming.CommunicationException) org.jnp.interfaces.NamingContext:1562 (http://java.sun.com/j2se/1.5.0/docs/api
/javax/naming/CommunicationException.html)
5. Error creating bean with name 'jbossMQ' defined in URL [file:/C:/Mule/mule-2.1.1-SNAPSHOT/examples/hello/conf/hello-config.xml]: Invocation of init method failed; nested exception is javax.naming.CommunicationException: Could not obtainconnection to any of these urls: localhost:1099 and discovery failed with error: javax.naming.CommunicationException: Receive timed out [Root exception is java.net.SocketTimeoutException: Receive timed out] [Root exception is javax.naming.CommunicationException: Failed to connect to server localhost:1099 [Root exception is javax.naming.ServiceUnavailableException: Failed to connect to server localhost:1099 [Root exception is java.net.ConnectException: Connection refused: connect]]] (org.springframework.beans.factory.BeanCreationException) org.springframework.beans.factory.support.AbstractAutowireCapableBeanFactory:1302 (null)
6. Error creating bean with name 'JMSConnector': Cannot resolve reference to bean 'jbossMQ' while setting bean property 'connectionFactory'; nested exception is org.springframework.beans.factory.BeanCreationException: Error creating bean with name 'jbossMQ' defined in URL [file:/C:/Mule/mule-2.1.1-SNAPSHOT/examples/hello/conf/hello-config.xml]: Invocation of init method failed; nested exception is javax.naming.CommunicationException: Could not obtain connection to any of these urls: localhost:1099 and discovery failed with error: javax.naming.CommunicationException: Receive timed out [Root exception is java.net.SocketTimeoutException: Receive timed out] [Root exception is javax.naming.CommunicationException: Failed to connect to server localhost:1099 [Root exception is javax.naming.ServiceUnavailableException: Failed to connect to server localhost:1099 [Root exception is java.net.ConnectException: Connection refused: connect]]] (org.springframework.beans.factory.BeanCreationException) org.springframework.beans.factory.support.BeanDefinitionValueResolver:275 (nul
l)
7. Initialisation Failure: Error creating bean with name 'JMSConnector': Cannotresolve reference to bean 'jbossMQ' while setting bean property 'connectionFactory'; nested exception is org.springframework.beans.factory.BeanCreationException: Error creating bean with name 'jbossMQ' defined in URL [file:/C:/Mule/mule-2.1.1-SNAPSHOT/examples/hello/conf/hello-config.xml]: Invocation of init method failed; nested exception is javax.naming.CommunicationException: Could not obtain connection to any of these urls: localhost:1099 and discovery failed with error:javax.naming.CommunicationException: Receive timed out [Root exception is java.net.SocketTimeoutException: Receive timed out] [Root exception is javax.naming.CommunicationException: Failed to connect to server localhost:1099 [Root exception
 is javax.naming.ServiceUnavailableException: Failed to connect to server localhost:1099 [Root exception is java.net.ConnectException: Connection refused: connect]]] (org.mule.api.lifecycle.InitialisationException) org.mule.registry.AbstractRegistry:79 (http://www.mulesource.org/docs/site/cur
rent2/apidocs/org/mule/api/lifecycle/InitialisationException.html)


 Description  « Hide
When employing a custom retry policy if the JMS Server is not running the retry policy is ignored and the server shuts down. If the JMS Server is up and the topic is not found it will attempt to retry.

Relevant portion of retry policy:

public PolicyStatus applyPolicy(Throwable arg0) {
try { Thread.sleep(frequency); } catch (InterruptedException e) { }
return PolicyStatus.policyOk();
}

Relevant section of config.xml

<jms:connector name="JMSConnector" acknowledgementMode="AUTO_ACKNOWLEDGE" connectionFactory-ref="jbossMQ" recoverJmsConnections="true">

<spring:property name="retryPolicyTemplate">
<spring:bean class="retry.ForeverPolicyTemplate">
<spring:property name="frequency" value="8000"/>
</spring:bean>
</spring:property>
</jms:connector>

<spring:bean name="jbossMQ" class="org.springframework.jndi.JndiObjectFactoryBean">
<spring:property name="jndiName" value="java:/ConnectionFactory" />
<spring:property name="jndiEnvironment">
<spring:props>
<spring:prop key="java.naming.factory.initial">org.jnp.interfaces.NamingContextFactory</spring:prop>
<spring:prop key="specifications">1.1</spring:prop>
<spring:prop key="java.naming.provider.url">jnp://localhost:1099</spring:prop>
</spring:props>
</spring:property>
</spring:bean>



 All   Comments   Work Log   Change History   Transitions   FishEye      Sort Order: Ascending order - Click to sort in descending order
Travis Carlson added a comment - 21/Oct/08 03:48 PM
I was able to reproduce these symptoms with Mule 2.1.1 (loss of connection retries but lack of connection at startup does not retry)

The explanation of this behavior is that org.springframework.jndi.JndiObjectFactoryBean does a one-off lookup of the JMS ConnectionFactory at startup. If this lookup fails (which it will if JBoss is offline), then no retry will happen because we haven't even reached that lifecycle phase yet (we're still in the Initialise phase).

I found MULE-492 which is for the exact same scenario and was apparently working for 1.x but since the way we use JNDI with JMS has changed for 2.x this is now a regression.

There is a task pending for creating our own JNDI lookup class which supports retry strategies (MULE-3777). I think this is the ideal solution for this case, so I have made it a blocker for this issue.


Andrew Perepelytsya added a comment - 21/Oct/08 03:53 PM
Mule 2.1.1 has many of jndi features ported over from 1.x, so I recommend a Mule-first approach. Configure all your jndi params on Mule connector, without external jndi lookups by Spring, as e.g. in http://mule.mulesource.org/display/MULE2USER/WebLogic+JMS+Integration