Skip to content

Commit 29c8125

Browse files
authored
Merge pull request vyuldashev#532 from trckster/add-documentation-for-handling-raw-messages
[13.2] Add job example for handling non-json messages from rabbitmq queue
2 parents 9c0d172 + ce0c582 commit 29c8125

File tree

1 file changed

+25
-0
lines changed

1 file changed

+25
-0
lines changed

README.md

Lines changed: 25 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -262,6 +262,31 @@ class RabbitMQJob extends BaseJob
262262
}
263263
```
264264

265+
If you want to handle raw message, not in JSON format or without 'job' key in JSON, you should add stub for `getName` method:
266+
```php
267+
<?php
268+
269+
namespace App\Queue\Jobs;
270+
271+
use Illuminate\Support\Facades\Log;
272+
use VladimirYuldashev\LaravelQueueRabbitMQ\Queue\Jobs\RabbitMQJob as BaseJob;
273+
274+
class RabbitMQJob extends BaseJob
275+
{
276+
public function fire()
277+
{
278+
$anyMessage = $this->getRawBody();
279+
Log::info($anyMessage);
280+
281+
$this->delete();
282+
}
283+
284+
public function getName()
285+
{
286+
return '';
287+
}
288+
}
289+
265290
### Use your own Connection
266291

267292
You can extend the built-in `PhpAmqpLib\Connection\AMQPStreamConnection::class`

0 commit comments

Comments
 (0)