Forums Register Login

Transactions in message driven beans

+Pie Number of slices to send: Send
HI, Im using java ee 5. i want to send database inserts to the database throught a message queue to ensure the order of insertions.


clients invokes a stateful session bean to send the data. and the bean will access the message driven bean which is responsible for the actual db insert. all the calls through a single stateful bean is in one transaction. if one of the inserts fail the transaction should rollback.

but the problem im facing here is the SQL connection used to the updates cannot be passed from the session bean to the message driven bean since the conncetion is not serializable.

Can any one help me with a solution to this problem.
+Pie Number of slices to send: Send
Hi Lahiru Abeydeera

Well, here i m not clear why you want to pass sql connection to MDB. Can't you just create a new connection through MDB or use a datasource(through dependency injection) to update the values in DB.

Do let me know if you have any problem in this way...

Cheers !!!
Sumit
+Pie Number of slices to send: Send
i want to pass the connection because i want to maintain the transaction. thats why the session has to pass the connection to the MDB. is there any other better way of doing this?

thaks for the interest.
+Pie Number of slices to send: Send
Hey Lahiru Abeydeera

I do believe that you must be doing your business implementation in this way

1. From stateful session bean you are just calling message driven bean and in MDB using entity manager(or datasource) you are inserting new values to DB.
2. For updation same way you are folowing...

Well, if you are invoking entity manager(or by datasource) through MDB then i dont believe there is any problem because i hope you are making you business method's with MANADATORY transaction attribute there itself...
If you are following above then i dont see you have to pass sql connection to MDB because you are creating it in MDB itself.

So just do DB specific operation(invocation of SQL connection,create,update,delete operation) in MDB and let the session bean talk to MDB..


Do let me know if i have got to your point or you can post your code snippet so that i can have a look on it.

Cheers,
Sumit
I can't beleive you just said that. Now I need to calm down with this tiny ad:
a bit of art, as a gift, the permaculture playing cards
https://gardener-gift.com


reply
reply
This thread has been viewed 960 times.
Similar Threads
Should the cache/DB and the reformat message be part of the same transaction?
tough questions on beans and others
overloading ejbCreate() methods
Transaction across methods in Entity Beans?
Stateless session bean with CMT, sending JMS message on commit
More...

All times above are in ranch (not your local) time.
The current ranch time is
Apr 16, 2024 10:07:13.