File tree 3 files changed +26
-4
lines changed
Client/ConsumptionExtension
Tests/Client/ConsumptionExtension
3 files changed +26
-4
lines changed Original file line number Diff line number Diff line change @@ -45,6 +45,9 @@ public function onPreReceived(Context $context)
45
45
if (false == $ message ->isRedelivered ()) {
46
46
return ;
47
47
}
48
+ if (false != $ context ->getResult ()) {
49
+ return ;
50
+ }
48
51
49
52
$ delayedMessage = $ this ->driver ->createClientMessage ($ message );
50
53
Original file line number Diff line number Diff line change @@ -24,17 +24,17 @@ public function onBeforeReceive(Context $context);
24
24
/**
25
25
* Executed when a new message is received from a broker but before it was passed to processor
26
26
* The context contains a message.
27
- * The extension may set a status.
28
- * The consumption could be interrupted at this step but it will done only after the message is processed.
27
+ * The extension may set a status. If the status is set the exception is thrown
28
+ * The consumption could be interrupted at this step but it exits after the message is processed.
29
29
*
30
30
* @param Context $context
31
31
*/
32
32
public function onPreReceived (Context $ context );
33
33
34
34
/**
35
35
* Executed when a message is processed by a processor.
36
- * The context contains a message status and could be changed
37
- * The consumption could be interrupted at this step but it will done only after the message is processed.
36
+ * The context contains a status, which could not be changed.
37
+ * The consumption could be interrupted at this step but it exits after the message is processed.
38
38
*
39
39
* @param Context $context
40
40
*/
Original file line number Diff line number Diff line change @@ -97,6 +97,25 @@ public function testShouldDoNothingIfMessageIsNotRedelivered()
97
97
self ::assertNull ($ context ->getResult ());
98
98
}
99
99
100
+ public function testShouldDoNothingIfMessageIsRedeliveredButResultWasAlreadySetOnContext ()
101
+ {
102
+ $ message = new NullMessage ();
103
+ $ message ->setRedelivered (true );
104
+
105
+ $ driver = $ this ->createDriverMock ();
106
+ $ driver
107
+ ->expects (self ::never ())
108
+ ->method ('sendToProcessor ' )
109
+ ;
110
+
111
+ $ context = new Context ($ this ->createPsrContextMock ());
112
+ $ context ->setPsrMessage ($ message );
113
+ $ context ->setResult ('aStatus ' );
114
+
115
+ $ extension = new DelayRedeliveredMessageExtension ($ driver , 12345 );
116
+ $ extension ->onPreReceived ($ context );
117
+ }
118
+
100
119
/**
101
120
* @return \PHPUnit_Framework_MockObject_MockObject|DriverInterface
102
121
*/
You can’t perform that action at this time.
0 commit comments