Custom EventStream in Java

122 views
Skip to first unread message

Guillermo Szeliga

unread,
Apr 10, 2014, 2:52:09 AM4/10/14
to akka...@googlegroups.com
Hi there,

I've been trying to tackle this issue on my own but I didn't succeed so far so I hope you can help. Our new architecture requires to have a whole different logging event system (independents from Akka's)  by using a LoggingAdapter instance but with a custom-tailored LogEventBus. The idea is to have actors that act as subscribers to any loggin event that's been published on our custom bus so that our own cryptography secured appenders write out all of these signed traces independently from the ordinary logging events.

Unfortunately we need to work with Java, so my first approach was to create our custom LogEventBus by extending EventStream, since it's the only implementation of a LogEventBus that I can see from the Javadocs, something like this:

public class SecureLoggerBus extends EventStream {

    /**
     * @param debug
     */
    public SecureLoggerBus(final boolean debug) {
        super(debug);
    }

}

Now, if my code is compiled using Eclipse, everything's fine and the final PoC works just as expected, but if I try to compile the same code via console, I get the following output:

[INFO] BUILD FAILURE
[INFO] ------------------------------------------------------------------------
[INFO] Total time: 2.853s
[INFO] Finished at: Thu Apr 10 14:25:24 CST 2014
[INFO] Final Memory: 13M/154M
[INFO] ------------------------------------------------------------------------
[ERROR] Failed to execute goal org.apache.maven.plugins:maven-compiler-plugin:2.3.2:compile (default-compile) on project akka_lab: Compilation failure
[ERROR] /home/operador/development/workspace_experimental/akka_lab/src/main/java/com/scytl/poc/slogger/SecureLoggerBus.java:[18,7] subclassification() in akka.event.EventStream cannot implement subclassification() in akka.event.SubchannelClassification; attempting to use incompatible return type
[ERROR] found   : java.lang.Object
[ERROR] required: akka.util.Subclassification<java.lang.Object>
[ERROR] -> [Help 1]
[ERROR] 
[ERROR] To see the full stack trace of the errors, re-run Maven with the -e switch.
[ERROR] Re-run Maven using the -X switch to enable full debug logging.
[ERROR] 
[ERROR] For more information about the errors and possible solutions, please read the following articles:



Now, If I decide to override subclassification() as being requested with the proper return type,

public class SecureLoggerBus extends EventStream {

    /**
     * @param debug
     */
    public SecureLoggerBus(final boolean debug) {
        super(debug);
    }

    /**
     * @see akka.event.EventStream#subclassification()
     */
    @Override
    public Subclassification<Object> subclassification() {
        return (Subclassification<Object>) super.subclassification();
    }

}


The code compiles but failes at runtime.

Exception in thread "main" java.lang.NoSuchMethodError: akka.event.EventStream.subclassification()Ljava/lang/Object;
at com.scytl.poc.slogger.SecureLoggerBus.subclassification(SecureLoggerBus.java:33)
at akka.event.SubchannelClassification$class.akka$event$SubchannelClassification$$subscriptions(EventBus.scala:131)
at akka.event.EventStream.akka$event$SubchannelClassification$$subscriptions$lzycompute(EventStream.scala:26)
at akka.event.EventStream.akka$event$SubchannelClassification$$subscriptions(EventStream.scala:26)
at akka.event.SubchannelClassification$class.publish(EventBus.scala:168)
at akka.event.EventStream.publish(EventStream.scala:26)
at akka.event.EventStream.subscribe(EventStream.scala:45)
at com.scytl.poc.slogger.main.Main.main(Main.java:38)

 I'm currently using Akka 2.3.2.

Any ideas? Does it have to do the fact that suclassification is an implicit val expected somewhere?

Any hint will be appreciated. Thanks!

Patrik Nordwall

unread,
Apr 10, 2014, 5:32:14 AM4/10/14
to akka...@googlegroups.com
Use the classes in akka.event.japi.*
The classes in akka.event.* is the Scala API.

Cheers,
Patrik


--
>>>>>>>>>> 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.



--

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

Guillermo Szeliga

unread,
Apr 23, 2014, 9:37:21 AM4/23/14
to akka...@googlegroups.com
I've checked the Java API but I can't figure out how to build up a custom LoggingBus from scratch that can be passed to a LoggingAdapter instance. All the buses implementations do not implement such "interface".

Am I loosing my time or is there any way of achieving it using Java?

Cheers and thanks for the patience!

Patrik Nordwall

unread,
Apr 23, 2014, 4:07:32 PM4/23/14
to akka...@googlegroups.com
On Wed, Apr 23, 2014 at 3:37 PM, Guillermo Szeliga <gsze...@gmail.com> wrote:
I've checked the Java API but I can't figure out how to build up a custom LoggingBus from scratch that can be passed to a LoggingAdapter instance. All the buses implementations do not implement such "interface".

What do you need to do with your custom event bus? Should it be as the ActorSystem.eventStream? You can subscribe to event classes (sub-classes)? The you should start with http://doc.akka.io/docs/akka/2.3.2/java/event-bus.html#Subchannel_Classification
That example operates on strings, and you want it to operate on classes. For example isSubclass can be implemented with y.isAssignableFrom(x), classify is implement with event.getClass()

Regards,
Patrik

Konrad Malawski

unread,
Apr 23, 2014, 4:16:13 PM4/23/14
to akka...@googlegroups.com
We also found 2 pretty cool blog posts (by Ben Howell) explaining akka's event buses a bit today, see: http://www.benhowell.net/examples/2014/04/18/scala-and-the-akka-eventstream/


-- 
Konrad `ktoso` Malawski
Reply all
Reply to author
Forward
0 new messages