전에 대기열 시스템을 설정 한 적이 없습니다. 나는 그것을 한 번 주기로 결정했다. 대기열 시스템이 완벽하게 작동하는 것 같습니다. 그러나 데이터가 올바르게 전송되지 않는 것 같습니다. 여기 내 코드가있다.Laravel 4.1 및 Beanstalkd를 사용하여 대기열 클래스에 데이터 전달
...
$comment = new Comment(Input::all());
$comment->user_id = $user->id;
$comment->save();
if ($comment->isSaved())
{
$voters = $comment->argument->voters->unique()->toArray();
Queue::push('Queues\NewComment',
[
'comment' => $comment->load('argument', 'user')->toArray(),
'voters' => $voters
]
);
return Response::json(['success' => true, 'comment' => $comment->load('user')->toArray()]);
}
...
이 다음과 같습니다 처리하는 클래스 :
class NewComment {
public function fire($job, $data)
{
$comment = $data['comment'];
$voters = $data['voters'];
Log::info($data);
foreach ($voters as $voter)
{
if ($voter['id'] != $comment['user_id'])
{
$mailer = new NewCommentMailer($voter, $comment);
$mailer->send();
}
}
$job->delete();
}
}
이 동기 큐 드라이버를 사용하여 내 로컬 서버에 아름답게 작동합니다. 그러나 제작 서버에서 Beanstalkd를 사용하고 있습니다. 대기열이 예상대로 실행됩니다. 그러나, 나는이 같은 오류 받고 있어요 :
[2013-12-19 10:28:05] production.INFO: {"comment":{"incrementing":true,"timestamps":true,"exists":true}} [] []
이 왜 내가 단서가 없다 : 나는 NewComment
큐 핸들러에 전달 된 $data
변수를 인쇄 할 경우
[2013-12-19 10:25:02] production.ERROR: exception 'ErrorException' with message 'Undefined index: voters' in /var/www/mywebsite/app/queues/NewComment.php:10
을,이 얻을 사고. 누구나이 문제를 해결하는 방법을 알고 있습니다.