Skip to content

Commit f5c0ac3

Browse files
authored
Refactor formatting and remove captionless image
Updated headings to use consistent formatting and removed unnecessary image.
1 parent 31738c5 commit f5c0ac3

File tree

1 file changed

+10
-12
lines changed

1 file changed

+10
-12
lines changed

blog/2023-08-18-microservice-communication-with-laravel-workflow.md

Lines changed: 10 additions & 12 deletions
Original file line numberDiff line numberDiff line change
@@ -9,8 +9,6 @@ authors:
99
tags: [microservices, workflow, communication, distributed-systems]
1010
---
1111

12-
![captionless image](https://miro.medium.com/v2/resize:fit:1400/format:webp/1*nCy08NPtCpERqC09SVBFfg.jpeg)
13-
1412
In the evolving landscape of microservices, communication has always been a focal point. Microservices can interact in various ways, be it through HTTP/REST calls, using messaging protocols like RabbitMQ or Kafka, or even employing more recent technologies like gRPC. Yet, regardless of the communication method, the goal remains the same: seamless, efficient, and robust interactions. Today, we’ll explore how Laravel Workflow can fit into this picture and optimize the communication between microservices in a unique way.
1513

1614
## The Challenge
@@ -74,10 +72,10 @@ When working with microservices, it’s common for each service to have its dedi
7472

7573
## Step-By-Step Integration
7674

77-
### 1. Install `laravel-workflow` in all microservices.
75+
#### 1. Install `laravel-workflow` in all microservices.
7876
Follow the [installation guide](https://laravel-workflow.com/docs/installation/).
7977

80-
### 2. Create a shared database/redis connection in all microservices.
78+
#### 2. Create a shared database/redis connection in all microservices.
8179
```php
8280
// config/database.php
8381
'connections' => [
@@ -91,7 +89,7 @@ Follow the [installation guide](https://laravel-workflow.com/docs/installation/)
9189
],
9290
```
9391

94-
### 3. Configure a shared queue connection.
92+
#### 3. Configure a shared queue connection.
9593
```php
9694
// config/queue.php
9795
'connections' => [
@@ -103,7 +101,7 @@ Follow the [installation guide](https://laravel-workflow.com/docs/installation/)
103101
],
104102
```
105103

106-
### 4. Ensure only one microservice publishes Laravel Workflow migrations.
104+
#### 4. Ensure only one microservice publishes Laravel Workflow migrations.
107105
Update the migration to use the shared database connection.
108106
```php
109107
// database/migrations/..._create_workflows_table.php
@@ -113,7 +111,7 @@ class CreateWorkflowsTable extends Migration
113111
}
114112
```
115113

116-
### 5. Extend workflow models in each microservice to use the shared connection.
114+
#### 5. Extend workflow models in each microservice to use the shared connection.
117115
```php
118116
// app/Models/StoredWorkflow.php
119117
namespace App\Models;
@@ -126,12 +124,12 @@ class StoredWorkflow extends BaseStoredWorkflow
126124
}
127125
```
128126

129-
### 6. Publish Laravel Workflow config and update it with shared models.
127+
#### 6. Publish Laravel Workflow config and update it with shared models.
130128
```sh
131129
php artisan vendor:publish --provider="Workflow\Providers\WorkflowServiceProvider" --tag="config"
132130
```
133131

134-
### 7. Set workflows and activities to use the shared queue.
132+
#### 7. Set workflows and activities to use the shared queue.
135133
```php
136134
// app/Workflows/MyWorkflow.php
137135
class MyWorkflow extends Workflow
@@ -149,7 +147,7 @@ class MyActivity extends Activity
149147
}
150148
```
151149

152-
### 8. Ensure microservices define empty counterparts for workflow and activity classes.
150+
#### 8. Ensure microservices define empty counterparts for workflow and activity classes.
153151
#### In the workflow microservice:
154152
```php
155153
class MyWorkflow extends Workflow
@@ -188,10 +186,10 @@ class MyActivity extends Activity
188186
}
189187
```
190188

191-
### 9. Ensure all microservices have the same `APP_KEY` in their `.env` file.
189+
#### 9. Ensure all microservices have the same `APP_KEY` in their `.env` file.
192190
This is crucial for proper job serialization across services.
193191

194-
### 10. Run queue workers in each microservice.
192+
#### 10. Run queue workers in each microservice.
195193
```sh
196194
php artisan queue:work shared --queue=workflow
197195
php artisan queue:work shared --queue=activity

0 commit comments

Comments
 (0)