Queue
Use this skill for WelineFramework queue inspection, repair, and operation in this source repository. Prefer the framework query provider and queue CLI over direct database poking unless source-level diagnosis requires model internals.
First Pass
- Read the current queue source before assuming docs are current:
app/code/Weline/Queue/extends/module/Weline_Framework/Query/QueueQueryProvider.phpapp/code/Weline/Queue/Console/Queue/Collect.phpapp/code/Weline/Queue/Console/Queue/Run.phpapp/code/Weline/Queue/Console/Queue/Type/Listing.phpapp/code/Weline/Queue/Model/Queue.php
- Use
w_query('queue', ...)for runtime queue reads and business-level writes. Direct DB reads can miss framework casting, EAV/model behavior, event dispatching, and current query-provider semantics. - Preserve side-effect boundaries.
stats,get,getByBizKey,list,getTypeIdByClass, andqueue:type:listingare diagnostic.create,update,delete,queue:collect, andqueue:runchange state or execute work. - New cross-module consumers implement
Weline\Queue\Api\QueueConsumerInterfaceand receiveQueueTaskContextInterface.Weline\Queue\QueueInterfaceremains a runtime compatibility boundary for existing third-party consumers only.
Queue CLI
Use these commands from the repository root.
php bin/w queue:collect
Collect queue types from modules into weline_queue_type. Run this after adding or changing queue classes, or when getTypeIdByClass cannot resolve a class. The collector only registers instantiable classes that implement either the public Weline\Queue\Api\QueueConsumerInterface or the legacy Weline\Queue\QueueInterface; helper/static classes in a Queue/ directory are not queue implementations.
php bin/w queue:type:listing
php bin/w queue:type:listing ExampleQueue
php bin/w queue:type:listing Vendor_Module
List registered queue types. Extra arguments are search terms matched against name, module, and class.
php bin/w queue:run --id=77
php bin/w queue:run --id=77 -f
php bin/w queue:run --id=77 --force
Run one queue item by weline_queue.queue_id.
Use -f/--force only when intentionally taking over or rebuilding the same queue item. Current behavior:
- If the same queue is marked
running, force mode terminates the old same-ID process before continuing. - It injects
_force_rebuild=1into queue content when content is JSON. - It clears previous
resultandprocessso new logs are readable.
Do not cite queue:status as a real command unless the current source contains a command class for it.
w_query Examples
Bootstrap the app for ad hoc diagnostics:
php -r "require __DIR__ . '/app/bootstrap.php'; var_export(w_query('queue', 'stats'));"
Read one queue:
php -r "require __DIR__ . '/app/bootstrap.php'; print_r(w_query('queue', 'get', ['queue_id' => 77]));"
Find latest queue by business key:
php -r "require __DIR__ . '/app/bootstrap.php'; print_r(w_query('queue', 'getByBizKey', ['biz_key' => 'example:1']));"
List recent queues without dumping huge stream logs:
php -r "require __DIR__ . '/app/bootstrap.php'; $r=w_query('queue','list',['page_size'=>10]); foreach($r['items'] as $it){ $row=is_object($it)&&method_exists($it,'getData')?$it->getData():$it; echo json_encode(['queue_id'=>$row['queue_id']??null,'status'=>$row['status']??null,'module'=>$row['module']??null,'name'=>$row['name']??null,'biz_key'=>$row['biz_key']??null], JSON_UNESCAPED_UNICODE), PHP_EOL; }"
Filter by status or search text:
php -r "require __DIR__ . '/app/bootstrap.php'; $r=w_query('queue','list',['status'=>'error','q'=>'example','page_size'=>20]); foreach($r['items'] as $it){ $row=is_object($it)&&method_exists($it,'getData')?$it->getData():$it; echo ($row['queue_id']??'') . ' ' . ($row['status']??'') . ' ' . ($row['name']??'') . PHP_EOL; }"
Resolve a type id by class:
php -r "require __DIR__ . '/app/bootstrap.php'; var_export(w_query('queue','getTypeIdByClass',['class'=>'Vendor\\Module\\Queue\\ExampleQueue']));"
Create a queue through the provider:
php -r "require __DIR__ . '/app/bootstrap.php'; print_r(w_query('queue','create',['class'=>'Vendor\\Module\\Queue\\ExampleQueue','name'=>'Example task','module'=>'Vendor_Module','content'=>['foo'=>'bar'],'biz_key'=>'example:1']));"
Update a safe subset of fields:
php -r "require __DIR__ . '/app/bootstrap.php'; print_r(w_query('queue','update',['queue_id'=>77,'patch'=>['status'=>'pending','pid'=>0,'result'=>'','process'=>'']]));"
Delete only when intended:
php -r "require __DIR__ . '/app/bootstrap.php'; print_r(w_query('queue','delete',['queue_id'=>77]));"
Use force => true only when the queue is running and deletion is explicitly intended.
Provider Operations
w_query('queue', OP, PARAMS) currently supports:
get/load: requirequeue_idorid; return one queue row ornull.getByBizKey: requirebiz_key; return the latest matching row.list: filters includepage,page_size,module,status,type_id,queue_id,biz_key, andq; returnsitemsandpagination.stats: return counts forall,pending,running,done,error, andstop.getTypeIdByClass: resolve a public or legacy queue consumer class totype_id; if missing, it runs collection internally.create: requirename,module, and eithertype_idorclass; optionalcontent,status,auto,biz_key.update: locate byqueue_id/idorbiz_key; passpatchor top-level fields. Safe patch fields includename,module,status,content,result,process,biz_key,auto,finished,pid, andtype_id.delete: locate byqueue_id/idorbiz_key; running queues requireforce.
Valid statuses are pending, running, done, error, and stop.
Validation
After queue registration or consumer-contract filtering changes:
php -l app/code/Weline/Queue/Helper/Helper.php
php bin/w queue:collect
php bin/w queue:type:listing
After command behavior changes:
php bin/w queue:run --help
php bin/w queue:collect --help
php bin/w queue:type:listing --help