File APIs for Java Developers
Manipulate DOC, XLS, PPT, PDF and many others from your application.
http://aspose.com/file-tools
The moose likes EJB and other Java EE Technologies and the fly likes MDB Big Moose Saloon
  Search | Java FAQ | Recent Topics | Flagged Topics | Hot Topics | Zero Replies
Register / Login
JavaRanch » Java Forums » Java » EJB and other Java EE Technologies
Bookmark "MDB" Watch "MDB" New topic
Author

MDB

Devaki Nihar
Greenhorn

Joined: Apr 30, 2005
Posts: 20
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.
 
I agree. Here's the link: http://aspose.com/file-tools
 
subject: MDB
 
Similar Threads
MDBs are not necessarily asynchronous, are they?
MDB pulling messages using the same Timestamp for requeu and exception queue
Help required on how to use JCA with JMS.
JCA JMS simple example
MDB2.0 stoped listing to WebSphere Queue