You are viewing a plain text version of this content. The canonical link for it is here.
Posted to dev@tomee.apache.org by exabrial12 <ex...@gmail.com> on 2019/02/05 22:06:16 UTC
@Interceptors are not called when a @Scheduled timer is invoked
Hey guys,
I think we found a bug in tomee 7.0.x (possibly others). If you have a
scheduled @Timer, and the bean has @Interceptors around it, those
interceptors are not called when the timer fires.
According to: https://docs.oracle.com/javaee/6/tutorial/doc/gkedm.html using
@Interceptors is allowed:
> Multiple timeout interceptors may be defined for a given target class by
> specifying the interceptor classes containing @AroundTimeout interceptor
> methods in an @Interceptors annotation at the class level.
I wrote a project here to demostrate:
https://github.com/exabrial/tomee-timer-interceptors
Examine the source code, then run mvn clean package tomee:run to reproduce
the issue.
Thanks,
-Jonathan
--
Sent from: http://tomee-openejb.979440.n4.nabble.com/TomEE-Dev-f982480.html
Re: @Interceptors are not called when a @Scheduled timer is invoked
Posted by exabrial12 <ex...@gmail.com>.
:D I'll write it! And that's pretty cool to understand the history of how
that came about.
Once we're out of our busy season, I have that example and a bunch of neat
stuff around TomEE I need to blog about or write examples for. We're
compiling our TomEE apps to native Debian packages and have our own apt
repo, we have alerting and monitoring happening via Hawtio and the TICK
stack, reliable logging over ActiveMQ to Graylog, and just some other really
practical solutions to common problems and concerns for any small business.
--
Sent from: http://tomee-openejb.979440.n4.nabble.com/TomEE-Dev-f982480.html
Re: @Interceptors are not called when a @Scheduled timer is invoked
Posted by David Blevins <da...@gmail.com>.
> On Feb 6, 2019, at 1:06 PM, exabrial12 <ex...@gmail.com> wrote:
>
> OH, I understand what you are saying. It's not that the @Interceptors is not
> supported, it's the interceptor must use @AroundTimeout not @AroundInvoke
That's right. As I understand the confusion, and you likely won't be the only confused -- just the first in a while to mention it -- here's how that came to be a requirement.
EJB 3.0 - AroundInvoke is added for business methods
AroundTimeout -> intercepts @Timeout methods called by the Timer API
AroundConstruct -> intercepts @PostConstruct calls by the container
EJB 3.1 - "Calendar" timers are added to the Timer API
Programmatic use of ScheduleExpression results in calls to the bean's @Timeout method
Annotation use of @Schedule results in calls to that exact method
Both are considered Timer API uses, so @AroundTimeout covers both cases
The ScheduleExpression->@AroundTimeout->@Timeout connection is intuitive for people.
The @Schedule->@AroundTimeout connection throws people off, but is correct.
As I say, an "intercept-schedule-methods" example could be very useful to help others out. If you feel like sharing the knowledge :)
-David
Re: @Interceptors are not called when a @Scheduled timer is invoked
Posted by exabrial12 <ex...@gmail.com>.
OH, I understand what you are saying. It's not that the @Interceptors is not
supported, it's the interceptor must use @AroundTimeout not @AroundInvoke
--
Sent from: http://tomee-openejb.979440.n4.nabble.com/TomEE-Dev-f982480.html
Re: @Interceptors are not called when a @Scheduled timer is invoked
Posted by exabrial12 <ex...@gmail.com>.
OH, I understand what you are saying. It's not that the @Interceptors is not
supported, it's the interceptor must use @AroundTimeout not @AroundInvoke
--
Sent from: http://tomee-openejb.979440.n4.nabble.com/TomEE-Dev-f982480.html
Re: @Interceptors are not called when a @Scheduled timer is invoked
Posted by David Blevins <da...@gmail.com>.
> On Feb 6, 2019, at 12:42 PM, exabrial12 <ex...@gmail.com> wrote:
>
> David can you take a look at the last paragraph on this page? It seems to
> imply both can be used, and even list the order they are to be executed:
> https://docs.oracle.com/javaee/6/tutorial/doc/gkedm.html
Being specific, the specification doesn't support @AroundInvoke for timers and the TCK doesn't test it. If the tutorial implies @AroundInvoke does work for timers, it needs to be corrected.
I looked for it, but I couldn't quickly see the spot where this is implied. Can you paste the chunk that mentions it should work?
-David
Re: @Interceptors are not called when a @Scheduled timer is invoked
Posted by exabrial12 <ex...@gmail.com>.
David can you take a look at the last paragraph on this page? It seems to
imply both can be used, and even list the order they are to be executed:
https://docs.oracle.com/javaee/6/tutorial/doc/gkedm.html
--
Sent from: http://tomee-openejb.979440.n4.nabble.com/TomEE-Dev-f982480.html
Re: @Interceptors are not called when a @Scheduled timer is invoked
Posted by David Blevins <da...@gmail.com>.
This is the annotation you want:
- http://tomee.apache.org/jakartaee-8.0/javadoc/javax/interceptor/AroundTimeout.html
This is for any usage of timers, which includes @Schedule methods.
If you want to create/contribute an example, that should be very quick and a great addition to the growing set.
--
David Blevins
http://twitter.com/dblevins
http://www.tomitribe.com
> On Feb 6, 2019, at 7:43 AM, exabrial12 <ex...@gmail.com> wrote:
>
> opened bug https://issues.apache.org/jira/browse/TOMEE-2466
>
>
>
> --
> Sent from: http://tomee-openejb.979440.n4.nabble.com/TomEE-Dev-f982480.html
Re: @Interceptors are not called when a @Scheduled timer is invoked
Posted by exabrial12 <ex...@gmail.com>.
opened bug https://issues.apache.org/jira/browse/TOMEE-2466
--
Sent from: http://tomee-openejb.979440.n4.nabble.com/TomEE-Dev-f982480.html