You are viewing a plain text version of this content. The canonical link for it is here.
Posted to users@servicemix.apache.org by David Holroyd <da...@badgers-in-foil.co.uk> on 2007/10/30 01:32:06 UTC

Handling unreliable binding components

I've got a library implementing a communication protocol for talking to a
remote service.  I'd like to add some degree of reliability to this.  I
don't care about duplicate messages, as long as messages get through,
and in the order sent by my app.

I've think I can do this by building a Binding Component for the
protocol, and deploying Service units for,

 a) an instance of my new binding component
 b) JMS, to allow local apps to talk to the component


I've done the above, but so far, I've not got any of the reliability I
want.  Hunting around in the list archives, it looks like the way to do
this would be to have the BC rollback any current transaction on
failure, but I'm not sure how to make the JMS stuff be transacted.

Am I going in the right direction?  Docs I should look at?


thanks!
dave

-- 
http://david.holroyd.me.uk/

Solved: Handling unreliable binding components

Posted by David Holroyd <da...@badgers-in-foil.co.uk>.
On Thu, Nov 01, 2007 at 10:14:57PM +0000, David Holroyd wrote:
> On Thu, Nov 01, 2007 at 12:18:41AM +0000, David Holroyd wrote:
> > I see this example referenced from the servicemix-jms docs,
> > 
> >   http://svn.apache.org/viewvc/incubator/servicemix/trunk/deployables/bindingcomponents/servicemix-jms/src/test/resources/org/apache/servicemix/jms/spring-jca.xml?revision=HEAD
> > 
> > but this seems to be a configuration for an embedded servicemix, rather
> > than something I can plonk into my SU xbean.xml (?)

> I see that the underlying cause is,
> 
>   java.lang.IllegalStateException: Cannot log transactions unles
>   XAResources are named!

So after googling this a bit more, I saw this issue,

  https://issues.apache.org/activemq/browse/SM-778

and reading the diff prompted me to use synchronous="true" on the JMS
endpoint.  This seems to make things work much better!

I also changed my xbean.xml to use refs to things in JNDI, rather than
constructing new beans in the SU (required some additions to the
servicemix conf/jndi.xml).

This is my xbean.xml now, for reference,

----8<----
<beans xmlns:clientsupplier="urn:client:supplier"
       xmlns:jms="http://servicemix.apache.org/jms/1.0"
       xmlns:jencks="http://jencks.org/2.0"
       xmlns:amqra="http://activemq.org/ra/1.0"
       xmlns:jee="http://www.springframework.org/schema/jee"
       xmlns:xsi="http://www.w3.org/2001/XMLSchema-instance">

  <jms:endpoint service="clientsupplier:jms"
                endpoint="endpoint"
                targetService="clientsupplier:service"
                defaultMep="http://www.w3.org/2004/08/wsdl/in-only"
                role="consumer"
                destinationStyle="queue"
                processorName="jca"
                bootstrapContext="#bootstrapContext"
                connectionFactory="#connectionFactory"
                resourceAdapter="#resourceAdapter"
                synchronous="true">
    <jms:activationSpec>
       <amqra:activationSpec destination="supplier/subscribe"
                             destinationType="javax.jms.Queue"/>
    </jms:activationSpec>
  </jms:endpoint>

  <jee:jndi-lookup id="resourceAdapter"
                   jndi-name="java:comp/env/smx/ResourceAdapter"/>
  <jee:jndi-lookup id="connectionFactory"
                   jndi-name="java:comp/env/smx/ConnectionFactory"/>
  <jee:jndi-lookup id="bootstrapContext"
                   jndi-name="java:comp/env/smx/BootstrapContext"/>
</beans>
---->8----


ta,
dave

-- 
http://david.holroyd.me.uk/

Re: Handling unreliable binding components

Posted by David Holroyd <da...@badgers-in-foil.co.uk>.
On Thu, Nov 01, 2007 at 12:18:41AM +0000, David Holroyd wrote:
> On Tue, Oct 30, 2007 at 12:32:06AM +0000, David Holroyd wrote:
> 
> > I've done the above, but so far, I've not got any of the reliability I
> > want.  Hunting around in the list archives, it looks like the way to do
> > this would be to have the BC rollback any current transaction on
> > failure, but I'm not sure how to make the JMS stuff be transacted.
> 
> I see this example referenced from the servicemix-jms docs,
> 
>   http://svn.apache.org/viewvc/incubator/servicemix/trunk/deployables/bindingcomponents/servicemix-jms/src/test/resources/org/apache/servicemix/jms/spring-jca.xml?revision=HEAD
> 
> but this seems to be a configuration for an embedded servicemix, rather
> than something I can plonk into my SU xbean.xml (?)
> 
> I tried a bit of cut'n'paste in the dark, but the result is no messages
> arriving at the Binding Component any more, and no errors logged
> anywhere.


