1

我正在尝试将新用户添加到组并发送激活电子邮件。当我在没有队列的情况下实现它时,它在早些时候工作。

这是我在 app/routes.php 中的(相关)代码:

Queue::getIron()->ssl_verifypeer = false;

Route::post('queue/demo', function(){
    Log::info('marshal!');
    return Queue::marshal();
});

class FinishUserRegistration{
public function fire($job, $data){
    $user_id = $data['user_id'];
    $usergroup = Sentry::getGroupProvider()->findById(2);
    $newuser = Sentry::findUserById($user_id);
    $newuser->addGroup($usergroup);
    $emailData = array(
        'user_name' => $newuser->first_name . ' ' . $newuser->last_name,
        'activation_code' => $newuser->getActivationCode(),
        'user_id' => $newuser->id,
        'repeat' => false,
    );
    Mail::send('emails.activation', $emailData, function ($message) use($user_id){
        $newuser = Sentry::findUserById($user_id);
        $message->to($newuser->email, $newuser->first_name . ' ' . $newuser->last_name)->subject('Welcome to The Site!');
    });

    $job->delete();
}
}

在 UsersController.php 中,我有:

public function postModalRegister(){
    $user = Sentry::createUser($input);
    /*
    $user->addGroup($usergroup);
    $this->activationMail($user->id, false);
    */

    Queue::push('FinishUserRegistration', ['user_id'=>$user->id]);

    return \Response::json(['success' => true], 200);
}

我已按照IronMq + Laravel4 的说明进行操作:如何使其工作。当我注册一个新用户时,我收到了成功,我可以在 IronMQ 仪表板中看到消息计数增加。但是 laravel.log 没有显示“元帅!”,当我做 curl --data "param1=whatever" http://livesite.com/queue/demo

另外,我有

Route::when('*', 'csrf', array('post', 'put', 'delete', 'patch'));

在我的路由文件中,因此队列/演示路由在过滤器之前也有一个 csrf。

4

0 回答 0