Using an XML file to initialize a MessageDrivenBean
1 posts in topic
Flat View  Flat View
TOPIC ACTIONS:
 

Posted By:   Noah_Nordrum
Posted On:   Sunday, September 9, 2001 10:08 PM

I have a MDB that is used to asyc-process events. I have an XML file that contains all the information on how the MDB is supposed to respond to the different types of messages. I was wondering what is "the best(tm)" way to have the MDB read in the XML and maintain it through the life of the bean (obviously you don't want to be reading in a 50k XML file on every onMessage call)? I thought of the following: Read in from an app-client(or a servlet) and place a Snapshot of the data in JNDI use getSystemResourceAsStream and put it in the same classpath as the MDB ditch the XML and persist all the data as CMP/BMP EJB I'm not really thrilled with any of the   More>>

I have a MDB that is used to asyc-process events. I have an XML file that contains all the information on how the MDB is supposed to respond to the different types of messages. I was wondering what is "the best(tm)" way to have the MDB read in the XML and maintain it through the life of the bean (obviously you don't want to be reading in a 50k XML file on every onMessage call)?



I thought of the following:



  1. Read in from an app-client(or a servlet) and place a Snapshot of the data in JNDI

  2. use getSystemResourceAsStream and put it in the same classpath as the MDB

  3. ditch the XML and persist all the data as CMP/BMP EJB



I'm not really thrilled with any of these, but I like #1 the best by far. #4 is a little iffy because you have to deal with the appserver's classloader.



Any ideas? :)





Noah Nordrum

Java is my "Weapon of Choice"    <<Less

Re: Using an XML file to initialize a MessageDrivenBean

Posted By:   Joseph_Ottinger  
Posted On:   Thursday, September 13, 2001 11:05 AM

The more I think about it... #1 should refer to a URI, not a filesystem entry, at the very least. But that implies I/O, which EJBs shouldn't be doing.

#3 sounds bad just because it's... I don't know, something about it revolts me, and #4 revolts me slightly more.

#2 has a lot of advantages; it's EJB-spec-compliant, for one thing, and if an MDB doesn't find the required data it can throw an exception to indicate initialization hasn't occurred yet. As a result, the application can transact the message until it can be dealt with properly, perhaps. It's a little more work to write (a tiny bit!) but that shouldn't be too much of a problem.

About | Sitemap | Contact