Php Queue System

Customer Queue Management System 1. Multiple Client 3. Hotel Plan Master 4. Automatically Number 5. Complete Accounting. Skiplino is a free queue management system that allows businesses to handle customer queues smartly and speedily. Skiplino is an intelligent and cloud-based system that can monitor data related to queues in real time, and collect customer feedback.

The HP LaserJet P2015 is powered by a 400 MHz processor and features 32 MB of standard memory. You can expand the memory to a maximum of 288 MB. Hp 2015dn driver for windows 10. Thanks to its high resolution of 1200 dpi (dots per inch), the printer is capable of producing professional-quality documents.

A unified front-end for different queuing backends. Includes a REST server, CLI interface and daemon runners.

Why PHP-Queue?

Implementing a queueing system (eg. Beanstalk, Amazon SQS, RabbitMQ) for your application can be painful:

  • Which one is most efficient? Performant?
  • Learning curve to effectively implement the queue backend & the libraries.
  • Time taken to develop the application codes.
  • Vendor locked in, making it impossible to switch.
  • Requires massive code change (ie. not flexible) when use case for the queue changes.

PHP-Queue hopes to serve as an abstract layer between your application code and the implementation of the queue.

Benefits

  • Job Queue is Backend agnostic

    Just refer to the queue by name, what it runs on is independent of the application code. Your code just asks for the next item in the PHPQueueJobQueue, and you'll get a PHPQueueJob object with the data and jobId.

  • Flexible Job Queue implementation

    You can decide whether each PHPQueueJobQueue only carries 1 type of work or multiple types of target workers. You control the retrieval of the job data from the Queue Backend and how it is instantiated as a PHPQueueJob object. Each PHPQueueJob object carries information on which workers it is targeted for.

  • Independent Workers

    Workers are independent of Job Queues. All it needs to worry about is processing the input data and return the resulting data. The queue despatcher will handle the rest. Workers will also be chainable.

  • Powerful

    The framework is deliberately open-ended and can be adapted to your implementation. It doesn't get in the way of your queue system.

    We've build a simple REST server to let you post job data to your queue easily. We also included a CLI interface for adding and triggering workers. All of which you can sub-class and overwrite.

    You can also include our core library files into your application and do some powerful heavy lifting.

    Several backend drivers are bundled:

    • Memcache
    • Redis
    • MongoDB
    • CSVThese can be used as the primary job queue server, or for abstract FIFO or key-value data access.

Installation

Installing via Composer

Composer is a dependency management tool for PHP that allows you to declare the dependencies your project needs and installs them into your project. In order to use the PHP-Queue through Composer, you must do the following:

  1. Add 'coderkungfu/php-queue' as a dependency in your project's composer.json file. Visit the Packagist page for more details.

  2. Download and install Composer.

  1. Install your dependencies.
  1. All the dependencies should be downloaded into a vendor folder.

  2. Require Composer's autoloader.

Getting Started

You can have a look at the Demo App inside .vendorcoderkungfuphp-queuesrcdemo folder for a recommended folder structure.

  • htdocs folder
    • .htaccess
    • index.php
  • queues folder
    • <QueueNameInCamelCase>Queue.php
  • workers folder
    • <WorkerNameInCamelCase>Worker.php
  • runners folder
  • cli.php file
  • config.php file

I would also recommend putting the autoloader statement and your app configs inside a separate config.php file.

Recommended config.php file content:

Altenative config.php file:

You can also declare your application's namespace for loading the Queues and Workers.

PHP-Queue will attempt to instantiate the PHPQueueJobQueue and PHPQueueWorker classes using your namespace - appended with the queue/worker name. (ie. MyFabulousAppQueuesFacebook).

It might be advisable to use Composer's Custom Autoloader for this.

Note:
If you declared PHPQueueBase::$queue_path and/or PHPQueueBase::$worker_path together with the namespace, the files will be loaded with require_once from those folder path AND instantiated with the namespaced class names.

REST Server

The default REST server can be used to interface directly with the queues and workers.

Copy the htdocs folder in the Demo App into your installation. The index.php calls the PHPQueueREST::defaultRoutes() method - which prepares an instance of the RespectRest REST server. You might need to modify the path of config.php within the index.php file.

Recomended installation:use a new virtual host and map the htdocs as the webroot.

  1. Add new job.
  1. Trigger next job.

Read the full documentation on RespectRest to further customize to your application needs (eg. Basic Auth).

Command Line Interface (CLI)

Copy the cli.php file from the Demo App into your installation. This file implements the PHPQueueCli class. You might need to modify the path of config.php within the cli.php file.

  1. Add new job.
  1. Trigger next job.

