I am developing an EJB that will be used by other components (both local and remote) to log transaction records in a database. The transaction log tables will be read later by a separate (non-EJB) billing application.
There are several logging tables involved to capture all of the necessary data. The approach I am considering is to use a stateless session bean with methods to insert records into the various tables. There are a number of fields in the tables, so I need classes to represent the data passed into these methods, but I don't think they need to be entity beans.
Is this the best approach? Any reason to use entity beans here?
The only reason to use entity EJB's I can see would be a slightly reduced development cost (if you use CMP).
A stateless session EJB would be fine, and is what I would use (I avoid entity EJB's where possible)....
Set up ValueObjects for each of your 'logging transactions'.
The only reason to use entity EJB's I can see would be a >>slightly reduced development cost (if you use CMP).
iam agree if project starts from zero...
Have you thougth about doing the log in a Mesage-driven bean?
We are evaluating to make logs with a message-driven bean, so all the parts of the application (servlets, stand-alone applications and other EJBs) only have to write over JMS.
Dou you think this can be usefull?
I think this would depend on the application, but if you use MDB, you are de-coupling the logging from the processing. This may be an advantage for some systems, but a disadvantage for others.
If the logging is an essential part of the transaction, I'd say that using an standard EJB would be preferable. If you used a MDB, how would you handle a failure?
You are right, I was thinking about some kind of stadistics about transactions, which wouldn´t be so critical.
Yo may save some time, because you wouldn´t have to wait until the log is written, you only just send the message. Would it be the performance getting better?
Thanks a lot for the feedback.
The idea of using a Message Driven bean is an interesting one, but in this case the logging is an essential piece of the transaction.
Actually, one place these logging methods will be called is from inside another Message Driven bean when a message has been received.