Skip to content

Commit

Permalink
Update migration guide and docs with new RabbitMQ Clients
Browse files Browse the repository at this point in the history
  • Loading branch information
jvanecek committed Aug 12, 2024
1 parent 75ddd2f commit b3878df
Show file tree
Hide file tree
Showing 5 changed files with 101 additions and 2 deletions.
61 changes: 60 additions & 1 deletion docs/MigrationGuide.md
Original file line number Diff line number Diff line change
Expand Up @@ -2,4 +2,63 @@

## Migration from v2 to v3

To achieve this, manually load the package `Ansible-Deprecated-V3`.
* Manually load the package `Ansible-Deprecated-V3` that has transformation of deprecated messages.

* `RabbitMQWorker` has been refactored to be used by composition instead of inheritance:
The classes that subclassified it implemented the subclass responsibility `#configureConnection:` and `#process: payload` should be changed to instantiate `RabbitMQWorker` as to pass that process logic to the `processingPayloadWith:` collaborator.

For instance,

```
Class {
#name : 'RabbitMQTextReverser',
#superclass : 'RabbitMQWorker',
#instVars : [
'testCase',
]
}
{ #category : 'initialization' }
RabbitMQTextReverser >> initializeWorkingWith: aTestCase
testCase := aTestCase
{ #category : 'private' }
RabbitMQTextReverser >> #configureConnection: builder
builder hostname: 'localhost'.
builder portNumber: 5672.
builder username: 'guest'.
builder password: 'guest'.
{ #category : 'private' }
RabbitMQTextReverser >> process: payload
testCase storeText: payload utf8Decoded reversed
```

Should be refactored to

```
Class {
#name : 'RabbitMQTextReverser',
#superclass : 'Object',
#instVars : [
'worker'
]
}
RabbitMQTextReverser >> initializeWorkingWith: aTestCase
worker := RabbitMQWorker
configuredBy: [ :options |
options
at: #hostname 'localhost';.
at: #port 5672;.
at: #username 'guest';.
at: #password 'guest'
]
processingMessagesWith: [ :payload | aTestCase storeText: payload utf8Decoded reversed ].
worker start
```
7 changes: 7 additions & 0 deletions docs/README.md
Original file line number Diff line number Diff line change
Expand Up @@ -44,6 +44,13 @@ They are not a rewrite but rather my interpretation.
reading it to get a complete understanding. They also provide this [great tool](http://tryrabbitmq.com)
to help you explore different messaging patterns.

## Use RabbitMQ clients reifications

We provide two objects to simplify the instantiations of a publisher and a consumer:

1. [RabbitMQPublisher](tutorials/RabbitMQPublisher.md)
2. [RabbitMQWorker](tutorials/RabbitMQWorker.md)

---

To use the project as a dependency of your project, take a look at:
Expand Down
2 changes: 1 addition & 1 deletion docs/tutorials/PublishSubscribe.md
Original file line number Diff line number Diff line change
Expand Up @@ -70,7 +70,7 @@ logger name: 'Transcript logger'.
logger resume
```

## Receiveing notifications
## Receiving notifications

Here's the script to spawn a process that will pop up a toast notification on
every log message received
Expand Down
16 changes: 16 additions & 0 deletions docs/tutorials/RabbitMQPublisher.md
Original file line number Diff line number Diff line change
@@ -0,0 +1,16 @@
# RabbitMQPublisher

This object will connect to an AMQP channel and knows how to publish messages to the specified queue for further processing.

Accepts the following options:

| Attribute name | Description | Optional/Mandatory | Default value |
| ---------------|-------------|--------------------|---------------|
| #hostname | Hostname of the rabbitmq broker | Optional | 'localhost' |
| #port | Port numbre of the rabbitmq broker | Optional | 5672 |
| #username | Username of the rabbitmq broker | Optional | 'guest' |
| #password | Username of the rabbitmq broker | Optional | 'guest' |
| #maximumConnectionAttemps | Amount of retries when connecting to the broker fails | Optional | 3 |
| #timeSlotBetweenConnectionRetriesInMs | Time duration between retry attempts determined by using the exponential backoff algorithm | Optional | 3000 |
| #enableDebuggingLogs | A boolean indicating whether to log debugging events | Optional | false |
| #retry | A block that can configure the internal `Retry` instance | Optional | `[:action | ]` |
17 changes: 17 additions & 0 deletions docs/tutorials/RabbitMQWorker.md
Original file line number Diff line number Diff line change
@@ -0,0 +1,17 @@
# RabbitMQWorker

This object will connect to an AMQP channel and knows how to consume messages from a specified queue for processing.

Accepts the following options:

| Attribute name | Description | Optional/Mandatory | Default value |
| ---------------|-------------|--------------------|---------------|
| #queueName | Queue name where to consume from | Mandatory | |
| #hostname | Hostname of the rabbitmq broker | Optional | 'localhost' |
| #port | Port numbre of the rabbitmq broker | Optional | 5672 |
| #username | Username of the rabbitmq broker | Optional | 'guest' |
| #password | Username of the rabbitmq broker | Optional | 'guest' |
| #maximumConnectionAttemps | Amount of retries when connecting to the broker fails | Optional | 3 |
| #timeSlotBetweenConnectionRetriesInMs | Time duration between retry attempts determined by using the exponential backoff algorithm | Optional | 3000 |
| #enableDebuggingLogs | A boolean indicating whether to log debugging events | Optional | false |
| #retry | A block that can configure the internal `Retry` instance | Optional | `[:action | ]` |

0 comments on commit b3878df

Please sign in to comment.