Delegate to another bean maybe
Le 9 juil. 2013 19:46, "Leonardo K. Shikida" <[email protected]> a écrit :
> but still, scheduling from @PostConstruct does not work either, because
>
> @Stateless
> public class JmsWorkerEJB {
>
> @Resource
> TimerService timerService;
>
> @PostConstruct
> public void init() {
> System.out.println("Hello "+this);
> try {
> ScheduleExpression schedule = new
> ScheduleExpression();
> schedule.hour("*");
> schedule.minute("*");
> schedule.second("*");
>
> /*Timer timer =
> */timerService.createCalendarTimer(schedule);
> } catch (Exception e) {
> e.printStackTrace();
> }
>
> }
> @Timeout
> public void processMessage(){...}
>
>
> gives me
>
> java.lang.IllegalStateException: timerMethod cannot be called in
> POST_CONSTRUCT
>
> oh boy
>
> []
>
> Leo
>
>
> On Tue, Jul 9, 2013 at 2:19 PM, Leonardo K. Shikida <[email protected]>
> wrote:
> > learning something new everyday ;-)
> >
> > []
> >
> > Leo
> >
> >
> > On Tue, Jul 9, 2013 at 2:06 PM, Romain Manni-Bucau
> > <[email protected]> wrote:
> >> @Startup on stateless doesnt mean anything in the spec IIRC ;)
> >> Le 9 juil. 2013 19:04, "Leonardo K. Shikida" <[email protected]> a
> écrit :
> >>
> >>> No, it's a regular @Stateless
> >>>
> >>> @Stateless
> >>> @Startup
> >>> public class JmsWorkerEJB {...}
> >>>
> >>> It has a method annotated with @Schedule that reads from a JMS queue.
> >>>
> >>> In the worst case, since @PostConstruct is being called, I could
> >>> schedule from there instead, but does not seems an elegant way to deal
> >>> with that :-)
> >>>
> >>> []
> >>>
> >>> Leo
> >>>
> >>>
> >>> On Tue, Jul 9, 2013 at 1:56 PM, Romain Manni-Bucau
> >>> <[email protected]> wrote:
> >>> > Found in code this time ;)
> >>> >
> >>> > Is your ejb a singleton? Did you set @lock(read)?
> >>> >
> >>> > Working thread can be done with @Asynchronous in javaee 6
> >>> > Le 9 juil. 2013 18:52, "Leonardo K. Shikida" <[email protected]> a
> >>> écrit :
> >>> >
> >>> >> MinSize does instantiate these :-)
> >>> >>
> >>> >> Where did you find this parameter?
> >>> >>
> >>> >> But the method annotated with @Schedule is run only for one instance
> >>> >> at a time. I thought it should run for all of them.
> >>> >>
> >>> >> How people usually implement the concept of working threads in EJB?
> >>> >> Maybe I am trying to do this in the wrong way.
> >>> >>
> >>> >> TIA
> >>> >>
> >>> >> Leo
> >>> >>
> >>> >>
> >>> >> On Tue, Jul 9, 2013 at 1:37 PM, Romain Manni-Bucau
> >>> >> <[email protected]> wrote:
> >>> >> > Did you try MinSize?
> >>> >> > Le 9 juil. 2013 18:16, "Leonardo K. Shikida" <[email protected]>
> a
> >>> >> écrit :
> >>> >> >
> >>> >> >> Hi Romain
> >>> >> >>
> >>> >> >> I've added to tomee.xml
> >>> >> >>
> >>> >> >> <Container id="foo" type="STATELESS">
> >>> >> >> PoolSize=10
> >>> >> >> </Container>
> >>> >> >>
> >>> >> >> but it didn't worked as I was expecting.
> >>> >> >>
> >>> >> >> I thought it would instantiate 10 instances.
> >>> >> >>
> >>> >> >> I've also added a sysout in the
> >>> >> >>
> >>> >> >> @PostConstruct
> >>> >> >> public void init() {
> >>> >> >> System.out.println("Hello "+this);
> >>> >> >>
> >>> >> >> I thought I'd have 10 lines in the first service, but there was
> only
> >>> >> one.
> >>> >> >>
> >>> >> >> Do I have to set somewhere (somehow) that my bean is using this
> >>> >> >> container or tomee assumes it's the default configuration for all
> >>> >> >> stateless beans?
> >>> >> >>
> >>> >> >> TIA
> >>> >> >>
> >>> >> >> Leo
> >>> >> >>
> >>> >> >>
> >>> >> >> On Tue, Jul 9, 2013 at 12:29 PM, Romain Manni-Bucau
> >>> >> >> <[email protected]> wrote:
> >>> >> >> > Hi
> >>> >> >> >
> >>> >> >> > The basic conf is here
> >>> >> >> http://tomee.apache.org/containers-and-resources.html
> >>> >> >> >
> >>> >> >> > You can set PoolSize (MaxSize) but MinSize too
> >>> >> >> > Le 9 juil. 2013 14:45, "Leonardo K. Shikida" <
> [email protected]> a
> >>> >> >> écrit :
> >>> >> >> >
> >>> >> >> >> Hi
> >>> >> >> >>
> >>> >> >> >> I am using a stateless bean to consume from a jms queue
> >>> periodically
> >>> >> >> >> (@Schedule). It's started with the container (@Startup). Is
> there
> >>> any
> >>> >> >> >> way to configure somewhere the initial number of instances for
> >>> this
> >>> >> >> >> specific bean?
> >>> >> >> >>
> >>> >> >> >> TIA
> >>> >> >> >>
> >>> >> >> >> Leo
> >>> >> >> >>
> >>> >> >>
> >>> >>
> >>>
>