Asynchronous processing with ExecutorServices – Part 2

Continuing with the subject presented in the first part of this article, let’s talk a little more about asynchronous processing with ExecutorServices. In this second part, let’s approach the following use case.
Our software will receive and process a batch of transactions. After processing this batch, the system must create a “summary” of the processing, pointing individually the number of processed transactions successfully and with error. This summary could be sent to some other system, for example, that could then analyze the success rate of this transactions batch or something like that.

Continue reading “Asynchronous processing with ExecutorServices – Part 2”

Asynchronous processing with ExecutorServices – Part 1

Introduction

With state-of-the-art machines with a lot of processors, it’s essential that you be able to build software that can get the most out of these resources. What’s the purpose of having a super computer with 16 processors if your software is executed sequentially in a single-thread? Messaging systems, like JMS and AMQP, can be really useful to distribute your processing. However, in some scenarios, these technologies may be overkill, once besides bringing some overhead related to adding a message broker to the architecture, we may just want to efficiently use all the processors of the machine, splitting a task that would be executed in a single-thread in a set of smaller tasks that can be executed in parallel by multiple threads. Prior to Java 5, we had to create/manage manually the Threads, which wasn’t a pleasant task. But with Java 5, things got easier with the new Executor Services.

Continue reading “Asynchronous processing with ExecutorServices – Part 1”