message-driver 0.1.0 → 0.2.0.rc1
Sign up to get free protection for your applications and to get access to all the features.
- checksums.yaml +7 -0
- data/.gitignore +1 -0
- data/.travis.yml +18 -7
- data/CHANGELOG.md +12 -2
- data/Gemfile +17 -0
- data/Guardfile +8 -4
- data/README.md +14 -5
- data/Rakefile +44 -11
- data/examples/basic_producer_and_consumer/Gemfile +5 -0
- data/examples/basic_producer_and_consumer/common.rb +17 -0
- data/examples/basic_producer_and_consumer/consumer.rb +24 -0
- data/examples/basic_producer_and_consumer/producer.rb +33 -0
- data/features/.nav +8 -0
- data/features/CHANGELOG.md +12 -2
- data/features/amqp_specific_features/binding_amqp_destinations.feature +7 -7
- data/features/amqp_specific_features/declaring_amqp_exchanges.feature +3 -3
- data/features/amqp_specific_features/nack_redelivered_messages.feature +92 -0
- data/features/amqp_specific_features/requeueing_on_nack.feature +44 -0
- data/features/amqp_specific_features/server_named_destinations.feature +5 -5
- data/features/client_acks.feature +92 -0
- data/features/destination_metadata.feature +9 -11
- data/features/dynamic_destinations.feature +7 -7
- data/features/error_handling.feature +11 -9
- data/features/logging.feature +14 -0
- data/features/message_consumers/auto_ack_consumers.feature +79 -0
- data/features/message_consumers/manual_ack_consumers.feature +95 -0
- data/features/message_consumers/transactional_ack_consumers.feature +77 -0
- data/features/message_consumers.feature +54 -0
- data/features/publishing_a_message.feature +6 -10
- data/features/publishing_with_transactions.feature +10 -14
- data/features/rabbitmq_specific_features/dead_letter_queueing.feature +116 -0
- data/features/step_definitions/dynamic_destinations_steps.rb +3 -3
- data/features/step_definitions/error_handling_steps.rb +4 -2
- data/features/step_definitions/logging_steps.rb +28 -0
- data/features/step_definitions/message_consumers_steps.rb +29 -0
- data/features/step_definitions/steps.rb +60 -9
- data/features/support/broker_config_helper.rb +19 -0
- data/features/support/env.rb +1 -0
- data/features/support/firewall_helper.rb +8 -11
- data/features/support/message_table_matcher.rb +21 -5
- data/features/support/test_runner.rb +39 -16
- data/lib/message_driver/adapters/base.rb +51 -4
- data/lib/message_driver/adapters/bunny_adapter.rb +251 -127
- data/lib/message_driver/adapters/in_memory_adapter.rb +97 -18
- data/lib/message_driver/adapters/stomp_adapter.rb +127 -0
- data/lib/message_driver/broker.rb +23 -24
- data/lib/message_driver/client.rb +157 -0
- data/lib/message_driver/destination.rb +7 -4
- data/lib/message_driver/errors.rb +27 -0
- data/lib/message_driver/logging.rb +11 -0
- data/lib/message_driver/message.rb +8 -0
- data/lib/message_driver/subscription.rb +18 -0
- data/lib/message_driver/vendor/.document +0 -0
- data/lib/message_driver/vendor/nesty/nested_error.rb +26 -0
- data/lib/message_driver/vendor/nesty.rb +1 -0
- data/lib/message_driver/version.rb +1 -1
- data/lib/message_driver.rb +4 -2
- data/message-driver.gemspec +4 -4
- data/spec/integration/{amqp_integration_spec.rb → bunny/amqp_integration_spec.rb} +29 -28
- data/spec/integration/bunny/bunny_adapter_spec.rb +339 -0
- data/spec/integration/in_memory/in_memory_adapter_spec.rb +126 -0
- data/spec/integration/stomp/stomp_adapter_spec.rb +142 -0
- data/spec/spec_helper.rb +5 -2
- data/spec/support/shared/adapter_examples.rb +17 -0
- data/spec/support/shared/client_ack_examples.rb +18 -0
- data/spec/support/shared/context_examples.rb +14 -0
- data/spec/support/shared/destination_examples.rb +4 -5
- data/spec/support/shared/subscription_examples.rb +146 -0
- data/spec/support/shared/transaction_examples.rb +43 -0
- data/spec/support/utils.rb +14 -0
- data/spec/units/message_driver/adapters/base_spec.rb +38 -19
- data/spec/units/message_driver/broker_spec.rb +71 -18
- data/spec/units/message_driver/client_spec.rb +375 -0
- data/spec/units/message_driver/destination_spec.rb +9 -0
- data/spec/units/message_driver/logging_spec.rb +18 -0
- data/spec/units/message_driver/message_spec.rb +36 -0
- data/spec/units/message_driver/subscription_spec.rb +24 -0
- data/test_lib/broker_config.rb +50 -20
- metadata +83 -45
- data/.rbenv-version +0 -1
- data/lib/message_driver/exceptions.rb +0 -18
- data/lib/message_driver/message_publisher.rb +0 -15
- data/spec/integration/message_driver/adapters/bunny_adapter_spec.rb +0 -301
- data/spec/units/message_driver/adapters/in_memory_adapter_spec.rb +0 -43
- data/spec/units/message_driver/message_publisher_spec.rb +0 -65
@@ -0,0 +1,92 @@
|
|
1
|
+
@bunny
|
2
|
+
Feature: Client Acks
|
3
|
+
Support for doing client acks on messages
|
4
|
+
|
5
|
+
Background:
|
6
|
+
Given I am connected to the broker
|
7
|
+
And I have a destination :source_queue
|
8
|
+
And I have the following messages on :source_queue
|
9
|
+
| body |
|
10
|
+
| Test Message |
|
11
|
+
|
12
|
+
|
13
|
+
Scenario: Calling ack on the message to acknowledge it
|
14
|
+
When I execute the following code
|
15
|
+
"""ruby
|
16
|
+
message = MessageDriver::Client.pop_message(:source_queue, client_ack: true)
|
17
|
+
message.ack
|
18
|
+
"""
|
19
|
+
|
20
|
+
Then I expect to find no messages on :source_queue
|
21
|
+
|
22
|
+
|
23
|
+
Scenario: Calling nack on the message to put it back on the queue
|
24
|
+
When I execute the following code
|
25
|
+
"""ruby
|
26
|
+
message = MessageDriver::Client.pop_message(:source_queue, client_ack: true)
|
27
|
+
message.nack
|
28
|
+
"""
|
29
|
+
|
30
|
+
Then I expect to find the following message on :source_queue
|
31
|
+
| body |
|
32
|
+
| Test Message |
|
33
|
+
|
34
|
+
|
35
|
+
Scenario: Acking in a transaction that commits
|
36
|
+
When I execute the following code
|
37
|
+
"""ruby
|
38
|
+
MessageDriver::Client.with_message_transaction do
|
39
|
+
message = MessageDriver::Client.pop_message(:source_queue, client_ack: true)
|
40
|
+
message.ack
|
41
|
+
end
|
42
|
+
"""
|
43
|
+
|
44
|
+
Then I expect to find no messages on :source_queue
|
45
|
+
|
46
|
+
|
47
|
+
Scenario: Nacking in a transaction that commits
|
48
|
+
When I execute the following code
|
49
|
+
"""ruby
|
50
|
+
MessageDriver::Client.with_message_transaction do
|
51
|
+
message = MessageDriver::Client.pop_message(:source_queue, client_ack: true)
|
52
|
+
message.nack
|
53
|
+
end
|
54
|
+
"""
|
55
|
+
|
56
|
+
Then I expect to find the following message on :source_queue
|
57
|
+
| body |
|
58
|
+
| Test Message |
|
59
|
+
|
60
|
+
|
61
|
+
Scenario: Acking in a transaction that rolls back
|
62
|
+
When I execute the following code
|
63
|
+
"""ruby
|
64
|
+
MessageDriver::Client.with_message_transaction do
|
65
|
+
message = MessageDriver::Client.pop_message(:source_queue, client_ack: true)
|
66
|
+
message.ack
|
67
|
+
raise "rollback the transaction"
|
68
|
+
end
|
69
|
+
"""
|
70
|
+
And I reset the context
|
71
|
+
|
72
|
+
Then I expect it to raise "rollback the transaction"
|
73
|
+
And I expect to find the following message on :source_queue
|
74
|
+
| body |
|
75
|
+
| Test Message |
|
76
|
+
|
77
|
+
|
78
|
+
Scenario: Nacking in a transaction that rolls back
|
79
|
+
When I execute the following code
|
80
|
+
"""ruby
|
81
|
+
MessageDriver::Client.with_message_transaction do
|
82
|
+
message = MessageDriver::Client.pop_message(:source_queue, client_ack: true)
|
83
|
+
message.nack
|
84
|
+
raise "rollback the transaction"
|
85
|
+
end
|
86
|
+
"""
|
87
|
+
And I reset the context
|
88
|
+
|
89
|
+
Then I expect it to raise "rollback the transaction"
|
90
|
+
And I expect to find the following message on :source_queue
|
91
|
+
| body |
|
92
|
+
| Test Message |
|
@@ -2,15 +2,11 @@
|
|
2
2
|
@in_memory
|
3
3
|
Feature: Destination Metadata
|
4
4
|
Background:
|
5
|
-
Given the
|
6
|
-
|
7
|
-
MessageDriver::Broker.define do |b|
|
8
|
-
b.destination :my_queue, "my_queue", exclusive: true
|
9
|
-
end
|
10
|
-
"""
|
5
|
+
Given I am connected to the broker
|
6
|
+
And I have a destination :my_queue with no messages on it
|
11
7
|
|
12
8
|
Scenario: Checking the message count when the queue is empty
|
13
|
-
When I execute the following code
|
9
|
+
When I execute the following code
|
14
10
|
"""ruby
|
15
11
|
destination = MessageDriver::Broker.find_destination(:my_queue)
|
16
12
|
expect(destination.message_count).to eq(0)
|
@@ -19,12 +15,14 @@ Feature: Destination Metadata
|
|
19
15
|
Then I expect to have no errors
|
20
16
|
And I expect to find no messages on :my_queue
|
21
17
|
|
22
|
-
@no_travis
|
23
18
|
Scenario: Checking the message count when the queue has messages
|
24
|
-
When I
|
19
|
+
When I send the following messages to :my_queue
|
20
|
+
| body |
|
21
|
+
| Test Message 1 |
|
22
|
+
| Test Message 2 |
|
23
|
+
And I allow for processing
|
24
|
+
And I execute the following code
|
25
25
|
"""ruby
|
26
|
-
publish(:my_queue, "test message 1")
|
27
|
-
publish(:my_queue, "test message 2")
|
28
26
|
destination = MessageDriver::Broker.find_destination(:my_queue)
|
29
27
|
expect(destination.message_count).to eq(2)
|
30
28
|
"""
|
@@ -1,6 +1,6 @@
|
|
1
1
|
@all_adapters
|
2
2
|
Feature: Dynamic Destinations
|
3
|
-
|
3
|
+
Sometimes you want to connect to a queue that has some of it's characteristics
|
4
4
|
determined at runtime. Dynamic destinations allow you to do with without
|
5
5
|
leaking tons of destination definitions.
|
6
6
|
|
@@ -8,25 +8,25 @@ Feature: Dynamic Destinations
|
|
8
8
|
Given I am connected to the broker
|
9
9
|
|
10
10
|
Scenario: Sending to a dynamic destination
|
11
|
-
When I execute the following code
|
11
|
+
When I execute the following code
|
12
12
|
"""ruby
|
13
|
-
my_new_destination = MessageDriver::Broker.dynamic_destination("temp_queue"
|
13
|
+
my_new_destination = MessageDriver::Broker.dynamic_destination("temp_queue")
|
14
14
|
my_new_destination.publish("Test Message")
|
15
15
|
"""
|
16
16
|
|
17
|
-
Then I expect to find 1 message on the dynamic destination "temp_queue" with
|
17
|
+
Then I expect to find 1 message on the dynamic destination "temp_queue" with
|
18
18
|
| body |
|
19
19
|
| Test Message |
|
20
20
|
|
21
21
|
Scenario: Poping messages off a dynamic destination
|
22
|
-
Given I have a dynamic destination "temp_queue" with the following messages on it
|
22
|
+
Given I have a dynamic destination "temp_queue" with the following messages on it
|
23
23
|
| body |
|
24
24
|
| Test Message 1 |
|
25
25
|
| Test Message 2 |
|
26
26
|
|
27
|
-
When I execute the following code
|
27
|
+
When I execute the following code
|
28
28
|
"""ruby
|
29
|
-
my_new_destination = MessageDriver::Broker.dynamic_destination("temp_queue"
|
29
|
+
my_new_destination = MessageDriver::Broker.dynamic_destination("temp_queue")
|
30
30
|
|
31
31
|
msg1 = my_new_destination.pop_message
|
32
32
|
expect(msg1.body).to eq("Test Message 1")
|
@@ -5,42 +5,44 @@ Feature: Error Handling
|
|
5
5
|
|
6
6
|
@bunny
|
7
7
|
Scenario: Queue isn't found on the broker
|
8
|
-
When I execute the following code
|
8
|
+
When I execute the following code
|
9
9
|
"""ruby
|
10
10
|
MessageDriver::Broker.dynamic_destination("missing_queue", passive: true)
|
11
11
|
"""
|
12
12
|
|
13
13
|
Then I expect it to raise a MessageDriver::QueueNotFound error
|
14
14
|
|
15
|
-
@
|
15
|
+
@no_ci
|
16
16
|
@bunny
|
17
|
+
@slow
|
17
18
|
Scenario: The broker goes down
|
18
|
-
Given the following broker configuration
|
19
|
+
Given the following broker configuration
|
19
20
|
"""ruby
|
20
21
|
MessageDriver::Broker.define do |b|
|
21
|
-
b.destination :my_queue, "broker_down_queue", arguments: {:'x-expires' =>
|
22
|
+
b.destination :my_queue, "broker_down_queue", durable: true, arguments: {:'x-expires' => 1000*60*10 } #expires in 10 minutes
|
22
23
|
end
|
23
24
|
"""
|
25
|
+
And I have no messages on :my_queue
|
24
26
|
|
25
|
-
When I execute the following code
|
27
|
+
When I execute the following code
|
26
28
|
"""ruby
|
27
29
|
publish(:my_queue, "Test Message 1")
|
28
30
|
"""
|
29
31
|
And the broker goes down
|
30
|
-
And I execute the following code
|
32
|
+
And I execute the following code
|
31
33
|
"""ruby
|
32
34
|
publish(:my_queue, "Test Message 2")
|
33
35
|
"""
|
34
|
-
Then I expect it to raise a MessageDriver::
|
36
|
+
Then I expect it to raise a MessageDriver::ConnectionError error
|
35
37
|
|
36
38
|
When the broker comes up
|
37
|
-
And I execute the following code
|
39
|
+
And I execute the following code
|
38
40
|
"""ruby
|
39
41
|
publish(:my_queue, "Test Message 3")
|
40
42
|
"""
|
41
43
|
|
42
44
|
Then I expect to have no errors
|
43
|
-
And I expect to find 2 messages on :my_queue
|
45
|
+
And I expect to find the following 2 messages on :my_queue
|
44
46
|
| body |
|
45
47
|
| Test Message 1 |
|
46
48
|
| Test Message 3 |
|
@@ -0,0 +1,14 @@
|
|
1
|
+
@all_adapters
|
2
|
+
Feature: Stuff gets logged if you set a logger
|
3
|
+
|
4
|
+
You can configure the logger by add a logger to the hash passed to `MessageDriver::Broker.configure`.
|
5
|
+
If you don't provide a logger, then an info level logger will be created and sent to `STDOUT`.
|
6
|
+
|
7
|
+
Scenario: Starting the broker
|
8
|
+
Given I am logging to a log file at the debug level
|
9
|
+
And I am connected to the broker
|
10
|
+
|
11
|
+
Then the log file should contain:
|
12
|
+
"""
|
13
|
+
MessageDriver configured successfully!
|
14
|
+
"""
|
@@ -0,0 +1,79 @@
|
|
1
|
+
@bunny
|
2
|
+
Feature: Message Consumers auto-acknowledgement
|
3
|
+
This mode will ack the message if the consumer completes successfully.
|
4
|
+
It will nack the message if the consumer raises an error.
|
5
|
+
|
6
|
+
Background:
|
7
|
+
Given I am connected to the broker
|
8
|
+
And I have a destination :dest_queue with no messages on it
|
9
|
+
And I have a destination :source_queue with no messages on it
|
10
|
+
|
11
|
+
Scenario: Consuming Messages
|
12
|
+
Given I have a message consumer
|
13
|
+
"""ruby
|
14
|
+
MessageDriver::Broker.consumer(:my_consumer) do |message|
|
15
|
+
MessageDriver::Client.publish(:dest_queue, message.body)
|
16
|
+
end
|
17
|
+
"""
|
18
|
+
And I create a subscription
|
19
|
+
"""ruby
|
20
|
+
MessageDriver::Client.subscribe(:source_queue, :my_consumer, ack: :auto)
|
21
|
+
"""
|
22
|
+
|
23
|
+
When I send the following messages to :source_queue
|
24
|
+
| body |
|
25
|
+
| Auto Ack 1 |
|
26
|
+
| Auto Ack 2 |
|
27
|
+
And I let the subscription process
|
28
|
+
|
29
|
+
Then I expect to find no messages on :source_queue
|
30
|
+
And I expect to find the following 2 messages on :dest_queue
|
31
|
+
| body |
|
32
|
+
| Auto Ack 1 |
|
33
|
+
| Auto Ack 2 |
|
34
|
+
|
35
|
+
|
36
|
+
Scenario: An error occurs during processing
|
37
|
+
Given I have a message consumer
|
38
|
+
"""ruby
|
39
|
+
MessageDriver::Broker.consumer(:my_consumer) do |message|
|
40
|
+
raise "oh nos!"
|
41
|
+
end
|
42
|
+
"""
|
43
|
+
And I create a subscription
|
44
|
+
"""ruby
|
45
|
+
MessageDriver::Client.subscribe(:source_queue, :my_consumer, ack: :auto)
|
46
|
+
"""
|
47
|
+
|
48
|
+
When I send the following messages to :source_queue
|
49
|
+
| body |
|
50
|
+
| Auto Ack Error 1 |
|
51
|
+
| Auto Ack Error 2 |
|
52
|
+
And I let the subscription process
|
53
|
+
|
54
|
+
Then I expect to find no messages on :dest_queue
|
55
|
+
And I expect to find the following 2 messages on :source_queue
|
56
|
+
| body |
|
57
|
+
| Auto Ack Error 1 |
|
58
|
+
| Auto Ack Error 2 |
|
59
|
+
|
60
|
+
Scenario: A DontRequeue error occurs during processing
|
61
|
+
Given I have a message consumer
|
62
|
+
"""ruby
|
63
|
+
MessageDriver::Broker.consumer(:my_consumer) do |message|
|
64
|
+
raise MessageDriver::DontRequeueError, "don't requeue me"
|
65
|
+
end
|
66
|
+
"""
|
67
|
+
And I create a subscription
|
68
|
+
"""ruby
|
69
|
+
MessageDriver::Client.subscribe(:source_queue, :my_consumer, ack: :auto)
|
70
|
+
"""
|
71
|
+
|
72
|
+
When I send the following messages to :source_queue
|
73
|
+
| body |
|
74
|
+
| Auto Ack Error 1 |
|
75
|
+
| Auto Ack Error 2 |
|
76
|
+
And I let the subscription process
|
77
|
+
|
78
|
+
Then I expect to find no messages on :dest_queue
|
79
|
+
And I expect to find no messages on :source_queue
|
@@ -0,0 +1,95 @@
|
|
1
|
+
@bunny
|
2
|
+
Feature: Message Consumers with manual acknowledgement
|
3
|
+
This mode requires the consumer to call ack on the message in order to acknowledge it
|
4
|
+
|
5
|
+
Background:
|
6
|
+
Given I am connected to the broker
|
7
|
+
And I have a destination :source_queue with no messages on it
|
8
|
+
|
9
|
+
Scenario: Consuming Messages
|
10
|
+
Given I have a message consumer
|
11
|
+
"""ruby
|
12
|
+
MessageDriver::Broker.consumer(:my_consumer) do |message|
|
13
|
+
message.ack
|
14
|
+
end
|
15
|
+
"""
|
16
|
+
And I create a subscription
|
17
|
+
"""ruby
|
18
|
+
MessageDriver::Client.subscribe(:source_queue, :my_consumer, ack: :manual)
|
19
|
+
"""
|
20
|
+
|
21
|
+
When I send the following messages to :source_queue
|
22
|
+
| body |
|
23
|
+
| Test Message 1 |
|
24
|
+
| Test Message 2 |
|
25
|
+
And I let the subscription process
|
26
|
+
|
27
|
+
Then I expect to find no messages on :source_queue
|
28
|
+
|
29
|
+
Scenario: When a message is nack'ed
|
30
|
+
Given I have a message consumer
|
31
|
+
"""ruby
|
32
|
+
MessageDriver::Broker.consumer(:my_consumer) do |message|
|
33
|
+
message.nack(requeue: true)
|
34
|
+
end
|
35
|
+
"""
|
36
|
+
And I create a subscription
|
37
|
+
"""ruby
|
38
|
+
MessageDriver::Client.subscribe(:source_queue, :my_consumer, ack: :manual)
|
39
|
+
"""
|
40
|
+
|
41
|
+
When I send the following messages to :source_queue
|
42
|
+
| body |
|
43
|
+
| Test Message 1 |
|
44
|
+
| Test Message 2 |
|
45
|
+
And I let the subscription process
|
46
|
+
|
47
|
+
Then I expect to find the following 2 messages on :source_queue
|
48
|
+
| body |
|
49
|
+
| Test Message 1 |
|
50
|
+
| Test Message 2 |
|
51
|
+
|
52
|
+
Scenario: When an occurs before the message is ack'ed
|
53
|
+
Given I have a message consumer
|
54
|
+
"""ruby
|
55
|
+
MessageDriver::Broker.consumer(:my_consumer) do |message|
|
56
|
+
raise "oh nos!"
|
57
|
+
message.ack
|
58
|
+
end
|
59
|
+
"""
|
60
|
+
And I create a subscription
|
61
|
+
"""ruby
|
62
|
+
MessageDriver::Client.subscribe(:source_queue, :my_consumer, ack: :manual)
|
63
|
+
"""
|
64
|
+
|
65
|
+
When I send the following messages to :source_queue
|
66
|
+
| body |
|
67
|
+
| Test Message 1 |
|
68
|
+
| Test Message 2 |
|
69
|
+
And I let the subscription process
|
70
|
+
|
71
|
+
Then I expect to find the following 2 messages on :source_queue
|
72
|
+
| body |
|
73
|
+
| Test Message 1 |
|
74
|
+
| Test Message 2 |
|
75
|
+
|
76
|
+
Scenario: When an error occurs after the message is ack'ed
|
77
|
+
Given I have a message consumer
|
78
|
+
"""ruby
|
79
|
+
MessageDriver::Broker.consumer(:my_consumer) do |message|
|
80
|
+
message.ack
|
81
|
+
raise "oh nos!"
|
82
|
+
end
|
83
|
+
"""
|
84
|
+
And I create a subscription
|
85
|
+
"""ruby
|
86
|
+
MessageDriver::Client.subscribe(:source_queue, :my_consumer, ack: :manual)
|
87
|
+
"""
|
88
|
+
|
89
|
+
When I send the following messages to :source_queue
|
90
|
+
| body |
|
91
|
+
| Test Message 1 |
|
92
|
+
| Test Message 2 |
|
93
|
+
And I let the subscription process
|
94
|
+
|
95
|
+
Then I expect to find no messages on :source_queue
|
@@ -0,0 +1,77 @@
|
|
1
|
+
@bunny
|
2
|
+
Feature: Transactional Message Consumers
|
3
|
+
Background:
|
4
|
+
Given I am connected to the broker
|
5
|
+
And I have a destination :dest_queue with no messages on it
|
6
|
+
And I have a destination :source_queue with no messages on it
|
7
|
+
|
8
|
+
Scenario: Consuming Messages within a transaction
|
9
|
+
Given I have a message consumer
|
10
|
+
"""ruby
|
11
|
+
MessageDriver::Broker.consumer(:my_consumer) do |message|
|
12
|
+
MessageDriver::Client.publish(:dest_queue, message.body)
|
13
|
+
end
|
14
|
+
"""
|
15
|
+
And I create a subscription
|
16
|
+
"""ruby
|
17
|
+
MessageDriver::Client.subscribe(:source_queue, :my_consumer, ack: :transactional)
|
18
|
+
"""
|
19
|
+
|
20
|
+
When I send the following messages to :source_queue
|
21
|
+
| body |
|
22
|
+
| Test Message 1 |
|
23
|
+
| Test Message 2 |
|
24
|
+
And I let the subscription process
|
25
|
+
|
26
|
+
Then I expect to find no messages on :source_queue
|
27
|
+
And I expect to find the following 2 messages on :dest_queue
|
28
|
+
| body |
|
29
|
+
| Test Message 1 |
|
30
|
+
| Test Message 2 |
|
31
|
+
|
32
|
+
Scenario: When an error occurs
|
33
|
+
Given I have a message consumer
|
34
|
+
"""ruby
|
35
|
+
MessageDriver::Broker.consumer(:my_consumer) do |message|
|
36
|
+
MessageDriver::Client.publish(:dest_queue, message.body)
|
37
|
+
raise "oh nos!"
|
38
|
+
end
|
39
|
+
"""
|
40
|
+
And I create a subscription
|
41
|
+
"""ruby
|
42
|
+
MessageDriver::Client.subscribe(:source_queue, :my_consumer, ack: :transactional)
|
43
|
+
"""
|
44
|
+
|
45
|
+
When I send the following messages to :source_queue
|
46
|
+
| body |
|
47
|
+
| Test Message 1 |
|
48
|
+
| Test Message 2 |
|
49
|
+
And I let the subscription process
|
50
|
+
|
51
|
+
Then I expect to find the following 2 messages on :source_queue
|
52
|
+
| body |
|
53
|
+
| Test Message 1 |
|
54
|
+
| Test Message 2 |
|
55
|
+
And I expect to find no messages on :dest_queue
|
56
|
+
|
57
|
+
Scenario: When a DontRequeue error occurs
|
58
|
+
Given I have a message consumer
|
59
|
+
"""ruby
|
60
|
+
MessageDriver::Broker.consumer(:my_consumer) do |message|
|
61
|
+
MessageDriver::Client.publish(:dest_queue, message.body)
|
62
|
+
raise MessageDriver::DontRequeueError, "don't requeue me"
|
63
|
+
end
|
64
|
+
"""
|
65
|
+
And I create a subscription
|
66
|
+
"""ruby
|
67
|
+
MessageDriver::Client.subscribe(:source_queue, :my_consumer, ack: :transactional)
|
68
|
+
"""
|
69
|
+
|
70
|
+
When I send the following messages to :source_queue
|
71
|
+
| body |
|
72
|
+
| Test Message 1 |
|
73
|
+
| Test Message 2 |
|
74
|
+
And I let the subscription process
|
75
|
+
|
76
|
+
Then I expect to find no messages on :source_queue
|
77
|
+
And I expect to find no messages on :dest_queue
|
@@ -0,0 +1,54 @@
|
|
1
|
+
@in_memory
|
2
|
+
@bunny
|
3
|
+
Feature: Message Consumers
|
4
|
+
Background:
|
5
|
+
Given I am connected to the broker
|
6
|
+
And I have a destination :dest_queue with no messages on it
|
7
|
+
And I have a destination :source_queue with no messages on it
|
8
|
+
And I have a message consumer
|
9
|
+
"""ruby
|
10
|
+
MessageDriver::Broker.consumer(:my_consumer) do |message|
|
11
|
+
MessageDriver::Client.publish(:dest_queue, message.body)
|
12
|
+
end
|
13
|
+
"""
|
14
|
+
And I create a subscription
|
15
|
+
"""ruby
|
16
|
+
MessageDriver::Client.subscribe(:source_queue, :my_consumer)
|
17
|
+
"""
|
18
|
+
|
19
|
+
|
20
|
+
Scenario: Consuming Messages
|
21
|
+
When I send the following messages to :source_queue
|
22
|
+
| body |
|
23
|
+
| Test Message 1 |
|
24
|
+
| Test Message 2 |
|
25
|
+
And I let the subscription process
|
26
|
+
|
27
|
+
Then I expect to find no messages on :source_queue
|
28
|
+
And I expect to find the following 2 messages on :dest_queue
|
29
|
+
| body |
|
30
|
+
| Test Message 1 |
|
31
|
+
| Test Message 2 |
|
32
|
+
|
33
|
+
|
34
|
+
Scenario: Ending a subscription
|
35
|
+
When I send the following messages to :source_queue
|
36
|
+
| body |
|
37
|
+
| Test Message 1 |
|
38
|
+
| Test Message 2 |
|
39
|
+
And I allow for processing
|
40
|
+
And I cancel the subscription
|
41
|
+
And I send the following messages to :source_queue
|
42
|
+
| body |
|
43
|
+
| Test Message 3 |
|
44
|
+
| Test Message 4 |
|
45
|
+
|
46
|
+
Then I expect to find the following 2 messages on :dest_queue
|
47
|
+
| body |
|
48
|
+
| Test Message 1 |
|
49
|
+
| Test Message 2 |
|
50
|
+
|
51
|
+
And I expect to find the following 2 messages on :source_queue
|
52
|
+
| body |
|
53
|
+
| Test Message 3 |
|
54
|
+
| Test Message 4 |
|
@@ -1,19 +1,15 @@
|
|
1
1
|
@all_adapters
|
2
2
|
Feature: Publishing A Message
|
3
3
|
Background:
|
4
|
-
Given the
|
5
|
-
|
6
|
-
MessageDriver::Broker.define do |b|
|
7
|
-
b.destination :my_queue, "my_queue", exclusive: true
|
8
|
-
end
|
9
|
-
"""
|
4
|
+
Given I am connected to the broker
|
5
|
+
And I have a destination :publish_test with no messages on it
|
10
6
|
|
11
|
-
Scenario:
|
12
|
-
When I execute the following code
|
7
|
+
Scenario: Publishing a message
|
8
|
+
When I execute the following code
|
13
9
|
"""ruby
|
14
|
-
publish(:
|
10
|
+
publish(:publish_test, "Test Message")
|
15
11
|
"""
|
16
12
|
|
17
|
-
Then I expect to find
|
13
|
+
Then I expect to find the following message on :publish_test
|
18
14
|
| body |
|
19
15
|
| Test Message |
|
@@ -1,36 +1,32 @@
|
|
1
1
|
@bunny
|
2
2
|
Feature: Publishing a Message within a Transaction
|
3
3
|
Background:
|
4
|
-
Given the
|
5
|
-
|
6
|
-
MessageDriver::Broker.define do |b|
|
7
|
-
b.destination :my_queue, "my_queue", exclusive: true
|
8
|
-
end
|
9
|
-
"""
|
4
|
+
Given I am connected to the broker
|
5
|
+
And I have a destination :publish_transaction with no messages on it
|
10
6
|
|
11
7
|
Scenario: The block completes successfully
|
12
|
-
When I execute the following code
|
8
|
+
When I execute the following code
|
13
9
|
"""ruby
|
14
10
|
with_message_transaction do
|
15
|
-
publish(:
|
16
|
-
publish(:
|
11
|
+
publish(:publish_transaction, "Transacted Message 1")
|
12
|
+
publish(:publish_transaction, "Transacted Message 2")
|
17
13
|
end
|
18
14
|
"""
|
19
15
|
|
20
|
-
Then I expect to find 2 messages on :
|
16
|
+
Then I expect to find the following 2 messages on :publish_transaction
|
21
17
|
| body |
|
22
18
|
| Transacted Message 1 |
|
23
19
|
| Transacted Message 2 |
|
24
20
|
|
25
21
|
Scenario: An error is raised inside the block
|
26
|
-
When I execute the following code
|
22
|
+
When I execute the following code
|
27
23
|
"""ruby
|
28
24
|
with_message_transaction do
|
29
|
-
publish(:
|
25
|
+
publish(:publish_transaction, "Transacted Message 1")
|
30
26
|
raise "an error that causes a rollback"
|
31
|
-
publish(:
|
27
|
+
publish(:publish_transaction, "Transacted Message 2")
|
32
28
|
end
|
33
29
|
"""
|
34
30
|
|
35
31
|
Then I expect it to raise "an error that causes a rollback"
|
36
|
-
And I expect to find no messages on :
|
32
|
+
And I expect to find no messages on :publish_transaction
|