Dispatching a closure is convenient and stores executable code in the queue, which is a different security and deployment posture from a job class.
dispatch(function () use ($order) {
$order->markExported();
});
// what is stored: the closure's code, signed with the
// application key, plus the serialised $order.
// the consequences:
// the signature is why APP_KEY rotation breaks the queue
// a deploy that changes the surrounding file is fine —
// the code is in the payload, not looked up
// which means it runs OLD code after a deploy
Running old code after a deploy is the property that catches people, and it is the opposite of a job class, which is looked up by name and therefore runs the new implementation. The signature exists to stop an attacker with database access from executing arbitrary code, which is a real threat model and a reason to prefer job classes for anything long-lived.