• Post Reply Bookmark Topic Watch Topic
  • New Topic

MDB  RSS feed

Devaki Nihar
Posts: 20
  • Mark post as helpful
  • send pies
  • Quote
  • Report post to moderator
recieving JMS-messages in xml format from a JMS-Queue.
retrieving them using an MDB.
So i am processing all the xml-messages and writing the useful information from message to a File
(appending all messages info to a single file).
My question is : when i write the information from each single message to each single file,there is no
curreption in data.where as when i am writing all the messages info to a single File my data is getting
currepted.Means 2 or 3 messages when try to write the info at the same time causing curreption of data
so is it possible to synchronize this and so that i cant loose or corrept my data in the file.

I hope the MDBs in pool are trying to write the messages at same time ... as i am getting 10 messages
per second.Can anyone suggest me how i can write all of the messages with out curreption of the data ..

You seem to be trying direct file IO from an EJB. Which is not allowed.
Think about what happens when an MDB responds to a message: the message listener method in one instance
of the bean is called and starts the File IO. Then another message arrives on the Queue/Topic and
another instance of the same MDB starts trying to write to the same file. So you now have two threads
trying to write concurrently to one file.
As with any EJB, if you need access to a resource like the File System you need to do it through a JCA
Resource Adapter.
Can i have some sample code for this JCA Resource Adapter with weblogic....

JCA - J2EE Connector Architecture
JCA defines a standard architecture for connecting application server to Enterprise Information system.
e.g is JDBC

It is compatible over all application servers.
  • Post Reply Bookmark Topic Watch Topic
  • New Topic
Boost this thread!