Skip to content

Commit 2bead20

Browse files
dgafkagitbook-bot
authored andcommitted
GITBOOK-940: No subject
1 parent 28a0827 commit 2bead20

File tree

5 files changed

+162
-383
lines changed

5 files changed

+162
-383
lines changed

SUMMARY.md

Lines changed: 16 additions & 16 deletions
Original file line numberDiff line numberDiff line change
@@ -2,17 +2,17 @@
22

33
* [About](README.md)
44
* [Installation](install-php-service-bus.md)
5-
* [How to use](quick-start-php-ddd-cqrs-event-sourcing/README.md) - Quick start guides and examples
6-
* [CQRS PHP](quick-start-php-ddd-cqrs-event-sourcing/php-cqrs.md) - Command Query Responsibility Segregation
7-
* [Event Handling PHP](quick-start-php-ddd-cqrs-event-sourcing/php-event-handling.md) - Event-driven architecture patterns
8-
* [Aggregates & Sagas](quick-start-php-ddd-cqrs-event-sourcing/aggregates-and-sagas.md) - Domain modeling building blocks
9-
* [Scheduling in PHP](quick-start-php-ddd-cqrs-event-sourcing/scheduling-in-php.md) - Time-based message processing
10-
* [Asynchronous PHP](quick-start-php-ddd-cqrs-event-sourcing/asynchronous-php.md) - Background processing and queues
11-
* [Event Sourcing PHP](quick-start-php-ddd-cqrs-event-sourcing/event-sourcing-php.md) - Event-based data persistence
12-
* [Microservices PHP](quick-start-php-ddd-cqrs-event-sourcing/microservices-php.md) - Distributed system patterns
13-
* [Resiliency and Error Handling](quick-start-php-ddd-cqrs-event-sourcing/resiliency-and-error-handling.md) - Fault tolerance strategies
14-
* [Laravel Demos](quick-start-php-ddd-cqrs-event-sourcing/laravel-ddd-cqrs-demo-application.md) - Laravel integration examples
15-
* [Symfony Demos](quick-start-php-ddd-cqrs-event-sourcing/symfony-ddd-cqrs-demo-application/README.md) - Symfony integration examples
5+
* [How to use](quick-start-php-ddd-cqrs-event-sourcing/README.md)
6+
* [CQRS PHP](quick-start-php-ddd-cqrs-event-sourcing/php-cqrs.md)
7+
* [Event Handling PHP](quick-start-php-ddd-cqrs-event-sourcing/php-event-handling.md)
8+
* [Aggregates & Sagas](quick-start-php-ddd-cqrs-event-sourcing/aggregates-and-sagas.md)
9+
* [Scheduling in PHP](quick-start-php-ddd-cqrs-event-sourcing/scheduling-in-php.md)
10+
* [Asynchronous PHP](quick-start-php-ddd-cqrs-event-sourcing/asynchronous-php.md)
11+
* [Event Sourcing PHP](quick-start-php-ddd-cqrs-event-sourcing/event-sourcing-php.md)
12+
* [Microservices PHP](quick-start-php-ddd-cqrs-event-sourcing/microservices-php.md)
13+
* [Resiliency and Error Handling](quick-start-php-ddd-cqrs-event-sourcing/resiliency-and-error-handling.md)
14+
* [Laravel Demos](quick-start-php-ddd-cqrs-event-sourcing/laravel-ddd-cqrs-demo-application.md)
15+
* [Symfony Demos](quick-start-php-ddd-cqrs-event-sourcing/symfony-ddd-cqrs-demo-application/README.md)
1616
* [Doctrine ORM](quick-start-php-ddd-cqrs-event-sourcing/symfony-ddd-cqrs-demo-application/doctrine-orm.md)
1717
* [Tutorial](tutorial-php-ddd-cqrs-event-sourcing/README.md)
1818
* [Before we start tutorial](tutorial-php-ddd-cqrs-event-sourcing/before-we-start-tutorial.md)
@@ -115,11 +115,11 @@
115115
* [Sagas: Workflows That Remember](modelling/business-workflows/sagas.md)
116116
* [Orchestrators: Declarative Workflow Automation](modelling/business-workflows/orchestrators.md)
117117
* [Handling Failures](modelling/business-workflows/handling-failures.md)
118-
* [Testing Support](modelling/testing-support/README.md) - Comprehensive testing tools for message-driven applications
119-
* [Testing Messaging](modelling/testing-support/testing-messaging.md) - Basic setup and testing fundamentals
120-
* [Testing Aggregates and Sagas with Message Flows](modelling/testing-support/testing-aggregates-and-sagas-with-message-flows.md) - Business logic flow testing
121-
* [Testing Event Sourcing Applications](modelling/testing-support/testing-event-sourcing-applications.md) - Event sourcing specific patterns
122-
* [Testing Asynchronous Messaging](modelling/testing-support/testing-asynchronous-messaging.md) - Async messaging strategies
118+
* [Testing Support](modelling/testing-support/README.md)
119+
* [Testing Messaging](modelling/testing-support/testing-messaging.md)
120+
* [Testing Aggregates and Sagas with Message Flows](modelling/testing-support/testing-aggregates-and-sagas-with-message-flows.md)
121+
* [Testing Event Sourcing Applications](modelling/testing-support/testing-event-sourcing-applications.md)
122+
* [Testing Asynchronous Messaging](modelling/testing-support/testing-asynchronous-messaging.md)
123123

