Skip to content
Merged
Show file tree
Hide file tree
Changes from 1 commit
Commits
File filter

Filter by extension

Filter by extension


Conversations
Failed to load comments.
Loading
Jump to
Jump to file
Failed to load files.
Loading
Diff view
Diff view
Prev Previous commit
Next Next commit
iluwatar#1627 adding readme
  • Loading branch information
karthikbhat13 committed Jun 12, 2021
commit 227715d2400344e813cb55ac4364fa26138a8ed5
33 changes: 33 additions & 0 deletions fanout-fanin/README.md
Original file line number Diff line number Diff line change
@@ -0,0 +1,33 @@
---
layout: pattern
title: FanOut-FanIn
folder: fanout-fanin
permalink: /patterns/fanout-fanin/
categories: Concurrency
language: en
tags:
- Cloud distributed
- Performance
---

## Intent
The pattern that refers to executing multiple instances of the activity function concurrently. Generally "FanOut"
process is splitting the data into multiple chunks that would be passed to the activity function. "FanIn" process is
basically aggregating the result from individual instance of activity function and forming a single final result. <br />

Each activity function is a long-running process that takes in a chunk of data. A callback function, or a Consumer
is passed to the activity function, that will be called when the long-running process gets over. The consumer will
process the individual return value from activity function as they are done running into a final result.

## Class diagram
![alt-text](./etc/fanout-fanin.png)

## Applicability

Use this pattern when you can chunk the workload or load into multiple chunks that can be dealt with separately.

## Credits

* [Understanding Azure Durable Functions - Part 8: The Fan Out/Fan In Pattern](http://dontcodetired.com/blog/post/Understanding-Azure-Durable-Functions-Part-8-The-Fan-OutFan-In-Pattern)
* [Fan-out/fan-in scenario in Durable Functions - Cloud backup example](https://docs.microsoft.com/en-us/azure/azure-functions/durable/durable-functions-cloud-backup)
* [Understanding the Fan-Out/Fan-In API Integration Pattern](https://dzone.com/articles/understanding-the-fan-out-fan-in-api-integration-p)
File renamed without changes
2 changes: 1 addition & 1 deletion fanin-fanout/pom.xml → fanout-fanin/pom.xml
Original file line number Diff line number Diff line change
Expand Up @@ -9,7 +9,7 @@
</parent>
<modelVersion>4.0.0</modelVersion>

<artifactId>fanin-fanout</artifactId>
<artifactId>fanout-fanin</artifactId>

<dependencies>
<dependency>
Expand Down
Original file line number Diff line number Diff line change
Expand Up @@ -9,7 +9,7 @@


/**
* FanOut/FanIn pattern is a behavioral pattern that refers to executing multiple instances of the
* FanOut/FanIn pattern is a concurrency pattern that refers to executing multiple instances of the
* activity function concurrently. The "fan out" part is essentially splitting the data into
* multiple chunks and then calling the activity function multiple times, passing the chunks.
*
Expand Down
Original file line number Diff line number Diff line change
Expand Up @@ -24,6 +24,7 @@ public static Long fanOutFanIn(

ExecutorService service = Executors.newFixedThreadPool(requests.size());

// fanning out
List<CompletableFuture<Void>> futures =
requests.stream()
.map(
Expand Down
2 changes: 1 addition & 1 deletion pom.xml
Original file line number Diff line number Diff line change
Expand Up @@ -232,7 +232,7 @@
<module>table-module</module>
<module>presentation</module>
<module>lockable-object</module>
<module>fanin-fanout</module>
<module>fanout-fanin</module>
</modules>

<repositories>
Expand Down