Win a copy of Programmer's Guide to Java SE 8 Oracle Certified Associate (OCA) this week in the OCAJP forum!
  • Post Reply
  • Bookmark Topic Watch Topic
  • New Topic

Message driven bean (CMT)

 
manish gupta
Ranch Hand
Posts: 36
  • Mark post as helpful
  • send pies
  • Quote
  • Report post to moderator
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
Posts: 257
  • Mark post as helpful
  • send pies
  • Quote
  • Report post to moderator
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
 
Joseph Sweet
Ranch Hand
Posts: 327
  • Mark post as helpful
  • send pies
  • Quote
  • Report post to moderator
You can call messageDrivenContext.setRollbackOnly() only when you define your MDB to use bean-managed transactions.
 
Amit M Tank
Ranch Hand
Posts: 257
  • Mark post as helpful
  • send pies
  • Quote
  • Report post to moderator


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
Posts: 36
  • Mark post as helpful
  • send pies
  • Quote
  • Report post to moderator
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
Posts: 257
  • Mark post as helpful
  • send pies
  • Quote
  • Report post to moderator
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.
 
  • Post Reply
  • Bookmark Topic Watch Topic
  • New Topic