Your application doesn't have any registered broadcast events
seivad opened this issue · 11 comments
I cannot get the Listener to log at all.
The command line artisan rabbitevents:listen feedback
is running, the published event appears in the RabbitMQ management interface if I don't have the command line running.
I can view the message and the payload is all there but as soon as I run the command line, the message is acknowledged and plucked from RabbitMQ Management but the Listener in the same app is not called (no log events written to the log files).
<?php
namespace App\Providers;
use Nuwber\Events\RabbitEventsServiceProvider;
class RabbitEventsServiceProvider extends RabbitEventsServiceProvider
{
/**
* The event listener mappings for the application.
*
* @var array
*/
protected $listen = [
'feedback' => [
'App\Listeners\Feedback\FeedbackLogger',
],
];
public function boot()
{
parent::boot();
//
}
}
<?php
namespace App\Listeners\Feedback;
use Illuminate\Support\Facades\Log;
class FeedbackLogger
{
/**
* Create the event listener.
*
* @return void
*/
public function __construct()
{
Log::info('Feedback Logger Init...');
}
/**
* Handle the event.
*
* @param object $event
* @return void
*/
public function handle(string $event, array $payload)
{
Log::info('Feedback Logger Fired!...');
Log::info($event);
if ($event === 'feedback.created') {
Log::info('New Feedback Ticket...');
Log::info(print_r($payload));
}
}
}
Route::get('/tests/rabbit', function () {
publish('feedback', ['subject' => 'Test Feedback Ticket!', 'comments' => 'Random Feedback Comments...!', 'sent_at' => now()->format('H:i:s A')]);
return 'done!';
});
oh and I also had to change the composer.json to pull in 'dev-master'
to get the install commands to be pulled in, just calling the composer command you have in your documents pulls in a version missing all that.
- the version is 4.0-beta.1
- Could you please also show your
config/rabbitevents.php
- Your listener is incorrect. The first (and single) argument must be
$payload
. Please check the difference between wildcard and regular listeners.
I was trying both Wildcard and Standalone, sorry for the confusion on that but I did try both.
The config is your provided stub.
<?php
return [
/*
|--------------------------------------------------------------------------
| RabbitEvents Connection Configuration
|--------------------------------------------------------------------------
|
| Here you may define the RabbitMQ connection settings that should be used
| by RabbitEvents. Note that `vhost` should be created by you manually.
| @see https://www.rabbitmq.com/vhosts.html for more info
|
*/
[
'default' => env('RABBITEVENTS_CONNECTION', 'rabbitmq'),
'connections' => [
'rabbitmq' => [
'driver' => 'rabbitmq',
'exchange' => env('RABBITEVENTS_EXCHANGE', 'events'),
'host' => env('RABBITEVENTS_HOST', 'localhost'),
'port' => env('RABBITEVENTS_PORT', 5672),
'user' => env('RABBITEVENTS_USER', 'guest'),
'pass' => env('RABBITEVENTS_PASSWORD', 'guest'),
'vhost' => env('RABBITEVENTS_VHOST', 'events'),
'logging' => [
'enabled' => env('RABBITEVENTS_LOG_ENABLED', false),
'level' => env('RABBITEVENTS_LOG_LEVEL', 'info'),
],
],
],
],
];
How do I pull in that beta version in composer? currently I have:
"nuwber/rabbitevents": "dev-master",
I've now got "nuwber/rabbitevents": "dev-master#4.0-beta.1",
in the composer.json file but still when trying to run artisan rabbitevents:list
I still receive Your application doesn't have any registered broadcast events.
"nuwber/rabbitevents": "4.0-beta.1",
Thank you, I've fount what trouble is.
As you can see, the issue was in the installation command.
How to fix in your app: just add App\Providers\RabbitEventsServiceProvider::class,
in your providers list in config/app.php
config.
Thanks man, I'm about to go on a 4 day holiday over the aussie day long weekend but I will try it again on Tuesday morning if you can leave the ticket open. I've made pretty good strides so far using the tutorials, but hoping to simplify everything using this plugin and some other wrappers i'll put together.
@seivad This issue will wait for your testing
The new tag was created: 4.0-beta.2
Just bashed it around this morning and it's all working great! Listeners between μSVC and the main monoliths are working.
A thought though, how much harder would it be to support RPC? I've followed the RPC tutorial for PHP and Node.js on the RabbitMQ tutorials site, so really it's just listening back to the correct response. Maybe if we had another global helper command like publish but called rpc() which took in a UUID so it knows to send back to the right response. This is really the only thing missing now from this package for running microservices on Laravel.
Maybe also allowing some options on the listen command (command line call) to allow for persistent queues etc...
@seivad Thanks for your test. So, I'll close this issue and you please make a new issue with your suggestion.
I've read your comment but not fully understand what you need. Maybe because I'm not familiar with RPC.
And add a Star to this package if you like it