Skip to content

Commit cb0defc

Browse files
committed
Add job example for handling non-json messages from rabbitmq queue
1 parent a83eff9 commit cb0defc

File tree

1 file changed

+26
-0
lines changed

1 file changed

+26
-0
lines changed

README.md

Lines changed: 26 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -254,6 +254,32 @@ class RabbitMQJob extends BaseJob
254254
}
255255
```
256256

257+
If you want to handle raw message, not in JSON format or without 'job' key in JSON, you should add stub for `getName` method:
258+
```php
259+
<?php
260+
261+
namespace App\Queue\Jobs;
262+
263+
use Illuminate\Support\Facades\Log;
264+
use VladimirYuldashev\LaravelQueueRabbitMQ\Queue\Jobs\RabbitMQJob as BaseJob;
265+
266+
class RabbitMQJob extends BaseJob
267+
{
268+
public function fire()
269+
{
270+
$anyMessage = $this->getRawBody();
271+
Log::info($anyMessage);
272+
273+
$this->delete();
274+
}
275+
276+
public function getName()
277+
{
278+
return '';
279+
}
280+
}
281+
```
282+
257283
## Laravel Usage
258284

259285
Once you completed the configuration you can use the Laravel Queue API. If you used other queue drivers you do not need to

0 commit comments

Comments
 (0)