*
The moose likes EJB and other Java EE Technologies and the fly likes Message driven bean (CMT) Big Moose Saloon
  Search | Java FAQ | Recent Topics | Flagged Topics | Hot Topics | Zero Replies
Register / Login


Win a copy of Murach's Java Servlets and JSP this week in the Servlets forum!
JavaRanch » Java Forums » Java » EJB and other Java EE Technologies
Bookmark "Message driven bean (CMT)" Watch "Message driven bean (CMT)" New topic
Author

Message driven bean (CMT)

manish gupta
Ranch Hand

Joined: Nov 06, 2005
Posts: 36
Hi,

I amd developing MDB application with container mangement transcation,do I require seperatly commit or rolledback transcation inside onMessage()?

Please guide me resolve this problem.

Thanks with regard
Manish
Amit M Tank
Ranch Hand

Joined: Mar 28, 2004
Posts: 257
You don't require to have commit code in the onMessage. If there is a RunTimeException when your code is invoked then the Transaction will automatically be rollbacked.

However, if you want to do an explicit rollback in case you encounter a checked Exception(or some business scenario where your business rules fails) then you have to use context.setRollbackOnly() in the onMessage.

Amit Tank


Amit Tank
Linked In
Joseph Sweet
Ranch Hand

Joined: Jan 29, 2005
Posts: 327
You can call messageDrivenContext.setRollbackOnly() only when you define your MDB to use bean-managed transactions.


We must know, we will know. -- David Hilbert
Amit M Tank
Ranch Hand

Joined: Mar 28, 2004
Posts: 257


You can call messageDrivenContext.setRollbackOnly() only when you define your MDB to use bean-managed transactions.



I bet its the other way. Read EJB 2.0 Specs 15.4.3 It says "Only instance of a MDB with CMT demarcation can use messageDrivenContext.setRollbackOnly()

Regards,
Amit Tank
manish gupta
Ranch Hand

Joined: Nov 06, 2005
Posts: 36
Thanks for reply,

I have another problem as I am using CMT for my MDB application.
My MDB receive message from input queue and call another classes like some helper and DAO classes and send message to another queue in single transaction.
I have created JMS QueueConnectionFactory not XA Connection factory,so I would like to know when to create QueueConnectionFactory or when to create XA Connection factory?
My Queue session not transacted sessions as
I mentioned in my code
" qsession = qcon.createQueueSession(false, Session.AUTO_ACKNOWLEDGE);"

I have created JDBC connection pool also with max capacity 25 for performence I am pumping messages into input jms queue (persistance)

by default Abandon Timeout Seconds:86400 and
Max Transactions: 10000

first
After 86400 it started giving error
<BEA-110423> <Abandoning transaction after 86,453 seconds:
Xid=BEA1-021820CE6882ED3D7FF3(8048808),Status=Committing,numRepliesOwedMe=0,numRepliesOwedOthers=0,seconds since begin=86452,seconds left=0,XAServerResourceInfo[JMS_PMTCJDBCMessageStore]=(ServerResourceInfo[JMS_PMTCJDBCMessageStore]=(state=committed,assigned=myserver),xar=JMS_PMTCJDBCMessageStore,re-Registered = true),XAServerResourceInfo[weblogic.jdbc.wrapper.JTSXAResourceImpl]=(ServerResourceInfo[weblogic.jdbc.wrapper.JTSXAResourceImpl]=(state=new,assigned=none),xar=weblogic.jdbc.wrapper.JTSXAResourceImpl@18d5ae7,re-Registered = true),SCInfo[pmtc_domain+myserver]=(state=committed),properties=({weblogic.jdbc=t3://16.138.181.4:7001}),local properties=({weblogic.transaction.recoveredTransaction=true}),OwnerTransactionManager=ServerTM[ServerCoordinatorDescriptor=(CoordinatorURL=myserver+16.138.181.4:7001+pmtc_domain+t3+, XAResources={JMS_FileStore, weblogic.jdbc.wrapper.JTSXAResourceImpl, JMS_PMTCJDBCMessageStore},NonXAResources={})],CoordinatorURL=myserver+16.138.181.4:7001+pmtc_domain+t3+)>

I don't understand why it is giving error like that.
Please tell me is there any problem?

Thanks with regard
Manish
Amit M Tank
Ranch Hand

Joined: Mar 28, 2004
Posts: 257
If you have multiple resource particiapting in the transaction then you need to have XA Connection factory and XA Driver for DB connection pool for two phase commit.
 
I agree. Here's the link: http://aspose.com/file-tools
 
subject: Message driven bean (CMT)
 
Similar Threads
System Exceptions Doubt
part ii transcation question
Transaction Problem
big doubt HFE page 483 'Suspend a transaction'
Transcation basic