[mule-user] (Community Edition) How to handle connection failure?

49 views
Skip to first unread message

a a

unread,
Mar 5, 2011, 12:32:42 PM3/5/11
to us...@mule.codehaus.org
Hi,

I'm using Mule 3.x Community Edition. I want to handle connection failure (JDBC, FTP, ...). For instance, I take files from FTP and insert records into database. The problem occurs when during transaction, I have a JDBC connection failure. The files are already taken from FTP (so are deleted), and how to save them anywhere and automatically retransmit them when the connection is restored?

Thx,
Stevy

---------------------------------------------------------------------
To unsubscribe from this list, please visit:

http://xircles.codehaus.org/manage_email


Magnus Larsson

unread,
Mar 5, 2011, 1:15:43 PM3/5/11
to us...@mule.codehaus.org, a a
Hello Stevy!

A high level suggestion (that at least works for us :-):

1. Put the content in the FTP-files on a JMS queue to secure the FTP transfer.
Assuming that the communication between Mule and the JMS provider is robust this will more or less "never fail" (from a JMS perspective).

2. Then in a second flow try to read the messages from the queue and insert them in the database as table records.
If the database insert fails, e.g. due to connection problem, you can use transaction semantics to rollback both the database and the queue and then apply retry policies on the JMS queue to retry a number of times with a proper intervall. After a number of retries we configure the JMS provider to place the message on a deadletter queue (that we monitor properly).

3. Typically some JDBC-driver and JMS-provider specific configuration also is required to handle stale connections in a, from a Mule perspective, transparent way (e.g. get rid of stale connections from the underlying connection pool...)

Hope that helps!

Regards,
Magnus.
--
Magnus Larsson

Callista Enterprise AB
Mobile: +46 (0)733-51 91 72
mailto:magnus....@callistaenterprise.se
http://www.callistaenterprise.se

a a

unread,
Mar 5, 2011, 8:52:36 PM3/5/11
to us...@mule.codehaus.org
Thanks Magnus for your reply...
It was the first thing I thought about (using JMS). But I wonder if there are some JMS providers already bundled to Mule??? (I know that JBoss ESB has some kind of providers, but for Mule ESB I don't know). Must I need to install external JMS providers? Can't I avoid using JMS, and handle these connection failures another way?

Best regards.
**
Stevy

Edited by: a a on 5 mars 2011 17:52

Magnus Larsson

unread,
Mar 6, 2011, 12:36:46 AM3/6/11
to us...@mule.codehaus.org, a a
Hello again!

Well, this is what JMS does (i.e. messaging middleware), so if that is what you require then JMS it is :-)
There was a similar discussion recently on the subject "can you use something else than JMS to do what JMS is meant for" and the answer was "no" :-)

No JMS provider comes pre-bundled with Mule but is's only takes a maven dependency to "bundle" one :-)
 
We use Apache ActiveMQ a lot as JMS provider and it can be used both as an external queue manager or it can be configured to be running embedded within the Mule instance. 
Sometime customers require usage of commercial JMS providers and that works as well but then only as an external queue manager.

Sample maven dependency for bundling ActiveMQ with Mule:

<dependency>

<groupId>org.apache.activemq</groupId>

<artifactId>activemq-core</artifactId>

<version>${activemq.version}</version>

</dependency>


Mvh,

Magnus.
--
Magnus Larsson

Callista Enterprise AB
Mobile: +46 (0)733-51 91 72
mailto:magnus....@callistaenterprise.se
http://www.callistaenterprise.se


David Dossot

unread,
Mar 6, 2011, 12:51:11 AM3/6/11
to us...@mule.codehaus.org, Magnus Larsson, a a
If you're interested, I've detailed a lot of Mule-ActiveMQ integration scenarios on this page: http://www.mulesoft.org/mule-activemq-integration-examples

a a

