• Post Reply
  • Bookmark Topic Watch Topic
  • New Topic

web services and transactions

 
Ravi Danum
Ranch Hand
Posts: 129
  • Mark post as helpful
  • send pies
  • Quote
  • Report post to moderator
Hello,

Question 1:
I have an EJB web service. If the web service is invoked from another EJB which is in the middle of a transaction, and the web service has the transaction attribute set to: TransactionAttributeType.REQUIRED, will a new transaction be created in the web service, or will the caller's transaction be used?

Question 2:
I have a servlet based web service which invokes a stateless session bean with TransactionAttributeType.REQUIRED set. If another EJB that is currently in a transaction invokes the servlet based web service, will the stateless session bean invoked by the web service always create a new transaction?

Thanks so much.

Ravi
 
Peer Reynders
Bartender
Posts: 2968
6
  • Mark post as helpful
  • send pies
  • Quote
  • Report post to moderator
Why do you think an SLSB exposed as a web service cannot support "mandatory"?

Because the transaction does not propagate over the HTTP/SOAP link.
  • "required" will always start a new transaction.
  • An SLSB being accessed as a web service is being accessed as a web service - not as an SLSB
  • An EJB client accessing a web service has no idea whether the web service is actually based on a SLSB - so EJB features don't apply.

  • See also Servlet endpoint Vs EJB endpoint
     
    Peer Reynders
    Bartender
    Posts: 2968
    6
    • Mark post as helpful
    • send pies
    • Quote
    • Report post to moderator
    Now if both ends have Project Tango installed then WS-AtomicTransaction is used to propagate transactions over the web service link. But that is a very special case...
     
    Ravi Danum
    Ranch Hand
    Posts: 129
    • Mark post as helpful
    • send pies
    • Quote
    • Report post to moderator
    Peer,

    I am deploying my web service on Glassfish which I believe has Tango. Will I have to configure it to get the behavior you mentioned? I am so glad for your response.

    Many Thanks.

    Ravi
     
    Peer Reynders
    Bartender
    Posts: 2968
    6
    • Mark post as helpful
    • send pies
    • Quote
    • Report post to moderator
    I'm not sure but I wouldn't be surprised if it is automatically active as part of WSIT on Glassfish. Something about WS-AtomicTransaction automatically working for SLSBs and that it can be used manually on servlets.

    About the basicWSTX Example

    So Glassfish-to-Glassfish and Glassfish-to-Microsoft WCF should work. But I haven't come across any evidence that either WS-AtomicTransaction or WSIT are part of Java EE 5. Though JBoss 5 seems to include WS-AtomicTransaction support.
    But it is probably safer to look at this as WS-AtomicTransaction support - not EJB transaction support - it would be surprising if things lined up perfectly.
     
    Ravi Danum
    Ranch Hand
    Posts: 129
    • Mark post as helpful
    • send pies
    • Quote
    • Report post to moderator
    Thanks, Peer. I wouldn't be aware of this without your help. There may be cases where we want the web service to be part of its caller's transaction. This is very helpful.

    Many thanks.

    Ravi
     
    It is sorta covered in the JavaRanch Style Guide.
    • Post Reply
    • Bookmark Topic Watch Topic
    • New Topic