File tree Expand file tree Collapse file tree
Expand file tree Collapse file tree Original file line number Diff line number Diff line change @@ -18,13 +18,22 @@ class GearmanConsumer implements PsrConsumer
1818 private $ destination ;
1919
2020 /**
21- * @param \GearmanWorker $worker
21+ * @var GearmanContext
22+ */
23+ private $ context ;
24+
25+ /**
26+ * @param GearmanContext $context
2227 * @param GearmanDestination $destination
28+ *
29+ * @internal param \GearmanWorker $worker
2330 */
24- public function __construct (\ GearmanWorker $ worker , GearmanDestination $ destination )
31+ public function __construct (GearmanContext $ context , GearmanDestination $ destination )
2532 {
26- $ this ->worker = $ worker ;
33+ $ this ->context = $ context ;
2734 $ this ->destination = $ destination ;
35+
36+ $ this ->worker = $ context ->createWorker ();
2837 }
2938
3039 /**
@@ -85,6 +94,9 @@ public function acknowledge(PsrMessage $message)
8594 */
8695 public function reject (PsrMessage $ message , $ requeue = false )
8796 {
97+ if ($ requeue ) {
98+ $ this ->context ->createProducer ()->send ($ this ->destination , $ message );
99+ }
88100 }
89101
90102 /**
Original file line number Diff line number Diff line change @@ -88,7 +88,7 @@ public function createConsumer(PsrDestination $destination)
8888 {
8989 InvalidDestinationException ::assertDestinationInstanceOf ($ destination , GearmanDestination::class);
9090
91- $ this ->consumers [] = $ consumer = new GearmanConsumer ($ this -> createWorker () , $ destination );
91+ $ this ->consumers [] = $ consumer = new GearmanConsumer ($ this , $ destination );
9292
9393 return $ consumer ;
9494 }
You can’t perform that action at this time.
0 commit comments