I need to perform a distributed transaction in My Servlet.
My distributed transaction involves Updating to the DB and also publishing a message to a queue.
The queue is not present in my app server, where my Servlet is running.
It is there on a remote machine.
I'm using below code to achieve the same.
But I'm not getting the transactional behaviour working... That means
If I publish a message to queue and then if DB Operation fails, the transaction should roll back and the queue should not be having any contents.
But my queue is still showing me the contents...
1. use the XA versions of the implementations.
2. make sure you are using an XA driver.
3. Do not specify a transacted session..JTA user transactions are ignored by transacted sessions and you cannot include other resources in transactions when you use a transacted session for jms. Specify false in the first arg to connection.createSession() method.
The original code will not even compile. There is no publishMessage() method that accepts a bolean var.
For example
ram.
Bahadur Shah
Greenhorn
Joined: Feb 20, 2007
Posts: 18
posted
0
I tried using false to not to use transacted session. But am still getting the same error
My code is like below. I am clueless what is missing.
I am using SAP NetWeaver Application Server
In my below code, Even after I rollback my JTA UserTransaction, the JMS operations are not rolling back.
Jimmy Clark
Ranch Hand
Joined: Apr 16, 2008
Posts: 2187
posted
0
Any glitches in my code???
I would say there is a "glitch" in your design. Stuffing all of this transactional code in a servlet is questionable and in conflict with standard three-tier programming model.
Presentation tier
Business tier
Integration tier
Java servlets are for handling Presentation-oriented requirements via web server. Cramming business logic/data logic/transactional logic into servlet classes typically is not a very good design for anything mildly complex, e.g. distributed transactions.
Bahadur Shah
Greenhorn
Joined: Feb 20, 2007
Posts: 18
posted
0
I created this test servlet just to test the application and do a POC