Figured it out. After digging deeper, it looks like ApplicationEventListeners are ordered and respect the `@Priority` annotation. So adding a priority > 5000 to my listener guarantees that it runs after the UnitOfWork listener.
On Sunday, June 19, 2016 at 2:34:09 PM UTC-4, Al Scott wrote: > > Hi everyone, > > I'm trying to do a basic annotation based multitenancy setup with a > tenantId path parameter and hibernate filters. I'm having trouble fitting > something into the jersey lifecycle that can process my annotation *after* > the UnitOfWork annotation has set up a hibernate session. > > The path I went down was to create a multitenancy ApplicationEventListener > and RequestEventListener, much like the listeners already set up for > UnitOfWork. All the request listener does in wait for the > RESOURCE_METHOD_START event and then pulls out the path parameter and > enables my hibernate filter on the current session. > > The problem with this approach is that it seems like the order in which > the request listeners fire is non-deterministic. I am seeing my request > listener work correctly every time when I run my app with my development > config.yml, but fail every time I run it with my test config.yml (the two > configs differ only in some minor logging details). > > This was confusing to me because digging into the jersey source code it > looks like RequestEventListeners should be handled in a predictable order > based on when you registered them. > > So my questions are the following: > > > 1. Is there a way to guarentee order of execution between two > RequestEventListener's listening to the same event? > 2. If not, it seems like I must either not use UnitOfWork and roll my > own transaction management, or I need to use something other than a > RequestEventListener, any advice there? > > I can provide more details if anyone needs! > > Thanks, > -Al > -- You received this message because you are subscribed to the Google Groups "dropwizard-user" group. To unsubscribe from this group and stop receiving emails from it, send an email to [email protected]. For more options, visit https://groups.google.com/d/optout.
