-
1. Re: Newbie: how to interface EJB code with external librarie
itsme Aug 6, 2008 4:00 AM (in response to nopik)Well let's try to answer that.
Think of EJB's as a facade in front of any complex functionality that should be executed remote and/or local with transactions and in a multi user environment. Stateless and stateful session beans are doing something for you while entities (pre EJB 3.0 entity beans) are business object which (mostly) get stored into a database.
So for example you can write a (stateful) session bean that manages the login and logoff off users. So here is the (at least for me) very simple hint for using EJB's: Keep things simple. Each ejb must have its own clear context.
For transactions (I think transactions are important for a trade system) there is nothing to do. You get them right out of the box if you're using container managed transactions.
For the ui by using jsf I personally prefer having one backing bean for one screen (i.e. login/logoff-ui). This backing bean can delegate its work to a ejb (that login facade mentioned above).
To concluse I would recommend to analyse the system carefully and do design the new app by using a combination of JSF and EJB.
Hope this helps in a way.
Regards
\sandor\ -
2. Re: Newbie: how to interface EJB code with external librarie
nopik Aug 9, 2008 5:30 PM (in response to nopik)First of all, thanks for the reply, it has been insightful, really.
Unfortunately it do not answer my main concern - how to interface with external libraries. In meantime I am progressing with reading the mentioned book, and I am after chapter describing JMS basics. I thought, that it provides solution to my problem.. I was thinking about something like this:
Right now I do link with some external jar and create one of its objects, lets call it Server. This object does internally open some sockets, run threads and so on, all hidden from me. Then, I register listener on its events and eventually start receive events by my listeners. In meantime I call some methods there to invoke some operations. While I call like up to 100 methods per second, I need to receive like 1000+ events per second, all from external thread.
Now, how should I approach this specific problem (being abstract from jsf etc. for a moment)?
I thought I will use JMS. Actually, it do give me all required functionality. I just create two message channels and create standalone application outside of JBoss to interface with my library. The events from the lib will be converted to JMS message, so would be my calls (well, ok I would end up reinventing RMI, nevermind, in theory I would be able to call RMI one side and get JMS in the other direction). But, when I made some quick tests (based on exercises from the book), the amount of overhead is overwhelming (well, 2 separate java vm processes communicating via tcp cannot be so fast): I was able to process like 40 messages per second on my machine. So, about 20-30 times slower than I need. Not to mention, that current, 'native', solution does not use more than 10% cpu... So, is there any better way of solving my problem? -
3. Re: Newbie: how to interface EJB code with external librarie
nopik Aug 9, 2008 5:38 PM (in response to nopik)Well, actually being able to run my code inside JBoss vm, but outside of any bean, could get enough speed, even with usage of jms (just by reduction of tcp connection and replacing it with local). This is definitely possible, as I can do that as Tomcat servlet (i.e. servlet which does use external libraries and communicates with it heavily). Is there simple method of putting such code to JBoss?