Bug 974980 - Transaction handling is broken when calling a service from Camel component
Summary: Transaction handling is broken when calling a service from Camel component
Keywords:
Status: CLOSED CURRENTRELEASE
Alias: None
Product: JBoss Fuse Service Works 6
Classification: JBoss
Component: SwitchYard
Version: 6.0.0 GA
Hardware: Unspecified
OS: Unspecified
unspecified
high
Target Milestone: ER1
: 6.0.0
Assignee: Keith Babo
QA Contact: Jiri Pechanec
URL:
Whiteboard:
Depends On:
Blocks:
TreeView+ depends on / blocked
 
Reported: 2013-06-17 10:06 UTC by Jiri Pechanec
Modified: 2014-06-16 23:53 UTC (History)
2 users (show)

Fixed In Version:
Clone Of:
Environment:
Last Closed:
Type: Bug
Embargoed:


Attachments (Terms of Use)
Reproducer (18.39 KB, application/x-compressed-tar)
2013-06-18 03:39 UTC, Jiri Pechanec
no flags Details


Links
System ID Private Priority Status Summary Last Updated
Red Hat Issue Tracker SWITCHYARD-1550 0 Blocker Closed SwitchYardProducer does not prune transient context properties in camel routes 2014-06-16 23:53:31 UTC

Description Jiri Pechanec 2013-06-17 10:06:12 UTC
The issue is present when there is a Camel-implented service C.

Form this service call a service S that has managedTransaction.Global policy set.

The call then fails with Required policies have not been provided: managedTransaction.Global

The problem is that when TransactionHandler is executed for the service S it goes through handleAfter method instead of handleBefore.

It seems that when service C goes through transaction handler handleBefore then it sets org.switchyard.exchange.transaction.beforeInvoked on SY exchange.

When SwitchYardProducer.process prepares to call the service S it creates a new SY exchange. This exchange has context properties that were obtained from CamelExchange (and SY exchange for service C).

So, the property org.switchyard.exchange.transaction.beforeInvoked is set to true on newly create exchange and when the service is invoked then the trascation handler goes through the wrong phase and required policies are thus not provided.

Comment 1 Keith Babo 2013-06-17 11:11:16 UTC
Can you attach an app to reproduce this and also provide the error / stack trace you are seeing for the failure?

Also, which build is this?  Alpha1?

Comment 2 Jiri Pechanec 2013-06-18 03:39:55 UTC
Created attachment 762276 [details]
Reproducer

The issue is present in DR5

Rproducer is based on the QA camel-service. I added one bean service TransactionalServiceBean. The test works if the service is not marked as requires="managedTransaction.Global". When the policy is added (as is now) It throws an exception - about required policy,

Comment 3 Keith Babo 2013-06-21 02:30:32 UTC
Awesome catch on this issue.  Chances are good we would have missed this for 1.0 Final if you didn't find it.

SwitchYardProducer, which is used to handle switchyard:// endpoints in a Camel route, is propagating context properties with a label of TRANSIENT which should not happen.  This is definitely a bug and will be fixed for SY 1.0.0.Final.

IMO, I don't think this is a blocker for Alpha2 as it is confined to cases where multiple services are called from a Camel route with policy configured on the invoked service.  I should mention there is a workaround available which involves adding a bean to your camel route to manually prune the offending context properties:

@Named("PolicyCleanup")
public class CleanContext {

  public void clean(Exchange exchange) {	   
    exchange.removeProperty("org.switchyard.exchange.transaction.initiated");
  }
}

public void configure() {
        from("switchyard://JavaDSL")
            .log("Message received in Java DSL Route")
            .log("${body}")
            .to("switchyard://TransactedService")
            .beanRef("PolicyCleanup")
            .split(body(String.class).tokenize("\n"))
            .to("switchyard://XMLService?operationName=acceptMessage");
    }

This workaround is not ideal, obviously, but I think it's a minor annoyance for Alpha2 users.  The fix for this is reasonably small, so we could consider delivering this as a patch on top of Alpha2 if it causes big trouble.  This will be fixed in SY 1.0.0.Final and available in Beta builds for customers.

Comment 5 JBoss JIRA Server 2013-06-27 19:41:08 UTC
Keith Babo <kbabo> made a comment on jira SWITCHYARD-1550

pushed

Comment 6 Jiri Pechanec 2013-09-18 12:11:22 UTC
Verified in ER2

Comment 10 JBoss JIRA Server 2014-06-16 23:53:32 UTC
Keith Babo <kbabo> updated the status of jira SWITCHYARD-1550 to Closed


Note You need to log in before you can comment on or make changes to this bug.