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.
Well, thanks for nothing
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.
"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
Apparently you haven't read that document Adrian helpfully pointed out. Here is a section you might have not read:
How can I use X to do Y?
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.
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.
"but you cannot say that I'm pre-supponing or confused about a thing", I mean.
"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.
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.
"it takes a long" I mean
God!!! I'm dyslexic!!
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.
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?
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.
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).
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.