I have an architecture type question for an EJB 3.0 app.
Currently, I have an session bean that runs on a time. Every X minutes it wakes up and does the following.
1. Reads some records from a database.
2. Loops through each record
While looping through each record it:
1. Makes a connection to web server A to download information.
2. Makes a connection to web server B to deliver information.
3. Updates record
This works fine when the number of records is relatively low. But I'm looking for a better way to be able to scale the application. The number of records that need to be processed in each cycle is growing and can result in more work in the allotted time. The bottleneck is the communication between web server A and B, there is little computational processing going on. So I need to be able to process multiple records simultaneously, but at the same time make sure that the same record isn't processed more than once.
I'm fairly new to EJB design, so am looking for some suggestions.
One thought I had was to move the work done in the loop into a message bean. Meaning the timer just reads the database records and fires off a message for each record to be processed. But I'm not sure how the server would actually handle this. Would it process multiple messages simultaneously? I think it would. If so, does it have a queuing mechanism or would it try to process them all at once? I want to have this done as quickly as possible but not bring the server to its knees. Would I be able to poll to see if my messages have completed or not? I'd want to avoid sending duplicate messages (i.e. Avoid a timer firing a second time that sends off the same records to be processed that are currently in the server's message queue).
Thoughts, suggestions or recommended documentation is appreciated. I have a few books, but they cover things at a lower level and don't get into recommended design.
No problem, I appreciate the help. I've been away myself as well.
I've made some progress in reproducing, the problem, although I'm still without a solution. The other server was running 4.0.5GA, where I had 4.0.4GA. I installed 4.0.5GA and now mirror the problem on my local PC.
Nothing about my app shows up in the java: Namespace or Global JNDI Namespace when deployed as an ear (same file deployed in both versions), but I do see it listed under Web Applications.
The output from JBoss after I deploy the app is below. Are there new deployment requirements for the later version of JBoss?
I just found out that this is the first application deployed on this server that makes use of EJBs. Can anyone recommend any kind of official JBoss reference ear I could have them test to make sure the server is working?
Something simple that works in JBoss and involves JSPs talking to an EJB so we can verify that the server is working ok.
I'm stuck on this issue again. I did get this working on a JBoss server running on my PC, when I tried to deploy it to a production server I'm facing the same error again. But this time, nothing related to my app shows up in the Global JNDI Namespace. The JBoss version is the same, the only difference is that server is a 2 server cluster. Does that setup require different configuration of my app?
I have created some EJBs that are packaged in a jar, and jsp pages that are packaged in a war. If I deploy them the JBoss they work fine.
My problem comes when I try to package them both together in a ear file. JBoss seems like it is deploying both files from the ear, but none of my jsp pages can access the EJBs. I'm connecting through the local interface using:
Context ic = new InitialContext(); Object o = ic.lookup("UserManagerBean/local");
When I try this, I get this exception:
javax.naming.NameNotFoundException: local not bound
I've also found that if I copy the ear and jar file, everything works. So for whatever reason the jsp pages can't access the EJBs when they are packaged in the ear file.
This is the first ear file I've tried to create, so I'm probably doing something wrong there. I've searched around and found lots of docs about the ear spec, but not many examples. Can anyone help? Thanks!
I finally did get this to work how I wanted. I removed all references to EntityManager from my bean with the loop. I then set the method that creates the log entry to require a new trascation. This wrote out the database entry right away, but my loop still timed out writting to Oracle. To fix that problem I specified that the method that contains the loop does not support transaction, so JBoss doesn't try to do it all in a single transaction. Since I didn't have any reference to EntityManager anymore, JBoss was fine with that method not supporting transactions.
The Message bean idea didn't work either... JBoss is still forcing my method to use a transaction, so I'm back to square 1. Actually, I'm 2 steps back now. After testing with larger data sets, meaning my loop runs longer, I'm getting commit timeouts writing to Oracle. So none of the data is being commited.
There has to be a way to tell EJB/JBoss to commit now, or else how does anyone handle a long running batch operation?