I'm currently working on different kinds of parallelism functionality in Prometheus and pipelined parallelism is one of them.
The goal is to extract all plumbing (threading, blocking, message dispatching) from the process itself so it only contains the 'business logic' (generating messages transforming messages, consuming messages). This makes them a lot easier to use in different contexts, easier to test, easier to understand.
Code:
class Account{
int amount;
}
class ProcessA{
void receive(Account account){
//do some logic:
account.amount+=10;
}
}
The same goes for process B and C.
The processes can be connected in different ways:
You could let them execute synchronous (so only a single thread that executes the complete chain).
Code:
InputChannel in = ...
OutputChannel out = ...
Processor processor = new StandardProcessor(in,new Object[]{processA,processB,processC},out);
If the processor is run by a single thread, you will have your classic single threaded solution. If the processor is run by multiple threads, complete processing chains are run in parallel. But you also can decide to create a 'real' pipeline: each step is running asynchronous, so doesn't depend on the completion of the next step in the chain.
example of a pipeline:
Code:
InputChannel processA_in = ...
OutputChannel processA_out = ...
InputChannel processB_in = ...
....
Processor processorA = new StandardProcessor(processA_in, processA, processA_out)
Processor processorB = new StandardProcessor(processB_in, processB, processB_out)
Processor processorB = new StandardProcessor(processC_in, processC, processC_out)
If you let every processor run on its own thread, you will have the 'classic' pipeline. But ofcourse, you can also let a single processor be run by multiple threads which gives you parallelism in a different direction.
As you can see the same process can be used in different contexts and this gives a lot of freedom looking for the correct configuration for a specific situation.
At the moment my main focus is providing 'low' level concurrency structures and there is no direct support for batches etc (you have to build it on top). Maybe it could be useful in Spring Batch?