Skip to content

Instantly share code, notes, and snippets.

View nicholasdgoodman's full-sized avatar

Nicholas Goodman nicholasdgoodman

  • New York, New York
View GitHub Profile
@nicholasdgoodman
nicholasdgoodman / Keyed-Processing.md
Last active January 18, 2024 22:26
Multi-Threaded Processing for Solace JCSMP

Description of Problem

When leveraging parallel processing of an event stream, it is often desirable to partition data along a particular piece of metadata referred to as a "key" upon which message orders can be guaranteed for a given key value. This same pattern can be extended down to individual consumer processes which may leverage multi-threaded processing within.

Parallel Processing in Java

In Java, the JDK provides the ExecutorService API for simplifying the task of running asynchronous code. A service instance can be created with a specified number of threads which then receives tasks which will be executed in parallel on one of these threads:

ExcecutorService executor = Executors.newFixedThreadPool(8); // allow up to 8 tasks to execute concurrently