PHP Message Queuing Usage example analysis, PHP queue instance Analysis _php Tutorial

Source: Internet
Author: User
Tags php error php programming

PHP Message Queuing Usage example analysis, PHP queue instance analysis


The example in this article describes the PHP Message Queuing usage. Share to everyone for your reference, as follows:

This message queue is used under Linux for process communication

#根据路径和后缀创建一个id $key = Ftok (__dir__, ' R '); #获取队列中的消息 $q = Msg_get_queue ($key); #删除队列msg_remove_queue ($q); #获取队列的状态信息 $ Status = Msg_stat_queue ($q);p Rint_r ($status), echo "\ n", for ($i =0; $i <100; $i + +) {/** * Add message to queue * Resource $queue, int $msgtype, mixed $message [, bool $serialize = True [, bool $blocking = true [, int & $errorcode]] * $msgtype: Type of message * $message: Specific data * $serialize: whether to serialize * $blocking: Whether blocking, when the queue is full, will block, set to non-blocking will produce a msg_eagain error message * * * $FL  AG = Msg_send ($q, 111, Array (' A ' =>1), True, false, $errorcode); Var_dump ($errorcode);}  /** Receive Message resource $queue, int $desiredmsgtype, int & $msgtype, int $maxsize, mixed & $message [, BOOL $unserialize = True [, int $flags = 0 [, int & $errorcode]] $desiredmsgtype: 0 means return data from the front of the queue, bigger 0: Specific queue $maxsize: Data max, get message If this value is faulted $msgtype: the exact type of the message, because $desiredmsgtype can specify no type, that is, 0$flags:msg_ipc_nowait if the queue is empty directly (without blocking), msg_except Msg_ NOERROR See manual */$data = msg_receive ($q, 0, $type, $msg), Var_dump ($data); EchO "\ n"; var_dump ($type); echo "\ n"; var_dump ($msg); echo "\ n"; 

Queue status information: specific reference manuals

Array ([Msg_perm.uid] = 1015[msg_perm.gid] = 100[msg_perm.mode] = 438[msg_stime] = 0[msg_rtime] = 0[ Msg_ctime] = 1411830331[msg_qnum] [0[msg_qbytes] = 65536[msg_lspid] = 0[msg_lrpid] + 0)

Linux under the IPC command to view, with the IPCRM command can be deleted

More about PHP related content readers can view the topic: "PHP Basic Grammar Introductory Tutorial", "PHP error and Exception handling method summary", "PHP Programming algorithm Summary" and "PHP object-oriented Programming introduction Tutorial"

I hope this article is helpful to you in PHP programming.

Articles you may be interested in:

    • Php+memcache implementing Message Queuing case sharing
    • How Linux Message Queuing completes inter-process communication under PHP
    • Implementing Message Queuing in PHP Memcache
    • PHP implementation of the Memcache ring Queue class instance
    • Example of a PHP queue usage
    • A two-way queue class instance implemented by PHP
    • PHP Memcache class sharing (Memcache queue)
    • Using Redis queue operation instance code in PHP
    • The actual application of the queue in programming (PHP)

http://www.bkjia.com/PHPjc/1099076.html www.bkjia.com true http://www.bkjia.com/PHPjc/1099076.html techarticle PHP Message Queuing Usage example analysis, PHP queue Instance Analysis This article describes the PHP Message Queuing usage. Share to everyone for reference, as follows: The message queue for Linux, ...

  • Contact Us

    The content source of this page is from Internet, which doesn't represent Alibaba Cloud's opinion; products and services mentioned on that page don't have any relationship with Alibaba Cloud. If the content of the page makes you feel confusing, please write us an email, we will handle the problem within 5 days after receiving your email.

    If you find any instances of plagiarism from the community, please send an email to: info-contact@alibabacloud.com and provide relevant evidence. A staff member will contact you within 5 working days.

    A Free Trial That Lets You Build Big!

    Start building with 50+ products and up to 12 months usage for Elastic Compute Service

    • Sales Support

      1 on 1 presale consultation

    • After-Sales Support

      24/7 Technical Support 6 Free Tickets per Quarter Faster Response

    • Alibaba Cloud offers highly flexible support services tailored to meet your exact needs.