Akka with Java 8 lambda support - MDC

169 views
Skip to first unread message

nil...@gmail.com

unread,
Nov 6, 2014, 3:40:13 PM11/6/14
to akka...@googlegroups.com
I'm testing the experimental Java 8 lambda support with akka and AbstractActor, but I cannot seem to find a way to use the MDC feature this way. With an untyped actor, I can do Logging.getLogger(this) and get a DiagnosticLoggingAdapter with MDC support. However, since AbstractActor does not extend UntypedActor, I can only get a regular LoggingAdapter, with no way to set the MDC. Am I missing something? Is it possible with AbstractActor, or do I need to switch back to using UntypedActor?

Martynas Mickevičius

unread,
Nov 7, 2014, 12:35:48 PM11/7/14
to akka...@googlegroups.com
Hi,

there is Logging.apply(logSource: Actor) which you can use with AbstractActor.

On Thu, Nov 6, 2014 at 10:40 PM, <nil...@gmail.com> wrote:
I'm testing the experimental Java 8 lambda support with akka and AbstractActor, but I cannot seem to find a way to use the MDC feature this way. With an untyped actor, I can do Logging.getLogger(this) and get a DiagnosticLoggingAdapter with MDC support. However, since AbstractActor does not extend UntypedActor, I can only get a regular LoggingAdapter, with no way to set the MDC. Am I missing something? Is it possible with AbstractActor, or do I need to switch back to using UntypedActor?

--
>>>>>>>>>> Read the docs: http://akka.io/docs/
>>>>>>>>>> Check the FAQ: http://doc.akka.io/docs/akka/current/additional/faq.html
>>>>>>>>>> Search the archives: https://groups.google.com/group/akka-user
---
You received this message because you are subscribed to the Google Groups "Akka User List" group.
To unsubscribe from this group and stop receiving emails from it, send an email to akka-user+...@googlegroups.com.
To post to this group, send email to akka...@googlegroups.com.
Visit this group at http://groups.google.com/group/akka-user.
For more options, visit https://groups.google.com/d/optout.



--
Martynas Mickevičius
TypesafeReactive Apps on the JVM

nil...@gmail.com

unread,
Nov 8, 2014, 1:16:33 PM11/8/14
to akka...@googlegroups.com
Thanks! That does work. I was kind of staying away from the apply methods in the Akka classes, since I was considering them Scala specific. Is there any "danger" in using those?

Nils-H

Patrik Nordwall

unread,
Nov 10, 2014, 2:28:52 AM11/10/14
to akka...@googlegroups.com
On Sat, Nov 8, 2014 at 7:16 PM, <nil...@gmail.com> wrote:
Thanks! That does work. I was kind of staying away from the apply methods in the Akka classes, since I was considering them Scala specific. Is there any "danger" in using those?

No danger. They are no special from java perspective. However, by convention we have not used apply for Java APIs. I'll create a ticket to add an alias method named create for this.

/Patrik



--

Patrik Nordwall
Typesafe Reactive apps on the JVM
Twitter: @patriknw

Reply all
Reply to author
Forward
0 new messages