So I enabled DEBUG loggin for "org.apache.activemq", and see,

  INFO  - ServerSessionImpl:2            - Endpoint failed to process
  message. Reason: java.lang.RuntimeException: Endpoint after delivery
  notification failure

running in the debugger, I see that the underlying cause is,

  java.lang.IllegalStateException: Cannot log transactions unles
  XAResources are named!
  org.apache.activemq.ra.LocalAndXATransaction@1b10e9e

this happens over here,

  org.apache.geronimo.transaction.manager.TransactionImpl$TransactionBranch.getResourceName(TransactionImpl.java:716)
  org.apache.geronimo.transaction.log.HOWLLog.prepare(HOWLLog.java:254)
  org.apache.geronimo.transaction.manager.TransactionImpl.internalPrepare(TransactionImpl.java:443)
  org.apache.geronimo.transaction.manager.TransactionImpl.commit(TransactionImpl.java:315)
  org.apache.geronimo.transaction.manager.TransactionManagerImpl.commit(TransactionManagerImpl.java:264)
  org.jencks.XAEndpoint.afterDelivery(XAEndpoint.java:105)


Any simple way to make it happy?


Here is my xbean.xml,

<beans xmlns:custsupplier="urn:cust:supplier"
       xmlns:jms="http://servicemix.apache.org/jms/1.0"
       xmlns:jencks="http://jencks.org/2.0"
       xmlns:amqra="http://activemq.org/ra/1.0"
       xmlns:xsi="http://www.w3.org/2001/XMLSchema-instance">

  <jms:endpoint service="custsupplier:jms"
                endpoint="endpoint"
                targetService="custsupplier:service"
                defaultMep="http://www.w3.org/2004/08/wsdl/in-only"
                role="consumer"
                destinationStyle="queue"
                processorName="jca"
                bootstrapContext="#bootstrapContext"
                connectionFactory="#connectionFactory"
                resourceAdapter="#resourceAdapter"
                synchronous="false">
  <jms:activationSpec>
     <amqra:activationSpec destination="supplier/subscribe"
                           destinationType="javax.jms.Queue" />
  </jms:activationSpec>


  </jms:endpoint>

  <amqra:managedConnectionFactory id="activemqMCF"
                                  resourceAdapter="#resourceAdapter"/>
  <amqra:resourceAdapter id="resourceAdapter"
                         serverUrl="tcp://127.0.0.1:61616?jms.asyncDispatch=true&amp;jms.useAsyncSend=true"/>
  <jencks:connectionFactory  id="connectionFactory"
                             managedConnectionFactory="#activemqMCF"
                             connectionManager="#connectionManager" />

  <!-- Transaction manager -->
  <jencks:transactionManager id="transactionManager"/>

  <!-- Work manager -->
  <jencks:workManager id="workManager"
                      transactionManager="#transactionManager"/>
  
  <!-- Bootstrap context for JCA -->
  <jencks:bootstrapContext id="bootstrapContext"
                           workManager="#workManager"
                           transactionManager="#transactionManager"/>
  
  <!-- Connection manager for JCA -->
  <jencks:connectionTracker id="connectionTracker"
                            geronimoTransactionManager="#transactionManager"/>
  <jencks:poolingSupport id="poolingSupport"
                         allConnectionsEqual="false"/>
  <jencks:connectionManager id="connectionManager"
                            containerManagedSecurity="false"
                            transaction="xa"
                            transactionManager="#transactionManager"
                            poolingSupport="#poolingSupport"
                            connectionTracker="#connectionTracker"/>

</beans>



ta much!
dave

-- 
http://david.holroyd.me.uk/

Re: Handling unreliable binding components

Posted by David Holroyd <da...@badgers-in-foil.co.uk>.
On Tue, Oct 30, 2007 at 12:32:06AM +0000, David Holroyd wrote:

> I've done the above, but so far, I've not got any of the reliability I
> want.  Hunting around in the list archives, it looks like the way to do
> this would be to have the BC rollback any current transaction on
> failure, but I'm not sure how to make the JMS stuff be transacted.

I see this example referenced from the servicemix-jms docs,

  http://svn.apache.org/viewvc/incubator/servicemix/trunk/deployables/bindingcomponents/servicemix-jms/src/test/resources/org/apache/servicemix/jms/spring-jca.xml?revision=HEAD

but this seems to be a configuration for an embedded servicemix, rather
than something I can plonk into my SU xbean.xml (?)

I tried a bit of cut'n'paste in the dark, but the result is no messages
arriving at the Binding Component any more, and no errors logged
anywhere.

Is it reasonable / possible to enable transacted JCA processing in a
service unit's xbean.xml, or will this only be possible by 'static
configuration' (if I understand the term correctly)?


ta!
dave

-- 
http://david.holroyd.me.uk/