如何手动获取 RegistrationID(未解决) + horizon 队列处于暂停状态?(已解决)
请问老师,有两个问题请教下。
问题1
APP 获取 APNs 分配的 deviceToken,去 Jpush 注册并获取 RegistrationID
是APP自动将获取到的deviceToken发送到Jpush的服务器上,然后自动去注册并获取RegistrationID的吗?由于现在并没有APP,如果我想手动去得到一个可以使用的RegistrationID来测试Jpush
的推送功能的话,应该怎么样去做呢?
问题2
当前的RegistrationID我们假设的是"test_registration_id",在修改了.env文件中的APP_ENV=testing后,根据\App\Notifications\TopicReplied
和\App\Listeners\PushNotification
是否实现ShouldQueue
,使用这个错误的RegistrationID会有不同的响应(有时会报错,有时不会,具体重现步骤见下)。
1. TopicReplied实现ShouldQueue,PushNotification不实现--不报错
app/Notifications/TopicReplied.php
class TopicReplied extends Notification implements ShouldQueue
//class TopicReplied extends Notification
...
app/Listeners/PushNotification.php
//class PushNotification implements ShouldQueue
class PushNotification
响应为:
- postman不报错
- laravel.log内未见报错。
- public/jpush.log内未见发送日志。
2. TopicReplied不实现ShouldQueue,PushNotification实现--不报错
app/Notifications/TopicReplied.php
//class TopicReplied extends Notification implements ShouldQueue
class TopicReplied extends Notification
...
app/Listeners/PushNotification.php
class PushNotification implements ShouldQueue
//class PushNotification
响应为:
- postman不报错(时间明显更长,因为TopicReplied中有发送邮件)
- laravel.log内未见报错。
- public/jpush.log内未见发送日志。
- Laravel Horizon中有
PushNotification
的队列记录,但并没有失败?(从队列中取出job执行这个动作成功了,但即使这个job本身(推送)失败,但队列执行job还是成功了?)
3. TopicReplied和PushNotification都实现ShouldQueue--不报错
app/Notifications/TopicReplied.php
class TopicReplied extends Notification implements ShouldQueue
//class TopicReplied extends Notification
...
app/Listeners/PushNotification.php
class PushNotification implements ShouldQueue
//class PushNotification
响应为:
- postman不报错
- laravel.log内未见报错。
- public/jpush.log内未见发送日志。
- Laravel Horizon中有
TopicReplied
的队列记录,而且是同一时间有两个同样的job。
4. TopicReplied和PushNotification都不实现ShouldQueue--报错
app/Notifications/TopicReplied.php
//class TopicReplied extends Notification implements ShouldQueue
class TopicReplied extends Notification
...
app/Listeners/PushNotification.php
//class PushNotification implements ShouldQueue
class PushNotification
响应为:
- postman报错
- laravel.log内有报错记录:
- public/jpush.log内有发送日志:
看看 status 还没执行啊,应该是 执行到 PushNotification 会尝试多次然后进入 failed,你的队列没有配置正确