1 2 Previous Next 16 Replies Latest reply on Mar 5, 2004 7:20 AM by adrian.brock

    Interesting question: launched SFSB from MDB

    norrin88

      Hello. I have launched a method from an activated Stateful Session Bean (SFSB) from the onMessage method of a Message Driven Bean (MDB). The SFSB was retrieved from a message with getObject(). Although this is working like a rock, I would like to be able to stop this SFSB. Since MDB is stateless, I cannot store the SFSB and cannot invoke remove(). I have tried to keep the reference of the SFSB in a separate Entity Bean, and I can remove it, but it seems that JBoss creates another reference for messaging uses of the SFSB which I cannot remove.

      Question is... is it possible to remove this SFSB from the MDB? Should I try another technique or service? MBeans? I would like to send a "remove" message to the MDB, and then in the onMessage method remove the SFSB but I still don't know how.

      Please help!

        • 1. Re: Interesting question: launched SFSB from MDB
          norrin88

          Interesting forum: so many questions, never an answer... At least for me. It seems that if you ask for something more difficult than "How to make a HelloWorld bean" you don't have a chance to get your problems solved.

          This app server is great, isn't it? But it isn't as great as its documentation or its support.

          (sarcasm)

          Well, thanks for nothing

          • 2. Re: Interesting question: launched SFSB from MDB

            Read this.

            http://www.catb.org/~esr/faqs/smart-questions.html

            Remember support here is given for free. You need to help us, help you if you
            want an answer.

            In general you will only get answers if the barrier for entry is not too high.
            Keep your questions to specific technical points rather than:

            "but it seems that JBoss creates another reference for messaging uses of the SFSB which I cannot remove."

            Why would JBoss do this? Your code is doing this because you are doing it wrong.

            Regards,
            Adrian

            • 3. Re: Interesting question: launched SFSB from MDB
              norrin88

              "but it seems that JBoss creates another reference for messaging uses of the SFSB which I cannot remove.

              Why would JBoss do this?"

              That's exactly what I'm wondering. I'm also asking for a solution or an explanation, and I'm sure that there are many users/moderators/jboss gurus out there who has launched a SFSB from a MDB and probably they has met the same problem.

              But nobody can help me because jboss issues, or maybe nobody wants to help me. With the sarcastic post I was trying to discard one of the possibilities.

              The only thing I'm doing bad is using this app server. Unfortunately, I'm obliged to do so. Maybe if I can't get a solution soon I could make something to change it.

              Maybe you should read http://www.catb.org/~esr/faqs/clever-answers.html

              Best regards,

              • 4. Re: Interesting question: launched SFSB from MDB
                genman


                Apparently you haven't read that document Adrian helpfully pointed out. Here is a section you might have not read:

                Q:.
                How can I use X to do Y?

                A:.
                If what you want is to do Y, you should ask that question without pre-supposing the use of a method that may not be appropriate. Questions of this form often indicate a person who is not merely ignorant about X, but confused about what problem Y they are solving and too fixated on the details of their particular situation. It is generally best to ignore such people until they define their problem better.

                • 5. Re: Interesting question: launched SFSB from MDB
                  norrin88

                  Ok, sorry. I think the appropiate question is:

                  How can I use JBoss to make things work?

                  Where X=JBoss and Y="make things work".

                  What happen to you, guys? I'm just describing exactly what I'm seeing. Happily, I'm still not squint. You may request more information, if you really need it to help me and you want to help, but you cannot say that I'm not pre-supponing or confused about a thing.

                  Instead to start an absurd flame war, you may help... although I guess you are not for it. Or maybe it's just not possible to use a SFSB from a MDB.

                  Sad bad true.

                  • 6. Re: Interesting question: launched SFSB from MDB
                    norrin88

                    "but you cannot say that I'm pre-supponing or confused about a thing", I mean.

                    • 7. Re: Interesting question: launched SFSB from MDB

                      "Or maybe it's just not possible to use a SFSB from a MDB."

                      That would be something to consider. At least the way you seem to use SFSB. In a first place, I am curious to understand how come you use a SF component from a stateless one.

                      Regards,

                      Stephane

                      • 8. Re: Interesting question: launched SFSB from MDB
                        norrin88

                        Easy. As exposed in the first post, I retrieve the SFSB from a message inside the MDB (using getObject in onMessage).

                        Now I can invoke the SFSB methods. But obviously I cannot keep a reference of the SFSB in the MDB. Nevertheless, this reference is kept in another bean.

                        On the MDB I invoke one of the SFSB methods. If takes a long. When I try to stop it, for instance invoking remove(), I use the reference to the SFSB kept outside the MDB. Well, this reference is effectively removed, but the invoked SFSB method keeps running in the MDB!!! It's for this because I'm assuming that the MDB creates a new reference of the SFSB which I cannot remove or access in any way.

                        I think I cannot explain or expose it better...

                        Thanks for any possible idea or suggestion.

                        • 9. Re: Interesting question: launched SFSB from MDB
                          norrin88

                          "it takes a long" I mean

                          God!!! I'm dyslexic!!

                          • 10. Re: Interesting question: launched SFSB from MDB

                            First SFSB instances are not designed for concurrent use.
                            There are few methods that are allowed concurrently, remove is one of them.

                            By invoking remove() all you are doing is invoking ejbRemove on the bean instance
                            and removing the instance from the list of available SFSBs.
                            It will not interrupt any in flight invocation being done by the MDB thread.

                            Regards,
                            Adrian

                            • 11. Re: Interesting question: launched SFSB from MDB
                              norrin88

                              Ok, thank you very much. But let me abuse of your patience. If I need to run simultaneously two beans in a non-blocking fashion, how do I do it? Is it possible? I thought that MDB was the right mechanism for doing so.

                              I guess this is a general EJB question, but since I was able to run two SFSB at the same time inside JBoss with no performance or specification-breaking issues (or warnings), I believed that this was the right way.

                              What should I try?


                              Best regards,
                              Juanma

                              • 12. Re: Interesting question: launched SFSB from MDB

                                The restriction applies to invoking on the same SFSB instance.
                                Try it, instead of removing the bean, try to invoke a business operation
                                while the MDB is using it.
                                Then go read the spec.

                                Regards,
                                Adrian

                                • 13. Re: Interesting question: launched SFSB from MDB
                                  norrin88

                                  You missunderstood me. I don't invoke on the same SFSB. I just receive messages on the MDB from which I extract a DIFFERENT SFSB for each received message. Then, for each received one, I invoke a method.

                                  What I'm wondering is how to stop/remove/interact them once the method has been invoked from the MDB. To me, it is clear that I cannot invoke any method as I can't keep a reference of any SFSB in the MDB.

                                  I guess that the running threads must be somewhere. Is there any way to access them? I just need to be able to stop them, in a selective way (i.e. to stop that one choosed to be aborted by an user).

                                  Thanks again.

                                  Best regards,
                                  Juanma

                                  • 14. Re: Interesting question: launched SFSB from MDB
                                    triathlon98

                                    If I understand correctly, you are doing some things which could cause many problems.

                                    From my understanding, EJB is meant to be used single threaded (or should I say "thread local").. That is, a bean which is looked up from one thread should be used and removed from that thread. Otherwise, depending on the application server, you could run into problems.

                                    I think you have the following scenario in mind :

                                    You pass a SFSB to another thread using JMS. This is deserialized there and you invoke a method.
                                    Then you remove the SFSB and you expect the running method to stop.

                                    If that is the case, then indeed the method will continue to run as (considering the single-threadedness of a bean) the system does not expect there to be another invocation at the same time, so nothing is done about this.

                                    Joachim

                                    1 2 Previous Next