BT

InfoQ Homepage News Akka Actors vs. Java EJBs from a High-Level Concurrency Perspective

Akka Actors vs. Java EJBs from a High-Level Concurrency Perspective

Lire ce contenu en français

This item in chinese

Bookmarks

When comparing architectural principles and coding styles in Akka Actors and Java EE 7 Enterprise JavaBeans, specifically stateless session beans and JMS message-driven beans, there are commonalities, e.g. all three types are capable of both vertical and horizontal scaling, and some differences, e.g. in exception and transaction handling, Dr Gerald Loeffler concludes in a recent introductory talk when explaining and comparing the three approaches from a high-level concurrency view.

For his talk Gerald, a Senior Integration Architect, defines high-level concurrency as a programming paradigm where the concurrency is handled at the level of components and is abstracted away as much as possible, above handling individual threads or individual tasks and submitting those to thread pools.

He structures his talk around the idea of the Active Objects design pattern, loosely related to the classic design pattern but with the same kind of ideas. The examples are in Scala but he believes the talk is equally relevant for Java.

A simple mental model from an Active Objects perspective is for Gerald that:

  • Akka Actors receive messages as arbitrary objects, enqueued in a mailbox. They are explicitly managed and addressed individually via a common interface.
  • Stateless Session Beans expose asynchronous methods executed in an application server with lifecycle controlled by the container.
  • JMS Message-Driven Beans receive and process messages of predefined types from a JMS queue/topic. They are container-managed in the same way as session beans.

A common behaviour is that all three types execute asynchronously on threads, typically from a pool, with serialized access to the same instance.

Gerald uses three patterns for his comparison with code examples for all three types:

  • Local One-Way Asynchronous Request where an asynchronous request is sent from a requestor to a responder, who will not respond.
  • Request Asynchronous Out-of-Context Request where a requestor sends a message to a responder who sends back a return message, and when received the requestor has to re-establish the context.
  • Request Asynchronous In-Context Request where the context in some way has been preserved by the requestor when the return message is received.

Finally, Gerald concludes with a short summary of commonalities, e.g. all three approaches uses thread pools and are capable of both vertical and horizontal scaling, and some important differences, e.g. in exception handling, supervisor strategies and transaction handling.

Akka is an open source toolkit and runtime for building concurrent and event-driven applications on the JVM.
Enterprise Java Beans, EJB, is part of the larger Java EE specification, currently Java EE 7.

Rate this Article

Adoption
Style

Hello stranger!

You need to Register an InfoQ account or or login to post comments. But there's so much more behind being registered.

Get the most out of the InfoQ experience.

Allowed html: a,b,br,blockquote,i,li,pre,u,ul,p

Community comments

  • slides with code

    by Gerald Loeffler /

    Your message is awaiting moderation. Thank you for participating in the discussion.

    The slides for this talk (incl. Scala code) are available at www.gerald-loeffler.net/download/high_level_concurrency_scala_lsug_2014-02-05.pdf.

  • Excellent

    by David Tonhofer /

    Your message is awaiting moderation. Thank you for participating in the discussion.

    I love these efforts of carving out the principles between different approaches, getting rid of the irrelevant details and performing a side-by-side comparisons. It answers the question "underneath the sales pitch, what is this really and where have I seen this before?"

Allowed html: a,b,br,blockquote,i,li,pre,u,ul,p

Allowed html: a,b,br,blockquote,i,li,pre,u,ul,p

BT

Is your profile up-to-date? Please take a moment to review and update.

Note: If updating/changing your email, a validation request will be sent

Company name:
Company role:
Company size:
Country/Zone:
State/Province/Region:
You will be sent an email to validate the new email address. This pop-up will close itself in a few moments.