2 Replies Latest reply on Jan 17, 2008 3:20 PM by mjhammel

    Parallel processing in a JBoss app?

    ohako

      Hi there,

      Sorry if this is covered elsewhere (my Google skills are weak), and for not using ten-gallon words like 'application resource' and 'management interface' (I'm really a moron, y'see).

      I'm trying to launch an independant thread to do some work from inside an application servlet. In specific, I need to send emails to peopleafter they perform certain actions, but the priority of the email work is less than the priority of actually showing users stuff on my webpage. So, threading.

      This thread here:
      http://www.jboss.com/index.html?module=bb&op=viewtopic&p=4007686
      details someone else's take on the same question, and of the stern warnings the JBoss over-people made about the methods being used therein, and of the legal wrangling behind a certain JSR proposal, etc. etc.

      My two questions:
      1. The last post from this thread was in June of '07. I'm using JBoss 4.2.2 GA 'out of the box'. Has something changed here since then?
      2. Am I completely barking up the wrong tree, while there's a simple and elegant solution to managed threaded processes that's dangling just behind my crappy skills at Googling this site?


      Thanks in advance all you experienced JBossers out there!
      --------------
      Ohako

        • 1. Re: Parallel processing in a JBoss app?
          ohako

          not sure if this is allowed here...bump!

          I'm still interested to know if there's an answer, you see.

          • 2. Re: Parallel processing in a JBoss app?
            mjhammel

            I won't call myself experienced, just entagled. However, you don't want to use a separate thread here. Instead, have the incoming request/action posted to a db table and then use a Schedulable class that checks once a minute (or whatever time period you like) to see what emails need to be sent, to whom and with what content in response to the request/action. Since the email doesn't have to go out immediately, this mechanism is better suited to your needs than threads.

            I just implemented my first Schedulable and it was rather simple (though I'm using EJB3.0 I haven't got injection working so I have to get my EntityManager and it's ilk manually). Once you have the schedulable querying the db, you can probably use JMS or Java Mail to send the mail messages.

            Using a schedulable removes the need for threading in your app and leaves threading issues to the application server.

            See http://labs.jboss.com/file-access/default/members/jbossas/freezone/docs/Server_Configuration_Guide/beta422/html/Additional_Services-Scheduling_Tasks.html for more information on scheduling tasks in JBOSS.