To add a collaborator to this project you will need to use the Relish gem to add the collaborator via a terminal command. Soon you'll be able to also add collaborators here!
More about adding a collaboratorMiddleware with Blocks
You can also create middleware by passing a hash with blocks as the input to
append or prepend
- Background
-
- Given
- I am connected to the broker
- And
- I have a destination :middleware_queue with no messages on it
- Scenarios
-
- providing an on_publish block
- providing an on_consume block
- providing an on_consume block and an on_publish block
- providing an on_publish block
-
- When
-
I execute the following code
destination = MessageDriver::Client.find_destination(:middleware_queue) destination.middleware.append on_publish: ->(body, headers, properties) { [body+' published with a block!', headers, properties] }
- And
-
I send the following messages to :middleware_queue
body Test Message 1 Test Message 2 - Then
-
I expect to find the following 2 messages on :middleware_queue
raw_body Test Message 1 published with a block! Test Message 2 published with a block!
- providing an on_consume block
-
- Given
- I have a destination :dest_queue with no messages on it
- When
-
I execute the following code
destination = MessageDriver::Client.find_destination(:middleware_queue) destination.middleware.append on_consume: ->(body, headers, properties) { [body+' consumed with a block!', headers, properties] }
- And
-
I send the following messages to :middleware_queue
body Test Message 1 Test Message 2 - And
-
I create a subscription
MessageDriver::Client.subscribe_with(:middleware_queue) do |message| MessageDriver::Client.publish(:dest_queue, message.body) end
- And
- I let the subscription process
- Then
- I expect to find no messages on :middleware_queue
- And
-
I expect to find the following 2 messages on :dest_queue
raw_body Test Message 1 consumed with a block! Test Message 2 consumed with a block!
- providing an on_consume block and an on_publish block
-
- Given
- I have a destination :dest_queue with no messages on it
- When
-
I execute the following code
destination = MessageDriver::Client.find_destination(:middleware_queue) destination.middleware.append(on_consume: ->(body, headers, properties) { [body + ' consumed', headers, properties] }, on_publish: ->(body, headers, properties) { ['published ' + body, headers, properties] })
- And
-
I send the following messages to :middleware_queue
body Test Message 1 Test Message 2 - And
-
I create a subscription
MessageDriver::Client.subscribe_with(:middleware_queue) do |message| MessageDriver::Client.publish(:dest_queue, message.body) end
- And
- I let the subscription process
- Then
- I expect to find no messages on :middleware_queue
- And
-
I expect to find the following 2 messages on :dest_queue
raw_body published Test Message 1 consumed published Test Message 2 consumed
Last published about 7 years ago by soupmatt.