From 0892135ae5ab556f651b70039d9edec07045a4c5 Mon Sep 17 00:00:00 2001 From: Juan Vanecek Date: Tue, 3 Sep 2024 17:35:55 -0300 Subject: [PATCH] Unbind queue before worker termination --- source/Ansible-RabbitMQ-Tests/RabbitMQClientTest.class.st | 5 ++++- source/Ansible-RabbitMQ/RabbitMQWorker.class.st | 8 +++++++- 2 files changed, 11 insertions(+), 2 deletions(-) diff --git a/source/Ansible-RabbitMQ-Tests/RabbitMQClientTest.class.st b/source/Ansible-RabbitMQ-Tests/RabbitMQClientTest.class.st index 5726462..5337190 100644 --- a/source/Ansible-RabbitMQ-Tests/RabbitMQClientTest.class.st +++ b/source/Ansible-RabbitMQ-Tests/RabbitMQClientTest.class.st @@ -216,7 +216,10 @@ RabbitMQClientTest >> runWorkerNamed: aName consumingFrom: aQueueName bindedTo: ] processingPayloadWith: aProcessingBlock. worker bindQueueTo: anExchange routedBy: aRoutingKey. - [ worker start ] ensure: [ worker stop ] + [ worker start ] ensure: [ + worker unbindQueueTo: anExchange routedBy: aRoutingKey. + worker stop + ] ] newProcess. process name: aName; diff --git a/source/Ansible-RabbitMQ/RabbitMQWorker.class.st b/source/Ansible-RabbitMQ/RabbitMQWorker.class.st index c52e956..bb5ea31 100644 --- a/source/Ansible-RabbitMQ/RabbitMQWorker.class.st +++ b/source/Ansible-RabbitMQ/RabbitMQWorker.class.st @@ -41,7 +41,7 @@ RabbitMQWorker class >> configuredBy: aConfigurationAction processingPayloadWith processingMessagesWith: [ :message | aPayloadProcessor value: message body ] ] -{ #category : 'Configuring' } +{ #category : 'configuring' } RabbitMQWorker >> bindQueueTo: anExchange routedBy: aRoutingKey [ self @@ -144,3 +144,9 @@ RabbitMQWorker >> startProcessing [ ] ] repeat ] + +{ #category : 'configuring' } +RabbitMQWorker >> unbindQueueTo: anExchange routedBy: aRoutingKey [ + + channel queueUnbind: self queueName exchange: anExchange routingKey: aRoutingKey +]