In addition to Weibo, there is also WeChat
Please pay attention
WeChat public account
Shulou
2025-09-25 Update From: SLTechnology News&Howtos shulou NAV: SLTechnology News&Howtos > Development >
Share
Shulou(Shulou.com)05/31 Report--
This article Xiaobian introduces in detail for you "thinkphp6 uses think-queue to achieve ordinary queues and delay queues", the content is detailed, the steps are clear, and the details are handled properly. I hope that this article "thinkphp6 uses think-queue to achieve ordinary queues and delay queues" can help you solve your doubts.
# TP6 queue
Normal queues and delay queues can be implemented by using think-queue in TP6.
Think-queue is a message queuing service officially provided by thinkphp, which supports some basic features of message queuing:
Message release, acquisition, execution, deletion, retransmission, failure handling, delayed execution, timeout control, etc.
Multiple queues for queues, memory limits, start, stop, daemon, etc.
Message queuing can be degraded to synchronous execution
Message queue implementation process
1. Push messages to the message queuing service through the producer
2. The message queuing service stores the received messages in the redis queue (zset)
3. Consumers listen to the queue and get the first item of the queue when they hear a new message.
4. Process the obtained message and call the business class to process the related business.
5. After business processing, you need to delete the message from the queue.
Composer installation think-queuecomposer require topthink/think-queue configuration file
After installing think-queue, queue.php is generated in the config directory, which is the configuration file for the queue.
There are many ways to implement message queues in tp6. Sync is used by default, and I choose to use Redis here.
Return ['default' = >' redis', 'connections' = > [' sync' = > ['type' = >' sync',], 'database' = > [' type' = > 'database',' queue' = > 'default',' table' = > 'jobs',' connection' = > null,] 'redis' = > [' type' = > 'redis',' queue' = > 'default',' host' = > env ('redis.host',' 127.0.0.1'), 'port' = > env (' redis.port', '6379'),' password' = > env ('redis.password','123456') 'select' = > 0,' timeout' = > 0, 'persistent' = > false,],' failed' = > ['type' = >' none', 'table' = >' failed_jobs',],] Create directory and queue consumer files
Create a queue directory under the app directory, and then create a new abstract class Queue.php file under that directory as the base class
Welcome to subscribe "Shulou Technology Information " to get latest news, interesting things and hot topics in the IT industry, and controls the hottest and latest Internet news, technology news and IT industry trends.
Views: 0
*The comments in the above article only represent the author's personal views and do not represent the views and positions of this website. If you have more insights, please feel free to contribute and share.
The market share of Chrome browser on the desktop has exceeded 70%, and users are complaining about
The world's first 2nm mobile chip: Samsung Exynos 2600 is ready for mass production.According to a r
A US federal judge has ruled that Google can keep its Chrome browser, but it will be prohibited from
Continue with the installation of the previous hadoop.First, install zookooper1. Decompress zookoope
About us Contact us Product review car news thenatureplanet
More Form oMedia: AutoTimes. Bestcoffee. SL News. Jarebook. Coffee Hunters. Sundaily. Modezone. NNB. Coffee. Game News. FrontStreet. GGAMEN
© 2024 shulou.com SLNews company. All rights reserved.