unread,
Mar 6, 2011, 12:22:54 PM3/6/11
to us...@mule.codehaus.org
Thanks David and and Magnus for your replies... I'll try to use Active MQ, and write you if i face some problems.

Thx,
**
Stevy

a a

unread,
Mar 6, 2011, 1:01:45 PM3/6/11
to us...@mule.codehaus.org
Hi David,

I saw the following phrases on this page http://www.mulesoft.org/mule-activemq-integration-examples that you advised me : "Thanks to Mule ESB’s native support for Apache ActiveMQ and the capacity to transparently use Spring for advanced configuration needs" & "Mule, and its embedded ActiveMQ". Does it mean that Active MQ is pre-bundled to Mule??? Or do I need to add Active MQ libraries to Mule?? (Please, can you quickly describe me all the process if I need to add external Active MQ libraries to Mule?)

Thx for your help,

David Dossot

unread,
Mar 6, 2011, 1:15:53 PM3/6/11
to us...@mule.codehaus.org, a a
Hey Stevy,

What this verbiage of mine tries to say is that Mule has a specific support for ActiveMQ (see: http://www.mulesoft.org/documentation/display/MULE3USER/ActiveMQ+Integration) which allows to bootstrap a broker with minimal configuration.

You still need to add the ActiveMQ libs, which can be done by adding the org.apache.activemq:activemq-core Maven dependency (you will need more dependencies if you don't use the default persistence mechanism).

HTH
D.

a a

unread,
Mar 6, 2011, 1:49:26 PM3/6/11
to us...@mule.codehaus.org
Ok thanks, I'll try and give you return later...

**
Stevyy

a a

unread,
Mar 6, 2011, 2:48:13 PM3/6/11
to us...@mule.codehaus.org
Hi David,

I've tried to use the configuration on : http://www.mulesoft.org/mule-activemq-integration-examples .

<spring:beans>
<spring:bean id="AmqDeadLetterStrategy"
class="org.apache.activemq.broker.region.policy.IndividualDeadLetterStrategy"
p:queuePrefix="DLQ." />

<spring:bean id="AmqDefaultPolicyEntry"
class="org.apache.activemq.broker.region.policy.PolicyEntry"
p:queue="jobs.*"
p:deadLetterStrategy-ref="AmqDeadLetterStrategy" />

<spring:bean id="AmqPolicyMap"
class="org.apache.activemq.broker.region.policy.PolicyMap"
p:defaultEntry-ref="AmqDefaultPolicyEntry" />

<spring:bean name="AmqBroker"
class="org.apache.activemq.broker.BrokerService"
p:brokerName="esb-amq-broker"
p:persistent="true"
p:dataDirectory="${activemq.data.dir}"
p:useJmx="true"
p:useShutdownHook="false"
p:destinationPolicy-ref="AmqPolicyMap"
init-method="start"
destroy-method="stop" />

<spring:bean name="AmqRedeliveryPolicy"
class="org.apache.activemq.RedeliveryPolicy"
p:useExponentialBackOff="true" />

<spring:bean name="AmqConnectionFactory"
class="org.apache.activemq.spring.ActiveMQConnectionFactory"
p:brokerURL="vm://esb-amq-broker"
p:redeliveryPolicy-ref="AmqRedeliveryPolicy"
depends-on="AmqBroker" />
</spring:beans>

<jms:activemq-connector name="EsbJmsConnector"
specification="1.1"
connectionFactory-ref="AmqConnectionFactory"
disableTemporaryReplyToDestinations="true"
persistentDelivery="true">
</jms:activemq-connector>
**

I got an error:
**
ERROR 2011-03-06 20:36:52,390 [main] org.mule.config.spring.SpringXmlConfigurationBuilder: Configuration with "org.mule.config.spring.SpringXmlConfigurationBuilder" failed.
org.mule.api.lifecycle.InitialisationException: Line 50 in XML document from URL [file:/D:/workspace_eclipse/ActiveMQ_Test/conf/mule-config.xml] is invalid; nested exception is org.xml.sax.SAXParseException: The prefix "p" for attribute "p:queuePrefix" associated with an element type "spring:bean" is not bound.
at org.mule.registry.AbstractRegistry.initialise(AbstractRegistry.java:115)
at org.mule.config.spring.SpringXmlConfigurationBuilder.createSpringRegistry(SpringXmlConfigurationBuilder.java:116)
at org.mule.config.spring.SpringXmlConfigurationBuilder.doConfigure(SpringXmlConfigurationBuilder.java:73)
at org.mule.config.builders.AbstractConfigurationBuilder.configure(AbstractConfigurationBuilder.java:47)
at org.mule.config.builders.AbstractResourceConfigurationBuilder.configure(AbstractResourceConfigurationBuilder.java:78)
at org.mule.config.builders.AutoConfigurationBuilder.autoConfigure(AutoConfigurationBuilder.java:101)
at org.mule.config.builders.AutoConfigurationBuilder.doConfigure(AutoConfigurationBuilder.java:57)
at org.mule.config.builders.AbstractConfigurationBuilder.configure(AbstractConfigurationBuilder.java:47)
at org.mule.config.builders.AbstractResourceConfigurationBuilder.configure(AbstractResourceConfigurationBuilder.java:78)
at org.mule.context.DefaultMuleContextFactory.createMuleContext(DefaultMuleContextFactory.java:79)
at org.mule.MuleServer.initialize(MuleServer.java:377)
at org.mule.MuleServer.run(MuleServer.java:267)
at org.mule.MuleServer.start(MuleServer.java:254)
at org.mule.MuleServer.main(MuleServer.java:127)
Caused by: org.springframework.beans.factory.xml.XmlBeanDefinitionStoreException: Line 50 in XML document from URL [file:/D:/workspace_eclipse/ActiveMQ_Test/conf/mule-config.xml] is invalid; nested exception is org.xml.sax.SAXParseException: The prefix "p" for attribute "p:queuePrefix" associated with an element type "spring:bean" is not bound.
at org.springframework.beans.factory.xml.XmlBeanDefinitionReader.doLoadBeanDefinitions(XmlBeanDefinitionReader.java:396)
at org.springframework.beans.factory.xml.XmlBeanDefinitionReader.loadBeanDefinitions(XmlBeanDefinitionReader.java:334)
at org.springframework.beans.factory.xml.XmlBeanDefinitionReader.loadBeanDefinitions(XmlBeanDefinitionReader.java:302)
at org.springframework.beans.factory.support.AbstractBeanDefinitionReader.loadBeanDefinitions(AbstractBeanDefinitionReader.java:143)
at org.mule.config.spring.MuleApplicationContext.loadBeanDefinitions(MuleApplicationContext.java:107)
at org.springframework.context.support.AbstractRefreshableApplicationContext.refreshBeanFactory(AbstractRefreshableApplicationContext.java:130)
at org.springframework.context.support.AbstractApplicationContext.obtainFreshBeanFactory(AbstractApplicationContext.java:467)
at org.springframework.context.support.AbstractApplicationContext.refresh(AbstractApplicationContext.java:397)
at org.mule.config.spring.SpringRegistry.doInitialise(SpringRegistry.java:100)
at org.mule.registry.AbstractRegistry.initialise(AbstractRegistry.java:107)
... 13 more
Caused by: org.xml.sax.SAXParseException: The prefix "p" for attribute "p:queuePrefix" associated with an element type "spring:bean" is not bound.
at com.sun.org.apache.xerces.internal.util.ErrorHandlerWrapper.createSAXParseException(ErrorHandlerWrapper.java:195)
at com.sun.org.apache.xerces.internal.util.ErrorHandlerWrapper.fatalError(ErrorHandlerWrapper.java:174)
at com.sun.org.apache.xerces.internal.impl.XMLErrorReporter.reportError(XMLErrorReporter.java:388)
at com.sun.org.apache.xerces.internal.impl.XMLErrorReporter.reportError(XMLErrorReporter.java:318)
at com.sun.org.apache.xerces.internal.impl.XMLNSDocumentScannerImpl.scanStartElement(XMLNSDocumentScannerImpl.java:334)
at com.sun.org.apache.xerces.internal.impl.XMLDocumentFragmentScannerImpl$FragmentContentDriver.next(XMLDocumentFragmentScannerImpl.java:2755)
at com.sun.org.apache.xerces.internal.impl.XMLDocumentScannerImpl.next(XMLDocumentScannerImpl.java:648)
at com.sun.org.apache.xerces.internal.impl.XMLNSDocumentScannerImpl.next(XMLNSDocumentScannerImpl.java:140)
at com.sun.org.apache.xerces.internal.impl.XMLDocumentFragmentScannerImpl.scanDocument(XMLDocumentFragmentScannerImpl.java:511)
at com.sun.org.apache.xerces.internal.parsers.XML11Configuration.parse(XML11Configuration.java:808)
at com.sun.org.apache.xerces.internal.parsers.XML11Configuration.parse(XML11Configuration.java:737)
at com.sun.org.apache.xerces.internal.parsers.XMLParser.parse(XMLParser.java:119)
at com.sun.org.apache.xerces.internal.parsers.DOMParser.parse(DOMParser.java:235)
at com.sun.org.apache.xerces.internal.jaxp.DocumentBuilderImpl.parse(DocumentBuilderImpl.java:284)
at org.springframework.beans.factory.xml.DefaultDocumentLoader.loadDocument(DefaultDocumentLoader.java:75)
at org.springframework.beans.factory.xml.XmlBeanDefinitionReader.doLoadBeanDefinitions(XmlBeanDefinitionReader.java:388)
... 22 more
**

How can I fix it?

**
Stevy

David Dossot

unread,
Mar 6, 2011, 2:55:20 PM3/6/11
to us...@mule.codehaus.org, a a

a a

unread,
Mar 6, 2011, 3:35:06 PM3/6/11
to us...@mule.codehaus.org
Ok, thanks...

Euh, jms can't process HashMap ??? See the output below... (I have a transformer on my inbound-endpoint which returns a List<HashMap>, and I want to put values on JMS outbound-endpoint)

ERROR 2011-03-06 21:29:05,792 [EsbJmsConnector.dispatcher.1] org.mule.exception.DefaultServiceExceptionStrategy:
********************************************************************************
Message : Invalid type passed to StreamMessage: HashMap . Allowed types are: Boolean, Byte, Short, Character, Integer, Long, Float, Double,String and byte[] (javax.jms.MessageFormatException)
Code : MULE_ERROR-64999
--------------------------------------------------------------------------------
Exception stack is:
1. Invalid type passed to StreamMessage: HashMap . Allowed types are: Boolean, Byte, Short, Character, Integer, Long, Float, Double,String and byte[](JMS Code: null) (javax.jms.MessageFormatException)
org.mule.transport.jms.JmsMessageUtils:211 (http://java.sun.com/j2ee/sdk_1.3/techdocs/api/javax/jms/MessageFormatException.html)
2. Invalid type passed to StreamMessage: HashMap . Allowed types are: Boolean, Byte, Short, Character, Integer, Long, Float, Double,String and byte[] (javax.jms.MessageFormatException) (org.mule.api.transformer.TransformerException)
org.mule.transport.jms.transformers.AbstractJmsTransformer:75 (http://www.mulesoft.org/docs/site/current3/apidocs/org/mule/api/transformer/TransformerException.html)
--------------------------------------------------------------------------------
Root Exception stack trace:
javax.jms.MessageFormatException: Invalid type passed to StreamMessage: HashMap . Allowed types are: Boolean, Byte, Short, Character, Integer, Long, Float, Double,String and byte[]
at org.mule.transport.jms.JmsMessageUtils.listToMessage(JmsMessageUtils.java:211)
at org.mule.transport.jms.JmsMessageUtils.toMessage(JmsMessageUtils.java:132)
at org.mule.transport.jms.transformers.AbstractJmsTransformer.transformToMessage(AbstractJmsTransformer.java:67)
+ 3 more (set debug level logging or '-Dmule.verbose.exceptions=true' for everything)
********************************************************************************

David Dossot

unread,
Mar 6, 2011, 10:33:30 PM3/6/11
to us...@mule.codehaus.org, a a
The transport sees a list and tries to transform it into a StreamMessage, assuming this list only contains allowed types.

In your case, this default behavior doesn't apply, so you need to help the transport a little and serialize your payload, using a standard Mule transformer, to the form you prefer (typical options are: Java serialization to bytes, XML serialization or JSON).

HTH
D.

a a

unread,
Mar 7, 2011, 3:38:26 AM3/7/11
to us...@mule.codehaus.org
Okay, thanks for your replies.

Soon,
**
Stevy

a a

unread,
Mar 7, 2011, 4:56:49 AM3/7/11
to us...@mule.codehaus.org
Oups I'm here again. "Development needs perseverance"... As I said before, I'm trying to get files from FTP, put them on ActiveMQ JMS, and from this queue insert records in database. Below is my complete configuration file. But when I stop database services, and restart after, the messages are not redelivered!

**
<?xml version="1.0" encoding="UTF-8"?>
<mule xmlns="http://www.mulesoft.org/schema/mule/core" xmlns:xsi="http://www.w3.org/2001/XMLSchema-instance"
xmlns:ftp="http://www.mulesoft.org/schema/mule/ftp" xmlns:jdbc="http://www.mulesoft.org/schema/mule/jdbc"
xmlns:stdio="http://www.mulesoft.org/schema/mule/stdio" xmlns:tcp="http://www.mulesoft.org/schema/mule/tcp"
xmlns:spring="http://www.springframework.org/schema/beans" xmlns:file="http://www.mulesoft.org/schema/mule/file"
xmlns:vm="http://www.mulesoft.org/schema/mule/vm" xmlns:jms="http://www.mulesoft.org/schema/mule/jms"
xmlns:p="http://www.springframework.org/schema/p"
xsi:schemaLocation="
http://www.mulesoft.org/schema/mule/ftp http://www.mulesoft.org/schema/mule/ftp/3.1/mule-ftp.xsd
http://www.mulesoft.org/schema/mule/file http://www.mulesoft.org/schema/mule/file/3.1/mule-file.xsd
http://www.mulesoft.org/schema/mule/jdbc http://www.mulesoft.org/schema/mule/jdbc/3.1/mule-jdbc.xsd
http://www.mulesoft.org/schema/mule/core http://www.mulesoft.org/schema/mule/core/3.1/mule.xsd
http://www.mulesoft.org/schema/mule/stdio http://www.mulesoft.org/schema/mule/stdio/3.1/mule-stdio.xsd
http://www.mulesoft.org/schema/mule/tcp http://www.mulesoft.org/schema/mule/tcp/3.1/mule-tcp.xsd
http://www.springframework.org/schema/beans http://www.springframework.org/schema/beans/spring-beans-2.5.xsd
http://www.mulesoft.org/schema/mule/vm http://www.mulesoft.org/schema/mule/vm/3.1/mule-vm.xsd
http://www.mulesoft.org/schema/mule/jms http://www.mulesoft.org/schema/mule/jms/3.1/mule-jms.xsd
http://www.springframework.org/schema/beans http://www.springframework.org/schema/beans/spring-beans-3.0.xsd">

<!--
FTP global properties
-->
<global-property name="ftp.host" value="localhost" />
<global-property name="ftp.username" value="root" />
<global-property name="ftp.password" value="pwd" />

This data source is used to connect to the database
-->
<spring:bean id="jdbcDataSource"
class="org.enhydra.jdbc.standard.StandardDataSource" destroy-method="shutdown">

<spring:property name="driverName" value="com.mysql.jdbc.Driver" />
<spring:property name="url"
value="jdbc:mysql://localhost:3306/db" />
<spring:property name="user" value="root" />
<spring:property name="password" value="pwd" />

</spring:bean>

<spring:beans>
<spring:bean id="AmqDeadLetterStrategy"
class="org.apache.activemq.broker.region.policy.IndividualDeadLetterStrategy"
p:queuePrefix="DLQ." />

<spring:bean id="AmqDefaultPolicyEntry"
class="org.apache.activemq.broker.region.policy.PolicyEntry" p:queue="jobs.*"
p:deadLetterStrategy-ref="AmqDeadLetterStrategy" />

<spring:bean id="AmqPolicyMap"
class="org.apache.activemq.broker.region.policy.PolicyMap"
p:defaultEntry-ref="AmqDefaultPolicyEntry" />

<spring:bean name="AmqBroker"
class="org.apache.activemq.broker.BrokerService" p:brokerName="esb-amq-broker"
p:persistent="true" p:dataDirectory="${activemq.data.dir}" p:useJmx="true"
p:useShutdownHook="false" p:destinationPolicy-ref="AmqPolicyMap"
init-method="start" destroy-method="stop" />

<spring:bean name="AmqRedeliveryPolicy" class="org.apache.activemq.RedeliveryPolicy"
p:useExponentialBackOff="true" />

<spring:bean name="AmqConnectionFactory"
class="org.apache.activemq.spring.ActiveMQConnectionFactory"
p:brokerURL="vm://esb-amq-broker" p:redeliveryPolicy-ref="AmqRedeliveryPolicy"
depends-on="AmqBroker" />
</spring:beans>

<jms:activemq-connector name="EsbJmsConnector" maxRedelivery="1"


specification="1.1" connectionFactory-ref="AmqConnectionFactory"
disableTemporaryReplyToDestinations="true" persistentDelivery="true">
</jms:activemq-connector>

<!--
This JDBC connector specifies the queries to run and what data source
to use.
-->
<jdbc:connector name="jdbcConnector" dataSource-ref="jdbcDataSource"
validateConnections="true">

<jdbc:query key="insertCDRIntoDB"
value="insert into cdr
(Test1, Test2, Test3)
values
(#[map-payload:Test1], #[map-payload:Test2], #[map-payload:Test3])" />

</jdbc:connector>

<ftp:connector name="FTPconnector" passive="false"
pollingFrequency="1000" validateConnections="true">
</ftp:connector>

<!--
This custom transformer will take CSV data and convert it to a map,
based on the format provided in a mapping file.
-->
<custom-transformer name="CSV2Maps"
class="com.mvno.muleesb.transformer.My_csv_to_maps_transformer" />

<model>
<service name="CSVLoaderAndInsertToDB">
<description>This flow takes CSV files from a FTP server,
parses them
and inserts them into the database.
</description>
<inbound>
<ftp:inbound-endpoint host="localhost" user="asr"
password="pwd" passive="false" port="21" path="/Path"
connector-ref="FTPconnector">

<file:filename-wildcard-filter
pattern="*.csv" />
</ftp:inbound-endpoint>
</inbound>

<outbound>
<pass-through-router>
<jms:outbound-endpoint queue="jobs.essai"
connector-ref="EsbJmsConnector" >
<jms:transaction action="ALWAYS_BEGIN"/>
<!--<xa-transaction action="ALWAYS_BEGIN"/>-->
</jms:outbound-endpoint>
</pass-through-router>
</outbound>
</service>

<service name="CSVLoaderAndInsertToDB_2">
<description>This flow takes CSV files from a FTP server,
parses them
and inserts them into the database.
</description>
<inbound>
<jms:inbound-endpoint queue="jobs.essai"
connector-ref="EsbJmsConnector" transformer-refs="CSV2Maps" >
<jms:transaction action="JOIN_IF_POSSIBLE"/>
<!--<jdbc:transaction action="ALWAYS_BEGIN" />-->
<!--<xa-transaction action="JOIN_IF_POSSIBLE"/>-->
</jms:inbound-endpoint>
</inbound>

<outbound>
<list-message-splitter-router>
<jdbc:outbound-endpoint connector-ref="jdbcConnector"
queryKey="insertCDRIntoDB">
<payload-type-filter expectedType="java.util.Map" />
<jdbc:transaction action="BEGIN_OR_JOIN" />
<!--<jms:transaction action="JOIN_IF_POSSIBLE"/>-->
</jdbc:outbound-endpoint>

<payload-type-filter expectedType="java.util.List" />
</list-message-splitter-router>
</outbound>

<!--<default-exception-strategy>
<outbound-endpoint
address="stdio://OUT" />
<vm:outbound-endpoint address="vm://esb-amq-broker"
connector-ref="vmConnector" />
</default-exception-strategy>-->

</service>
</model>
</mule>

**

How can modify this configure so as to do the inserts if the database services restart ?

Thx,

David Dossot

unread,
Mar 7, 2011, 12:13:56 PM3/7/11
to us...@mule.codehaus.org
maxRedelivery is 1, is this really what you want? Even if the exponential backoff, the whole delivery-failure-redelivery-failure will happen in a second or so. How long do you want to keep retrying until the DB comes back up? Based on that you can estimate maxRedelivery.

HTH
D.

a a

unread,
Mar 7, 2011, 3:51:20 PM3/7/11
to us...@mule.codehaus.org
Hi David... I don't have a constraint about the waiting time. I have one demand : redeliver the message as soon as DB comes back. Which value do I need to set on property : "maxRedelivery" to achieve that?

David Dossot

unread,
Mar 7, 2011, 4:00:35 PM3/7/11
to us...@mule.codehaus.org, a a
The JMS redelivery can't be tied to the DB availability. From what you're saying, I have the impression that an exponential back-off is not what you want. You'd rather configure the redelivery policy to retry, say every 60 seconds, so the "as soon as DB comes back" would be a minute at most.

a a

unread,
Mar 7, 2011, 4:21:09 PM3/7/11
to us...@mule.codehaus.org
To configure retry-policy, don't I need to necessarily use Enterprise Edition? I'm using Community Edition.

David Dossot

unread,
Mar 7, 2011, 4:32:34 PM3/7/11
to us...@mule.codehaus.org
Why do you need a retry policy? For the JDBC transport?

If that is the case, you can try the Common Retries Policies: they're not as solid as the EE ones, but they may help you.

a a

unread,
Mar 7, 2011, 4:44:30 PM3/7/11
to us...@mule.codehaus.org
"Why do you need a retry policy? " Isn't you who advise to use redelivery policy? Or did I misunderstand you??

David Dossot

unread,
Mar 7, 2011, 4:50:13 PM3/7/11
to us...@mule.codehaus.org, a a
"Why do you need a retry policy? " Isn't you who advise to use redelivery policy? Or did I misunderstand you??

Indeed, I talked about redelivery policy (the existing one in your config, ie AmqRedeliveryPolicy) while you started to talk about retry policy :)

D.

a a

unread,
Mar 7, 2011, 5:08:51 PM3/7/11
to us...@mule.codehaus.org
Ah okay, sorry... But I don't find an appropriate property to set retry to 60ms on this redelivery policy... I've tried two manners (retryLimit & sleepTime) but got an error "org.springframework.beans.NotWritablePropertyException"... Do you know which property can I set?

Thx for your replies,

David Dossot

unread,
Mar 7, 2011, 5:16:46 PM3/7/11
to us...@mule.codehaus.org, a a

a a

unread,
Mar 7, 2011, 5:45:22 PM3/7/11
to us...@mule.codehaus.org
Hi again David. Yeah, I've seen this link before, but no property was suitable for me. Or perhaps, I didn't configure appropriately... According to you, which property or which combination properties (and their values) have I to use between these properties, to achieve what I struggle to do?

**
Property Name Type Description
backOffMultiplier short
collisionAvoidancePercent short
initialRedeliveryDelay long
maximumRedeliveries int
useCollisionAvoidance boolean
useExponentialBackOff boolean
**

Thx,

David Dossot

unread,
Mar 7, 2011, 5:54:46 PM3/7/11
to us...@mule.codehaus.org
OK, so assuming ActiveMQ >= 5.4 and unlimited retries every minute, I'll try this:

maximumRedeliveries = -1
useExponentialBackOff = false
initialRedeliveryDelay = 60000
deliveryDelay = 60000

Ensure that the Mule ActiveMQ doesn't put a limit on the number of redeliveries either.

HTH
D.

a a

unread,
Mar 7, 2011, 6:52:44 PM3/7/11
to us...@mule.codehaus.org
I have ActiveMQ 5.4.2... I try your config. I think it's "redeliveryDelay" instead of "deliveryDelay"... But no re-deliveries :(

David Dossot

unread,
Mar 7, 2011, 7:03:48 PM3/7/11
to us...@mule.codehaus.org

I have  ActiveMQ 5.4.2... I try your config. I think it's "redeliveryDelay" instead of "deliveryDelay"...

Correct, sorry about that.
 
But no  re-deliveries :(

Very strange. Do you consume the queue transactionally?

a a

unread,
Mar 8, 2011, 3:17:19 AM3/8/11
to us...@mule.codehaus.org
Yeah, I think so. Below is my model :

**

</service>
</model>
</mule>
**

**

David Dossot

unread,
Mar 8, 2011, 1:19:30 PM3/8/11
to us...@mule.codehaus.org
No you don't: JOIN_IF_POSSIBLE on the JMS inbound endpoint will not start a transaction to consume messages in.

a a

unread,
Mar 8, 2011, 3:37:20 PM3/8/11
to us...@mule.codehaus.org
And what do you suggest? How can I make JMS & JDBC transactional? First, I put "ALWAYS_JOIN" but I got an error; I tried xa-transactions, but I got an error (I saw the same errors posted by other persons, but no fix).

David Dossot

unread,
Mar 8, 2011, 3:46:47 PM3/8/11
to us...@mule.codehaus.org
You need XA if you want to enroll JMS and JDBC resources in the same transaction.

If you tolerate the risk of having duplicate inserted in your DB, you can go without X and have a JMS:ALWAYS_BEGIN transaction on the JMS inbound and a JMS:ALWAYS_JOIN transaction on the JDBC outbound. If the JDBC outbound raises an exception, the JMS transaction will be rolled back. But there is a window of opportunity where the JDBC outbound works but the JMS transaction doesn't get committed, which would lead to the duplicates I mentioned.

If you want to be 100% strict, XA is the way to go.

HTH
D.

a a

unread,
Mar 8, 2011, 4:25:08 PM3/8/11
to us...@mule.codehaus.org
"If you want to be 100% strict, XA is the way to go." Yeah, theorically. I've already tried to use XA but I got an error (same error has been posted on http://forums.mulesoft.org/thread.jspa?threadID=4809&tstart=0 ).

David Dossot

unread,
Mar 8, 2011, 4:45:46 PM3/8/11
to us...@mule.codehaus.org, a a
I don't think you're using the SpringTransactionManagerFactory correctly. According to its JavaDoc it's "A holder to a transaction manager set via a Spring Application context" But I don't see the configuration of a TM with Spring beans in your config. Moreover, I don't even know if this is feasible for XA.

Reply all
Reply to author
Forward
0 new messages