It's not a secret anymore!*
The moose likes EJB and other Java EE Technologies and the fly likes EJBHow to get a default value for a stateless EJB (2.0)? Big Moose Saloon
  Search | Java FAQ | Recent Topics | Flagged Topics | Hot Topics | Zero Replies
Register / Login
JavaRanch » Java Forums » Java » EJB and other Java EE Technologies
Bookmark "EJBHow to get a default value for a stateless EJB (2.0)?" Watch "EJBHow to get a default value for a stateless EJB (2.0)?" New topic

EJBHow to get a default value for a stateless EJB (2.0)?

Klament J. Kruoghst
Ranch Hand

Joined: Oct 24, 2008
Posts: 35
Hi there, I have a stateless session bean that sends a message to a queue.

The messages can be sent with a delay so I'm setting the default delay to -1 (no delay) and i have a setter and getter for it defined too.

One type of message has a delay of X seconds, all others use its default. So when I'm calling the bean i:

local = localHome.create();
local.sendMessage("my message");
} finally {

The other calls go the same but without the setDelay call. The problem is that this delay doesn't seem to be setting. For instance if I don't set a delay it's going to pick the delay of the previous call (instead of picking my default delay of -1)

So I guess when the variable is changed by the first call and the bean is put back to the pool with that delay it's changed for the next called so... I tried putting the setDelay to -1 in the ejbCreate() which although it's not called when i do the loca.create(), it is supposed to be triggered when a business method is called so I thought would be triggered by the local.sendMessage() but the same thing is happening. I read that even when you call local.remove() it doesn't mean ejbRemove() will be called so I can't use that either, so...

How do I go about receiving a default value for a Stateless session bean each time it's called?

I agree. Here's the link:
subject: EJBHow to get a default value for a stateless EJB (2.0)?
Similar Threads
Performance Problem with EJB--Need expert guidence
Stateless vs Stateful bean
Performance Problem with EJB running on WAS
NPE when trying to get size() in ArrayList
ejbRemove() doesn't call ejbPassivate() ? - HFE p371 question #16