snoeren-development/laravel-discord-webhook-channel

Queueing support

Closed this issue · 13 comments

It seems like this package currently doesn't support queued notifications?

Hi @zepfietje! It should support queueing. Does your notification implement Laravel's ShouldQueue and Queueable?

Yes, and it works fine locally. However, running in production it fails with the following exception:
Driver [SnoerenDevelopment\DiscordWebhook\DiscordWebhookChannel] not supported.

Strange. That often means that namespaces are not correctly configured as Laravel cannot find them. Can you optimize your local environment and try again locally or clear the application cache in production? Maybe it's a caching issue.

What do you mean by "optimize your local environment"?

The php artisan optimize and php artisan optimize:clear commands. They cache the autodiscovered packages too.

After running php artisan optimize locally, no notifications come through. Both queued and not.

I verified it working locally both queued, unqueued, optimized and non-optimized. In all cases the notification was sent. Can you check if you;

  1. use DiscordWebhookChannel::class in your via method of your notification.
  2. Implement the toDiscord method in your notification.
  3. Implement the routeNotificationForDiscord method on your notifiable model (often User or Team).
  4. Have a working webhook URL for Discord.

If none of it works, I would try to dump the composer autoload files again to ensure the class is autoloaded. Also, some (example) code would help ;)

It's working locally now (not sure what fixed it).
However, in production (or staging) I can't seem to get it to work.
Also tried running composer dump-autoload and php artisan optimize:clear there.

I'm not doing anything special with the notification, so probably it's not related to this package (but rather a caching issue indeed).

When running php artisan package:discover I found that this package is not listed.
Could this be the cause?

The package should be autodiscovered. It was in my test setup. Are you using Laravel 5.5 or higher?

Yep, latest Laravel version.

@MSnoeren I'm still running into this issue.
Everything works fine locally (queued and not queued), but in production it only works when not queueing the notification. When queuing, I get the exception I posted earlier:
Driver [SnoerenDevelopment\DiscordWebhook\DiscordWebhookChannel] not supported.

Okay, finally solved it by running php artisan queue:restart.