8 Replies Latest reply on Feb 13, 2009 7:23 PM by danteconsales

    Seam and Multithread: How ?

    pedrosena

      Hi Guys,


      I have a big problem in hands.


      I need to make use of Seam in a multithreaded way (in JEE).


      I know that multithread and JEE are two things that do not play well, so I tried the JMS approach.


      Now I noticed that in JMS I can't use Conversation/Session Scopes.


      I don't know what else can I do to achieve this objective.


      Is it impossible?


      Any advices, tips are welcome.


      Thanks,


      Pedro Sena


        • 1. Re: Seam and Multithread: How ?
          danteconsales

          hi, can you please explain some details of your context and components?

          • 2. Re: Seam and Multithread: How ?
            pedrosena

            Sure,


            I have a webapp that consumes a lot of webservices(something like 10 today).


            I need to consume all those webservices and display the result to my end user.


            Making it sequentially results in a delay of (more or less) 10/13 minutes to display the result.


            Making it concurrently results in  1,5 minute. What is very acceptable in this context.


            I tried common multithread in JEE environment(bad idea) just to get the results. Worked but I lost the session context that is necessary to parse the results from webservices.


            I tried also a JMS approach, but I lost the Seam contexts this way, what makes impossible the parse of my response.


            Know I don't know what to do :(


            Thanks


            • 3. Re: Seam and Multithread: How ?
              danteconsales

              Make stateless session bean, which has access to jboss cache, place in to jboss cache a object that represents data that you will show as result.
              start every x times a jms action to consume services and inject about abve described ejb session bean result to the jboss cache...
              you can consume in seam the jboss cache an show result...


              do this way help you?

              • 4. Re: Seam and Multithread: How ?
                pedrosena

                Hmmm,


                It's a good idea, but it does not apply to my scenario.


                I need to consume the webservice with very specific parameters, informed by the user, so I need to consume it when my user inputs some parameter, the idea of cache the results from WS is not an option here.


                I think that I will try to pass as parameter anything that I need from Seam than make the multithread in the standard(but not recommended) way.


                This away, passing all I need as parameter, I do not need to access seam contexts to get this variables.


                I'm not very happy with this solution, so I would like to hear more opinions.


                Thanks Konstantin,


                Pedro Sena

                • 5. Re: Seam and Multithread: How ?
                  giomiano

                  If you cannot cache, 3 points..


                  1) I would work on how produce the report to optmize the response
                  2) I would start to think to profile jboss
                  3) I would loadbalance with apache


                  my 2 cent

                  • 6. Re: Seam and Multithread: How ?
                    pedrosena

                    Hi Giovanni,


                    First of all, thanks for your reply.


                    I will tell the real scenario to make thing more clear.


                    I'm creating an air-tickets reservation system that integrates a couple of differentes air lines services(actually 10, but we will expand to more).


                    The time to create the object to be sent is minimal, my problem is making sequential calls to these webservices, some of them take more than 45 seconds to respond.


                    The problem is not making the request, neither parse the response, but the time to the webservice(external, not under my control) to respond.


                    For this reason I choose to use multithread.


                    Regards,


                    Pedro Sena


                    • 7. Re: Seam and Multithread: How ?
                      danteconsales

                      maybe you can use seam remote and fire all methods asynchronous  at the firing moment you can register the event in a data structure like hash in java script and check if all request are ready... if all requests are ready go on...

                      • 8. Re: Seam and Multithread: How ?
                        danteconsales

                        not dice... i think this way is not thread save...