BorlandTalk.com Forum Index BorlandTalk.com
Borland discussion newsgroups
 
Archives   FAQFAQ   SearchSearch   MemberlistMemberlist   UsergroupsUsergroups   RegisterRegister 
 ProfileProfile   Log in to check your private messagesLog in to check your private messages   Log inLog in 

transaction in mdb

 
Post new topic   Reply to topic    BorlandTalk.com Forum Index -> JBuilder Enterprise
View previous topic :: View next topic  
Author Message
zbcong
Guest





PostPosted: Sat Aug 23, 2003 9:33 am    Post subject: transaction in mdb Reply with quote




hello
i write a message driven bean,that monitor the weblogic message queue,when a "Order" object is witten to the queue,the mdb get it and write it to a entity bean "Orderinfo".all of above logic is within the "onMessage" method of the mdb.
i want to encapsulate the flow in a transaction,see my code snippet of the onMessage method:


ObjectMessage objMsg = (ObjectMessage) msg;
OrderVO orderVO = (OrderVO) objMsg.getObject();
System.out.println(orderVO.booklist);
OrderinfoHome orderinfoHome = (OrderinfoHome) ctx.lookup(
"java:/comp/env/orderinfo");
Orderinfo orderinfo = orderinfoHome.create(orderVO.orderID);
orderinfo.setAddress(orderVO.address);
orderinfo.setCustname(orderVO.custName);
orderinfo.setEmail(orderVO.email);
orderinfo.setBooklist(orderVO.booklist);
orderinfo.setPrice(new BigDecimal(orderVO.price));


and deploy descriptor snippet(ejb-jar.xml):


<assembly-descriptor>
.............
............

<container-transaction>
<method>
<ejb-name>orderMDB</ejb-name>
<method-name>*</method-name>
</method>
<trans-attribute>Required</trans-attribute>
</container-transaction>
</assembly-descriptor>


i think during this transaction,there are two action:geting the object from the queue and saving it to entity bean.in order to test the transaction,i modify the jndi name of entity bean in the code to a WRONG one.redeploy my program,and send a message to the queue,the mdb is activated,then the exception is thrown because of the wrong jndi name.after that,i check the message queue,find that it is empty.why?i think if the second action of the transaction is fail,the transaction should roll back,the message should be send BACK to the queue.

i also ty to use the "javax.transaction.UserTransaction" in the onMessage method,but the follwing exception is thrown:

javax.transaction.NotSupportedException: Another transaction is associated with this thread.................................

who can help me,if any wrong with me,and how to use the transaction with the message driven bean?

thank you.



Back to top
Post new topic   Reply to topic    BorlandTalk.com Forum Index -> JBuilder Enterprise All times are GMT
Page 1 of 1

 
 


Powered by phpBB © 2001, 2006 phpBB Group
.