124124
## Messaging and Ecotone In Depth <a href="#messaging" id="messaging"></a>
125125

enterprise.md

Lines changed: 5 additions & 5 deletions
Original file line numberDiff line numberDiff line change
@@ -4,9 +4,8 @@
44

55
Ecotone comes with two plans:
66

7-
* **Ecotone Free** comes with [Apache License Version 2.0](https://github.com/ecotoneframework/ecotone-dev/blob/main/LICENSE) for open features. It allows to build message-driven system in PHP, which solves resiliency and scalability at the architecture level. This covers all the features, which are not marked as Enterprise. \
8-
9-
* **Ecotone Enterprise** is based Enterprise licence. It does provides more advanced set of features aim for Enterprise usage. It does bring to the table custom features, additional integrations, and ability to optimization resource usages.&#x20;
7+
* **Ecotone Free** comes with [Apache License Version 2.0](https://github.com/ecotoneframework/ecotone-dev/blob/main/LICENSE) for open features. It allows to build message-driven system in PHP, which solves resiliency and scalability at the architecture level. This covers all the features, which are not marked as Enterprise. \\
8+
* **Ecotone Enterprise** is based Enterprise licence. It does provides more advanced set of features aim for Enterprise usage. It does bring to the table custom features, additional integrations, and ability to optimization resource usages.
109

1110
{% hint style="success" %}
1211
Each Enterprise feature is marked with hint on the documentation page. Enterprise features can only be run with licence key.\
@@ -17,14 +16,15 @@ To subscribe to Enterprise plan, visit [https://ecotone.tech/pricing](https://ec
1716
## Available Enterprise Features
1817

1918
* [**Kafka Support**](modules/kafka-support/) - Enables integration with Kafka (Event Streaming Platform) to send, receive from Messages from topics, and to use Kafka in form of Message Channel abstraction for seamless integration into the System.
20-
* [**Rabbit Consumer**](modules/amqp-support-rabbitmq/rabbit-consumer.md) - Provides ability to set up whole consumption process with single Attribute, and to extend it with resiliency patterns like: instant-retry, dead letter or final failure strategy.&#x20;
19+
* [**Rabbit Consumer**](modules/amqp-support-rabbitmq/rabbit-consumer.md) - Provides ability to set up whole consumption process with single Attribute, and to extend it with resiliency patterns like: instant-retry, dead letter or final failure strategy.
2120
* [**Dynamic Message Channels**](modelling/asynchronous-handling/dynamic-message-channels.md) - Provides ability to simplify deployment strategy, adjusting asynchronous processing to business scenarios, and configure processing per Client dynamically (which is especially useful in Multi-Tenant and SAAS environments).
2221
* [**Event Sourcing Handlers with Metadata**](modelling/event-sourcing/event-sourcing-introduction/working-with-metadata.md#enterprise-accessing-metadata-during-event-application) - Provides ability to pass Metadata to Aggregate's Event Sourcing Handlers. This can be used to to adjust Aggregate's reconstruction process, based on Metadata information stored in related Events.
2322
* [**Asynchronous Message Buses**](modelling/asynchronous-handling/asynchronous-message-bus-gateways.md) **-** This grants ability to build customized Command/Event Buses where Message will first go over given Asynchronous Channel. This can be used to build for example Outbox Command Bus.
2423
* [**Distributed Bus with Service Map**](modelling/microservices-php/distributed-bus/distributed-bus-with-service-map/) - Provides way to communicate between Services (Applications) with ease and in explicit and decoupled way. Make it possible to use all available Message Channels providers (RabbitMQ, Amazon SQS, Redis, Dbal, Kafka, Symfony Message Channels, Laravel Queues).
25-
* [**Command Bus Instant Retries**](modelling/recovering-tracing-and-monitoring/resiliency/retries.md#customized-instant-retries) - Provides ability to roll out new Command Bus with custom retry configuration. Allows to help in self-healing from scenarios like during HTTP request - external service went down, or our database connection was interrupted.&#x20;
24+
* [**Command Bus Instant Retries**](modelling/recovering-tracing-and-monitoring/resiliency/retries.md#customized-instant-retries) - Provides ability to roll out new Command Bus with custom retry configuration. Allows to help in self-healing from scenarios like during HTTP request - external service went down, or our database connection was interrupted.
2625
* [**Command Bus Error Channel** ](modelling/recovering-tracing-and-monitoring/resiliency/error-channel-and-dead-letter/#command-bus-error-channel)- Provides ability to configure Error Channel for Command Bus. This way we can handle with grace synchronous scenarios like failure on receiving webhook, by pushing the Message to Error Channel.
2726
* [**Instant Aggregate Fetch**](modelling/command-handling/repository/repository.md#instant-fetch-aggregate) - Provides ability to fetch Aggregates directly without the need to access Repositories. This way we can keep the code focused on the business logic instead of orchestration level code.
27+
* [**Orchestrators**](modelling/business-workflows/orchestrators.md) - Perfect for building **predefined and dynamic workflows** where the workflow definition is separate from the individual steps.
2828
* Details about more features coming soon...
2929

3030
## Materials

modelling/business-workflows/connecting-handlers-with-channels.md

Lines changed: 27 additions & 69 deletions
Original file line numberDiff line numberDiff line change
@@ -27,6 +27,7 @@ public function place(PlaceOrder $command): void
2727
```
2828

2929
**What happens behind the scenes:**
30+
3031
1. Ecotone creates a channel named `place.order`
3132
2. Your handler listens to this channel
3233
3. When you use the Command Bus, it sends messages to this channel
@@ -69,6 +70,7 @@ class ProcessOrder
6970
```
7071

7172
**How the flow works:**
73+
7274
1. You send `PlaceOrder` to `verify.order` channel
7375
2. The `verify()` method processes it and returns the command
7476
3. Ecotone automatically sends the returned command to `place.order` channel
@@ -107,9 +109,10 @@ class ProcessOrder
107109
```
108110

109111
**What this means:**
110-
-`verify.order` can be called via Command Bus (entry point)
111-
-`place.order` can only be reached through the workflow
112-
- 🔒 This ensures orders are always verified before being placed
112+
113+
*`verify.order` can be called via Command Bus (entry point)
114+
*`place.order` can only be reached through the workflow
115+
* 🔒 This ensures orders are always verified before being placed
113116

114117
{% hint style="success" %}
115118
**Extending Workflows**: You can easily add more steps by adding `outputChannelName` to any handler. To send messages to multiple handlers, use the [Router pattern](../../messaging/messaging-concepts/message-endpoint/message-routing.md).
@@ -118,9 +121,10 @@ class ProcessOrder
118121
## Adding Asynchronous Processing
119122

120123
Sometimes you want parts of your workflow to run asynchronously (in the background). This is perfect for:
121-
- Heavy processing that shouldn't block the user
122-
- Ensuring messages aren't lost if something goes wrong
123-
- Scaling parts of your workflow independently
124+
125+
* Heavy processing that shouldn't block the user
126+
* Ensuring messages aren't lost if something goes wrong
127+
* Scaling parts of your workflow independently
124128

125129
**Example**: Keep verification synchronous (fast feedback) but make order placement asynchronous (reliable processing):
126130

@@ -152,6 +156,7 @@ class ProcessOrder
152156
```
153157

154158
**What happens now:**
159+
155160
1. `verify()` runs immediately and returns a response
156161
2. The message goes to a queue/background processor
157162
3. `place()` runs later in the background
@@ -166,9 +171,10 @@ class ProcessOrder
166171
## Adding Delays and Timeouts
167172

168173
Asynchronous handlers can also be delayed, which is perfect for business scenarios like:
169-
- Giving customers time to complete actions
170-
- Implementing timeout behaviors
171-
- Scheduling follow-up actions
174+
175+
* Giving customers time to complete actions
176+
* Implementing timeout behaviors
177+
* Scheduling follow-up actions
172178

173179
**Example**: Give customers 24 hours to pay, then automatically cancel unpaid orders:
174180

@@ -219,8 +225,9 @@ class OrderTimeoutHandler
219225
```
220226

221227
**Timeline:**
222-
-**T+0**: Order placed, event published
223-
-**T+24h**: Cancellation handler runs automatically
228+
229+
***T+0**: Order placed, event published
230+
***T+24h**: Cancellation handler runs automatically
224231

225232
## Controlling Workflow Flow
226233

@@ -405,7 +412,7 @@ class ProcessOrder
405412
$this->placedOrders[] = $command->orderId;
406413
}
407414

408-
// Test helpers
415+
// In production application you would most likely have some repository
409416
public function wasOrderVerified(string $orderId): bool
410417
{
411418
return in_array($orderId, $this->verifiedOrders);
@@ -457,56 +464,6 @@ class WorkflowChainTest extends TestCase
457464
}
458465
```
459466

460-
### Testing Header Enrichment
461-
462-
Test workflows that modify message headers:
463-
464-
```php
465-
class HeaderEnrichmentProcessor
466-
{
467-
#[InternalHandler(
468-
inputChannelName: 'enrich.headers',
469-
outputChannelName: 'use.headers',
470-
changingHeaders: true
471-
)]
472-
public function enrichHeaders(CustomerData $customer): array
473-
{
474-
return [
475-
'customerType' => $customer->isPremium() ? 'premium' : 'standard',
476-
'riskScore' => $this->calculateRisk($customer)
477-
];
478-
}
479-
480-
#[InternalHandler('use.headers')]
481-
public function useHeaders(
482-
CustomerData $customer,
483-
#[Header('customerType')] string $customerType,
484-
#[Header('riskScore')] int $riskScore
485-
): string {
486-
return "Customer: {$customer->name}, Type: {$customerType}, Risk: {$riskScore}";
487-
}
488-
489-
private function calculateRisk(CustomerData $customer): int
490-
{
491-
return $customer->isPremium() ? 10 : 50;
492-
}
493-
}
494-
495-
public function test_header_enrichment_workflow(): void
496-
{
497-
$processor = new HeaderEnrichmentProcessor();
498-
$ecotoneLite = EcotoneLite::bootstrapFlowTesting(
499-
[HeaderEnrichmentProcessor::class],
500-
[$processor]
501-
);
502-
503-
$premiumCustomer = new CustomerData(name: 'John Doe', premium: true);
504-
$result = $ecotoneLite->sendDirectToChannel('enrich.headers', $premiumCustomer);
505-
506-
$this->assertEquals('Customer: John Doe, Type: premium, Risk: 10', $result);
507-
}
508-
```
509-
510467
### Testing Asynchronous Workflows
511468

512469
Test async workflows in synchronous mode for easier testing:
@@ -563,10 +520,11 @@ public function test_async_workflow_in_sync_mode(): void
563520
You now understand the fundamentals of connecting handlers with channels in Ecotone:
564521

565522
### Key Concepts
566-
- **Channels**: Every handler has an input channel, and can send to output channels
567-
- **Connection**: Use `outputChannelName` to chain handlers together
568-
- **Privacy**: Use `InternalHandler` to make handlers private to workflows
569-
- **Async Processing**: Add `#[Asynchronous]` for background processing
570-
- **Delays**: Use `#[Delayed]` for time-based workflows
571-
- **Flow Control**: Return `null` to stop workflows
572-
- **Data Enrichment**: Transform payloads or add headers
523+
524+
* **Channels**: Every handler has an input channel, and can send to output channels
525+
* **Connection**: Use `outputChannelName` to chain handlers together
526+
* **Privacy**: Use `InternalHandler` to make handlers private to workflows
527+
* **Async Processing**: Add `#[Asynchronous]` for background processing
528+
* **Delays**: Use `#[Delayed]` for time-based workflows
529+
* **Flow Control**: Return `null` to stop workflows
530+
* **Data Enrichment**: Transform payloads or add headers

0 commit comments

Comments
 (0)