@@ -93,7 +93,13 @@ public function size($queue = null)
93
93
*/
94
94
public function push ($ job , $ data = '' , $ queue = null )
95
95
{
96
- return $ this ->pushRaw ($ this ->createPayload ($ job , $ this ->getQueue ($ queue ), $ data ), $ queue );
96
+ $ options = [];
97
+
98
+ if (isset ($ job ->orderingKey )) {
99
+ $ options ['orderingKey ' ] = $ job ->orderingKey ;
100
+ }
101
+
102
+ return $ this ->pushRaw ($ this ->createPayload ($ job , $ this ->getQueue ($ queue ), $ data ), $ queue , $ options );
97
103
}
98
104
99
105
/**
@@ -114,8 +120,11 @@ public function pushRaw($payload, $queue = null, array $options = [])
114
120
115
121
if (! empty ($ options )) {
116
122
$ publish ['attributes ' ] = $ this ->validateMessageAttributes ($ options );
117
- }
118
123
124
+ if (isset ($ options ['orderingKey ' ])) {
125
+ $ publish ['orderingKey ' ] = $ options ['orderingKey ' ];
126
+ }
127
+ }
119
128
$ topic ->publish ($ publish );
120
129
121
130
$ decoded_payload = json_decode ($ payload , true );
@@ -195,7 +204,7 @@ public function bulk($jobs, $data = '', $queue = null)
195
204
196
205
foreach ((array ) $ jobs as $ job ) {
197
206
$ payload = $ this ->createPayload ($ job , $ this ->getQueue ($ queue ), $ data );
198
- $ payloads [] = ['data ' => base64_encode ($ payload )];
207
+ $ payloads [] = ['data ' => base64_encode ($ payload )] + ( isset ( $ job -> orderingKey ) ? [ ' orderingKey ' => $ job -> orderingKey ] : []) ;
199
208
}
200
209
201
210
$ topic = $ this ->getTopic ($ this ->getQueue ($ queue ), $ this ->topicAutoCreation );
0 commit comments