{"id":26664774,"url":"https://github.com/dspacelabs/queue","last_synced_at":"2025-04-11T20:41:43.672Z","repository":{"id":34077445,"uuid":"37884708","full_name":"dSpaceLabs/Queue","owner":"dSpaceLabs","description":"General Queueing library that supports various backend storage systems","archived":false,"fork":false,"pushed_at":"2017-11-30T00:55:33.000Z","size":44,"stargazers_count":5,"open_issues_count":2,"forks_count":0,"subscribers_count":1,"default_branch":"master","last_synced_at":"2025-03-25T16:51:12.598Z","etag":null,"topics":["broker","filequeue","message-queue","php","redis-queue","sqs-queue"],"latest_commit_sha":null,"homepage":null,"language":"PHP","has_issues":true,"has_wiki":null,"has_pages":null,"mirror_url":null,"source_name":"InventivetalentDev/HologramAPI","license":"mit","status":null,"scm":"git","pull_requests_enabled":true,"icon_url":"https://github.com/dSpaceLabs.png","metadata":{"files":{"readme":"README.md","changelog":"CHANGELOG.md","contributing":null,"funding":null,"license":"LICENSE","code_of_conduct":null,"threat_model":null,"audit":null,"citation":null,"codeowners":null,"security":null,"support":null}},"created_at":"2015-06-22T22:50:22.000Z","updated_at":"2019-08-24T20:15:33.000Z","dependencies_parsed_at":"2022-07-18T01:10:41.122Z","dependency_job_id":null,"html_url":"https://github.com/dSpaceLabs/Queue","commit_stats":null,"previous_names":[],"tags_count":2,"template":false,"template_full_name":null,"repository_url":"https://repos.ecosyste.ms/api/v1/hosts/GitHub/repositories/dSpaceLabs%2FQueue","tags_url":"https://repos.ecosyste.ms/api/v1/hosts/GitHub/repositories/dSpaceLabs%2FQueue/tags","releases_url":"https://repos.ecosyste.ms/api/v1/hosts/GitHub/repositories/dSpaceLabs%2FQueue/releases","manifests_url":"https://repos.ecosyste.ms/api/v1/hosts/GitHub/repositories/dSpaceLabs%2FQueue/manifests","owner_url":"https://repos.ecosyste.ms/api/v1/hosts/GitHub/owners/dSpaceLabs","download_url":"https://codeload.github.com/dSpaceLabs/Queue/tar.gz/refs/heads/master","host":{"name":"GitHub","url":"https://github.com","kind":"github","repositories_count":248478876,"owners_count":21110777,"icon_url":"https://github.com/github.png","version":null,"created_at":"2022-05-30T11:31:42.601Z","updated_at":"2022-07-04T15:15:14.044Z","host_url":"https://repos.ecosyste.ms/api/v1/hosts/GitHub","repositories_url":"https://repos.ecosyste.ms/api/v1/hosts/GitHub/repositories","repository_names_url":"https://repos.ecosyste.ms/api/v1/hosts/GitHub/repository_names","owners_url":"https://repos.ecosyste.ms/api/v1/hosts/GitHub/owners"}},"keywords":["broker","filequeue","message-queue","php","redis-queue","sqs-queue"],"created_at":"2025-03-25T16:38:31.159Z","updated_at":"2025-04-11T20:41:43.647Z","avatar_url":"https://github.com/dSpaceLabs.png","language":"PHP","readme":"Queue Component [![Build Status](https://travis-ci.org/dSpaceLabs/Queue.svg?branch=master)](https://travis-ci.org/dSpaceLabs/Queue)\n===============\n\nGeneral queue library for PHP, ability to support various different queue\nsystems.\n\nFor more documentation, see the [wiki](https://github.com/dSpaceLabs/Queue/wiki).\n\n## Installation\n\n```\ncomposer require dspacelabs/queue\n```\n\n## Usage\n\n```php\n\u003c?php\n\nuse Dspacelabs\\Component\\Queue\\Message;\n\n// Publishing messages to a queue\n$message = new Message($body);\n$queue-\u003epublish($message);\n/**\n * This will publish a message to the queue you created, the $body can be\n * anything you want.\n */\n\n// Receive messages\n$message = $queue-\u003ereceive();\n$body    = $message-\u003egetBody();\n// ... Process Data ...\n/**\n * $message will be the message that was published. `-\u003ereceive()` can be put\n * into a foreach loop if you want to continue to process the queue until\n * all the messages are processed, use a for loop in you only want to process\n * a small number of the messages\n */\n\n/**\n * Once you are done processing a message, it needs to be deleted from the queue\n */\n$queue-\u003edelete($message);\n```\n\n## Messages, Queues, Broker\n\nMessages are published to queues. When you receive a message from a queue, you\nwill be interacting with this class.\n\nQueues are where you publish your messages to. For example, a Queue could be an\nAWS SQS, RabbitMQ, or any other queue you can think of.\n\nThe Broker helps you keep track of queues. So instead of having 100 different\nqueue objects all over, you just add all those to the Broker and let the Broker\nsort them out. You just get the ones you need.\n\n## Using the FileQueue\n\nThe FileQueue will store messages on disk and is good to use for local\ndevelopment.\n\nMessages are stored on disk in the file naming format \"name.timestamp.message\"\nso you can have multiple file queues share the same directory.\n\n\n```php\n\u003c?php\n\nuse Dspacelabs\\Component\\Queue\\FileQueue;\nuse Dspacelabs\\Component\\Queue\\Message;\n\n$queue = new FileQueue('queue.name', '/tmp/');\n$queue-\u003epublish(new Message('Hello World!'));\n\n// ...\n\n$message = $queue-\u003ereceive();\n$body = $message-\u003egetBody(); // $body === \"Hello World!\"\n$queue-\u003edelete($message);\n```\n\n## Using the SqsQueue\n\nRequires Amazon PHP SDK.\n\n```bash\nphp composer.phar require aws/aws-sdk-php\n```\n\n```php\n\u003c?php\n\nuse Aws\\Credentials\\Credentials;\nuse Aws\\Sqs\\SqsClient;\nuse Dspacelabs\\Component\\Queue\\SqsQueue;\n\n$credentials = new Credentials($accessKey, $secretKey);\n$client = new SqsClient([\n    'version'     =\u003e 'latest',\n    'region'      =\u003e 'us-east-1',\n    'credentials' =\u003e $credentials,\n]);\n\n$queue  = new SqsQueue($client, $queueUrl, $name);\n```\n\n## Using the StandardQueue\n\nThe standard queue is mainly used for testing. Once this is setup you\ncan quickly test your workflow. Keep in mind that this has some drawbacks\nmainly that the messages are not persisted.\n\n```php\n\u003c?php\n\n// First you need to setup the Queue\n$queue = new \\Dspacelabs\\Component\\Queue\\StandardQueue('queue.name');\n\n// Create a message that will be sent to the queue\n$message = new \\Dspacelabs\\Component\\Queue\\Message('Hello World A');\n\n// Publish the message\n$queue-\u003epublish($message);\n\n// Consume all messages\n/** @var Message $msg **/\nwhile ($msg = $queue-\u003ereceive()) {\n    // process message\n    // ...\n    // Delete the Message from the queu\n    $queue-\u003edelete($msg);\n}\n```\n\nNOTE: When using the StandardQueue, you do not need to delete the message like\nin this example `$queue-\u003edelete($msg);` HOWEVER there are some queues out there\nthat support this.\n\n## Using the RedisQueue\n\nTo use the `RedisQueue` you need to install Predis\n\n```bash\ncomposer require predis/predis\n```\n\nOnce you have done that, you can begin to use the Redis as one of the possible\nQueues.\n\n```php\n\u003c?php\n\nuse Predis\\Client;\nuse Dspacelabs\\Component\\Queue\\RedisQueue;\n\n$client = new Client();\n$queue  = new RedisQueue($client, 'queue.name');\n```\n\nSee https://github.com/nrk/predis for Predis documentation.\n\n## Using the Broker\n\nIf you have multiple queues, you can use the Broker which will just help you\nmanage the various queues you have. For example, you could be using multiple\nSQS queues and want a single point to access those at. The Broker will help you\nwith this.\n\nIt's also important to point out that the broker supports all queue types in\nthis library. So you can use the SQS Queue, Standard Queue, or a custom queue\nthat you made.\n\n```php\n\u003c?php\n\nuse Dspacelabs\\Component\\Queue\\Broker;\n\n$broker = new Broker();\n\n// I assume you already have a queue\n$broker-\u003eaddQueue($queue);\n\n// `queue.name` is the name given to the queue you created\n// I assume you already have a `$message` created\n$broker-\u003eget('queue.name')-\u003epublish($message);\n$broker-\u003eget('queue.other')-\u003epublish($messageOther);\n```\n\n## Change Log\n\nSee [CHANGELOG.md].\n\n## License\n\nCopyright (c) 2015-2017 dSpace Labs LLC\n\nSee [LICENSE] for full license.\n\n[CHANGELOG.md]: https://github.com/dSpaceLabs/Queue/blob/master/CHANGELOG.md\n[LICENSE]: https://github.com/dSpaceLabs/Queue/blob/master/LICENSE\n","funding_links":[],"categories":[],"sub_categories":[],"project_url":"https://awesome.ecosyste.ms/api/v1/projects/github.com%2Fdspacelabs%2Fqueue","html_url":"https://awesome.ecosyste.ms/projects/github.com%2Fdspacelabs%2Fqueue","lists_url":"https://awesome.ecosyste.ms/api/v1/projects/github.com%2Fdspacelabs%2Fqueue/lists"}