Thursday July 13, 2017

Actor and Executors

Disclaimer: I am talking about ActiveMQ Artemis internals here, giving tips on how you could achieve something similar on any system.

Systems today make heavy usage of Executors. No matter what system you chose, they are always there... Executors everywhere.

One pitfall they usually bring is: you will have to create one Runnable every time you call the executor:

Executor executor; // pretend this is already initialized

String data = "Hello world";
executor.execute(new Runnable() {

If you call this millions of time, you will have lots of Runnable instantiated that will need to be cleared by the Garbage Collector. (poor guy)

To make it easier, we haven recently introduce a new type of Executor on ActiveMQ Artemis internals. With the usage of lambdas it gets really elegant:

Executor parentExecutor; // pretend this is already initialized
Actor<String> actor = new Actor<>(parentExecutor, ::onMessage);

// this will call onMessage..
// an executor will be used underneath but no new Runnables are created
actor.act("Hello world");

public void onMessage(String message) {

Look at the code yourself if you want to have a similar pattern on your system:

- Our commons packet

- Code in use


Please explain why I would need to instantiate a new Executor for each execution.

Posted by Ken Geis on July 24, 2017 at 04:42 AM UTC #

I am looking forward for get new about the actor and executors try it for more informations.

Posted by 8 ball pool coins on October 10, 2017 at 08:58 AM UTC #

nice post Thanks for sharing. [url=][/url]

Posted by freexboxlivecodes on May 18, 2018 at 05:14 AM UTC #

I only recently started reading to such a famous book by Dan Brown as the Da Vinci Code, which is considered a classic of literature. The secret code is hidden in the works of Leonardo da Vinci ... Only he will help to find Christian shrines that give unthinkable power and power ... The key to the greatest mystery over which humanity has been beating for centuries can finally be found. If you need to write a paper on the topic of any work, you can ask for help here

Posted by Logan on July 20, 2018 at 09:50 AM UTC #

Post a Comment:
  • HTML Syntax: NOT allowed



Hot Blogs (today's hits)

Tag Cloud