You can extend the PHPQueueCli class to customize your own CLI batch jobs (eg. import data from a MySQL DB into a queue).

Runners

You can read more about the Runners here.

Interfaces

The queue backends will support one or more of these interfaces:

  • AtomicReadBuffer

This is the recommended way to consume messages. AtomicReadBuffer provides thepopAtomic($callback) interface, which rolls back the popped record if thecallback returns by exception. For example:$queue = new PHPQueueBackendPDO($options);

The message will only be popped if churn() returns successfully.

  • FifoQueueStore

A first in first out queue accessed by push and pop.

License

This software is released under the MIT License.

Copyright (C) 2012 Michael Cheng Chi Mun

Permission is hereby granted, free of charge, to any person obtaining a copy of this software and associated documentation files (the 'Software'), to deal in the Software without restriction, including without limitation the rights to use, copy, modify, merge, publish, distribute, sublicense, and/or sell copies of the Software, and to permit persons to whom the Software is furnished to do so, subject to the following conditions:

The above copyright notice and this permission notice shall be included in all copies or substantial portions of the Software.

THE SOFTWARE IS PROVIDED 'AS IS', WITHOUT WARRANTY OF ANY KIND, EXPRESS OR IMPLIED, INCLUDING BUT NOT LIMITED TO THE WARRANTIES OF MERCHANTABILITY, FITNESS FOR A PARTICULAR PURPOSE AND NONINFRINGEMENT. IN NO EVENT SHALL THE AUTHORS OR COPYRIGHT HOLDERS BE LIABLE FOR ANY CLAIM, DAMAGES OR OTHER LIABILITY, WHETHER IN AN ACTION OF CONTRACT, TORT OR OTHERWISE, ARISING FROM, OUT OF OR IN CONNECTION WITH THE SOFTWARE OR THE USE OR OTHER DEALINGS IN THE SOFTWARE.

  • Find a mentor
  • Find a freelancer
    • Others
  • Learning Center
  • Enterprise
Write a post

During the last several months we were faced with a challenging business requirement to run multiple micro services for thousands of requests in the most efficient way. Using a Queue was our first instinct (far better than creating a x-SQL table with your own statuses, creation dates, priorities, etc) and we were right - however there are way too many options out there.

Out of personal preference (and not a lot of technical backing) here are our findings:

  • RabbitMQ: Appears to be very powerful, fast and reliable - After months of using it, we were overwhelmed with the different options and terminologies. The learning curve was steep and we just needed a queue!

  • Amazon SQS: Excellent queue, with the legendary 'you need a PhD to navigate AWS world' issues. However we were able to get it up and running in a very short period of time to our surprise. Download canon mv500i manual pdf. However, there is latency when getting messages and a documented 'up to a minute or more' delay between publishing and consuming.

  • Beanstalkd: After some more research we ran into Beanstalkd. Stupidly simple and fast to setup, terminology is simple and gets the job done. Drawbacks: Absolutely no security (lock the ports and pray) - and I have yet to find a decent looking monitoring tool to help us track messages.

So I am going to show you how we set this up. I assume that you:

  • Know just enough about PHP
  • Basic working knowledge of composer
  • PHP OOP Understanding
  • You at least follow PSR-0 or use any decent framework.

Installing (Ubuntu)

Done. Go get some coffee. Good job.

Using it

First things first. We need what I call a publisher and then a number of consumers / workers.

Get this library into your composer:

I created a simple class called QueuePublisher.php and QueueConsumer.php:

And for the consumer:

Finally of course you need to call this:

Php Queue Class

Then in the other side, retrieve it

And that's it! In our application we run PhalconPHP and we have the concept of Tasks, we use these tasks to run the Consumer while we use a Cronjob to 'publish' messages. In the same way, we can run a large number of consumer tasks to process the queue faster if we need to.

For even more scalability, we could setup any number of servers with the same code, point the consumer to the same Beanstalkd IP/Domain and run even more consumers so we have virtually unlimited space to grow.

As a tip, we are running our tasks via Supervisor, so for example we have 10 workers running which clears our queues in about 15 minutes. (The delay takes place in the external API's we query for each of the thousand of messages we process). If your operations are local or you can control the performance of them, you could be processing hundreds of messages per second as needed.

Thank you.

Enjoy this post? Give Samuel Morhaim a like if it's helpful.

2

Php Queue Size

Discover and read more posts from Samuel Morhaim

Php Customer Queue System

Leave a like and comment for Samuel

2
Comments are closed.