--
You received this message because you are subscribed to the Google Groups "Play Framework" group.
To unsubscribe from this group and stop receiving emails from it, send an email to play-framework+unsubscribe@googlegroups.com.
To view this discussion on the web visit https://groups.google.com/d/msgid/play-framework/cdad6623-4b47-4c54-afa9-cde736ade5e6%40googlegroups.com.
For more options, visit https://groups.google.com/d/optout.
MDC is always thread based, so it's a fragile solution in general for Play, which is not using the same paradigm. You may have a custom execution context that you have to extend (it's mentioned as one of the other solutions in the blog post).You can also try using an SLF4J marker instead and passing it through methods as an implicit context -- this does require you to have your own logging wrapper, but it's checked at compile time and can pass between threads.
On Mon, Sep 26, 2016 at 11:38 AM, <jsw...@ebay.com> wrote:
I've setup my Play 2.5 app to use an MDC propagating dispatcher via the instructions hereIt works great for most cases, but one particular case it doesn't is Play filters.An example thread name is "ForkJoinPool-1-worker-10", which may give a clue that it's not an akka thread?I am using compile-time DI and manually instantiating the filters, and making sure that play.api.libs.concurrent.Execution.Implicits.defaultContext is in scope.Is this expected? Is there a workaround?jeff
--
You received this message because you are subscribed to the Google Groups "Play Framework" group.
To unsubscribe from this group and stop receiving emails from it, send an email to play-framewor...@googlegroups.com.
Bump. I have since seen evidence that filters sometimes run in a ForkJoinPool thread and sometimes run in an Akka thread. Is this expected?application-akka.actor.default-dispatcher-4ForkJoinPool-1-worker-18
--
You received this message because you are subscribed to the Google Groups "Play Framework" group.
To unsubscribe from this group and stop receiving emails from it, send an email to play-framework+unsubscribe@googlegroups.com.
To view this discussion on the web visit https://groups.google.com/d/msgid/play-framework/f8e7e22b-2461-4dcf-a461-2faa4e3b0f66%40googlegroups.com.
Are you talking about https://github.com/playframework/playframework/issues/6670 ?
On Mon, Nov 21, 2016 at 2:02 PM, Igmar Palsenberg <ig...@palsenberg.com> wrote:
Bump. I have since seen evidence that filters sometimes run in a ForkJoinPool thread and sometimes run in an Akka thread. Is this expected?application-akka.actor.default-dispatcher-4ForkJoinPool-1-worker-18As a sidenote : I can confirm this. Leads to very awkward, very strange to debug issues.Igmar
--
You received this message because you are subscribed to the Google Groups "Play Framework" group.
To unsubscribe from this group and stop receiving emails from it, send an email to play-framewor...@googlegroups.com.
class AccessLogFilter @Inject()(implicit val mat: Materializer, ec: ExecutionContext) extends Filter
def internalContext: ExecutionContextExecutor = {
val appOrNull: Application = Play._currentApp
appOrNull match {
case null => common
case app: Application => app.actorSystem.dispatcher
}
}
...
private val common = ExecutionContext.fromExecutor(new ForkJoinPool())
Updating to 2.5.10 did not fix my particular issue, but I did locate the root cause.I have a logging filter that uses implicit parameters to inject the ExecutionContext
class AccessLogFilter @Inject()(implicit val mat: Materializer, ec: ExecutionContext) extends Filter
The filter is manually constructed in a custom ApplicationLoader which imports play.api.libs.concurrent.Execution.Implicits.defaultContext. I discovered in play.core.Execution.scala
def internalContext: ExecutionContextExecutor = {
val appOrNull: Application = Play._currentApp
appOrNull match {
case null => common
case app: Application => app.actorSystem.dispatcher
}
}
...private val common = ExecutionContext.fromExecutor(new ForkJoinPool())So evidently, the EC is being bound to the ForkJoinPool because there is no currentApp yet, which makes sense.I tested that changing my filter to not accept the EC parameter and instead directly import the play EC works as expected.From looking at the filters documentation, I see examples that import the play EC and examples that inject the EC.
Is my workaround an expected but unfortunate aspect of using compile-time DI?I'm happy moving forward with my workaround (I do not need the flexibility of injecting the EC), but wanted to see if there's a better solution, or possible opportunity to improve play default EC implementation.
jeff
On Monday, November 21, 2016 at 5:08:55 PM UTC-8, jsw...@ebay.com wrote:Likely. I see the relevant PR made it in to 2.5.10, so I will upgrade to verify the issue is fixed. Thanks!jeff
On Monday, November 21, 2016 at 4:57:44 PM UTC-8, Will Sargent wrote:Are you talking about https://github.com/playframework/playframework/issues/6670 ?On Mon, Nov 21, 2016 at 2:02 PM, Igmar Palsenberg <ig...@palsenberg.com> wrote:--Bump. I have since seen evidence that filters sometimes run in a ForkJoinPool thread and sometimes run in an Akka thread. Is this expected?application-akka.actor.default-dispatcher-4ForkJoinPool-1-worker-18As a sidenote : I can confirm this. Leads to very awkward, very strange to debug issues.Igmar
You received this message because you are subscribed to the Google Groups "Play Framework" group.
To unsubscribe from this group and stop receiving emails from it, send an email to play-framewor...@googlegroups.com.
To view this discussion on the web visit https://groups.google.com/d/msgid/play-framework/f8e7e22b-2461-4dcf-a461-2faa4e3b0f66%40googlegroups.com.
--
You received this message because you are subscribed to the Google Groups "Play Framework" group.
To unsubscribe from this group and stop receiving emails from it, send an email to play-framework+unsubscribe@googlegroups.com.
To view this discussion on the web visit https://groups.google.com/d/msgid/play-framework/aca44432-5e9f-45c1-bade-a018e8376b7f%40googlegroups.com.
class AccessLogFilter @Inject()(implicit val mat: Materializer) extends Filter {
def apply(nextFilter: RequestHeader => Future[Result])(requestHeader: RequestHeader) = {
nextFilter(requestHeader).map { result =>
...
} (mat.executionContext)
}
}
Hi jeff,
To view this discussion on the web visit https://groups.google.com/d/msgid/play-framework/aca44432-5e9f-45c1-bade-a018e8376b7f%40googlegroups.com.