So I'm currently in a situation where I'm writing a project that "extends" a forum software called Xenforo.
Inside my app, I've basically got some jobs setup so that once a payment webhook gets sent from Stripe, it gets put on a queue, and the a worker processes it and gives the user a usergroup on the forum. The code for that looks like this;
$service = Xenforo::getApp()->service('XF:User\UserGroupChange');
$service->removeUserGroupChange($this->forum_id, $key);
However, when my job executes it would appear that it finishes before the usergroup change "completes".
So it DOES call the function that is supposed to change the usergroup, but that function itself relies on a lot of other stuff inside XF, and I'm not sure exactly how "long" it takes, but it would appear the job ending is cutting it off as when I check the XF database, there is still records laying around in there, just not fully finished, and it also fully executes the code after it as well.
On top of that, if I just add a controller and a button to my application to add/remove user groups, it works flawlessly every single time. So 100% the Job/Queue is playing a factor here I think.
Hopefully someone can give some additional information. Even if you know nothing about XF, if you can share any information on why the Job/Queue is behaving like this I would be very grateful.