• Post Reply Bookmark Topic Watch Topic
  • New Topic
programming forums Java Mobile Certification Databases Caching Books Engineering Micro Controllers OS Languages Paradigms IDEs Build Tools Frameworks Application Servers Open Source This Site Careers Other Pie Elite all forums
this forum made possible by our volunteer staff, including ...
Marshals:
  • Campbell Ritchie
  • Jeanne Boyarsky
  • Ron McLeod
  • Paul Clapham
  • Liutauras Vilda
Sheriffs:
  • paul wheaton
  • Rob Spoor
  • Devaka Cooray
Saloon Keepers:
  • Stephan van Hulst
  • Tim Holloway
  • Carey Brown
  • Frits Walraven
  • Tim Moores
Bartenders:
  • Mikalai Zaikin

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

 
Ranch Hand
Posts: 37
1
  • Mark post as helpful
  • send pies
    Number of slices to send:
    Optional 'thank-you' note:
  • Quote
  • Report post to moderator
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.setDelay(delay);
local.sendMessage("my message");
....
} finally {
...
local.remove();
}

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?

Thanks
 
reply
    Bookmark Topic Watch Topic
  • New Topic