Skip to content

Commit

Permalink
[docs] update README.md for travis-ci.com
Browse files Browse the repository at this point in the history
  • Loading branch information
abreksa4 committed Jun 27, 2021
1 parent e0faad6 commit 236611b
Showing 1 changed file with 65 additions and 44 deletions.
109 changes: 65 additions & 44 deletions README.md
Original file line number Diff line number Diff line change
@@ -1,20 +1,21 @@
Redis Simple Message Queue
--------------------------
[![Travis CI](https://travis-ci.org/abreksa4/php-rsmq.svg?branch=master)](https://travis-ci.org/abreksa4/php-rsmq)
[![Build Status](https://travis-ci.com/abreksa4/php-rsmq.svg?branch=master)](https://travis-ci.com/abreksa4/php-rsmq)
[![codecov](https://codecov.io/gh/abreksa4/php-rsmq/branch/master/graph/badge.svg)](https://codecov.io/gh/abreksa4/php-rsmq)
[![License](https://poser.pugx.org/andrewbreksa/rsmq/license)](//packagist.org/packages/andrewbreksa/rsmq)
[![GitHub issues](https://img.shields.io/github/issues/abreksa4/php-rsmq)](https://github.com/abreksa4/php-rsmq/issues)
[![Latest Stable Version](https://poser.pugx.org/andrewbreksa/rsmq/v)](//packagist.org/packages/andrewbreksa/rsmq)
[![Latest Unstable Version](https://poser.pugx.org/andrewbreksa/rsmq/v/unstable)](//packagist.org/packages/andrewbreksa/rsmq)
[![Latest Stable Version](https://poser.pugx.org/andrewbreksa/rsmq/v)](//packagist.org/packages/andrewbreksa/rsmq)
[![Latest Unstable Version](https://poser.pugx.org/andrewbreksa/rsmq/v/unstable)](//packagist.org/packages/andrewbreksa/rsmq)
[![composer.lock](https://poser.pugx.org/andrewbreksa/rsmq/composerlock)](//packagist.org/packages/andrewbreksa/rsmq)
[![Total Downloads](https://poser.pugx.org/andrewbreksa/rsmq/downloads)](//packagist.org/packages/andrewbreksa/rsmq)
[![Total Downloads](https://poser.pugx.org/andrewbreksa/rsmq/downloads)](//packagist.org/packages/andrewbreksa/rsmq)
[![GitHub stars](https://img.shields.io/github/stars/abreksa4/php-rsmq)](https://github.com/abreksa4/php-rsmq/stargazers)
[![Dependents](https://poser.pugx.org/andrewbreksa/rsmq/dependents)](//packagist.org/packages/andrewbreksa/rsmq)

A lightweight message queue for PHP that requires no dedicated queue server. Just a Redis server. See
A lightweight message queue for PHP that requires no dedicated queue server. Just a Redis server. See
[smrchy/rsmq](https://github.com/smrchy/rsmq) for more information.

This is a fork of [eislambey/php-rsmq](https://github.com/eislambey/php-rsmq) with the following changes:

- Uses [predis](https://github.com/nrk/predis) instead of the Redis extension
- Has some OO wrappers for QueueAttributes and Message
- Provides a simple [QueueWorker](./src/QueueWorker.php)
Expand Down Expand Up @@ -44,11 +45,13 @@ This is a fork of [eislambey/php-rsmq](https://github.com/eislambey/php-rsmq) wi
<!-- tocstop -->

# Installation

composer require andrewbreksa/rsmq

# Methods

## Construct

Creates a new instance of RSMQ.

Parameters:
Expand Down Expand Up @@ -76,24 +79,26 @@ $this->rsmq = new RSMQClient($predis);
## Queue

### createQueue

Create a new queue.

Parameters:

* `$name` (string): The Queue name. Maximum 160 characters; alphanumeric characters, hyphens (-), and underscores (_)
are allowed.
* `$vt` (int): *optional* *(Default: 30)* The length of time, in seconds, that a message received from a queue will be
invisible to other receiving components when they ask to receive messages. Allowed values: 0-9999999 (around 115 days)
* `$delay` (int): *optional* *(Default: 0)* The time in seconds that the delivery of all new messages in the queue will
be delayed. Allowed values: 0-9999999 (around 115 days)
* `$maxsize` (int): *optional* *(Default: 65536)* The maximum message size in bytes. Allowed values: 1024-65536 and -1
(for unlimited size)
* `$name` (string): The Queue name. Maximum 160 characters; alphanumeric characters, hyphens (-), and underscores (_)
are allowed.
* `$vt` (int): *optional* *(Default: 30)* The length of time, in seconds, that a message received from a queue will be
invisible to other receiving components when they ask to receive messages. Allowed values: 0-9999999 (around 115 days)
* `$delay` (int): *optional* *(Default: 0)* The time in seconds that the delivery of all new messages in the queue will
be delayed. Allowed values: 0-9999999 (around 115 days)
* `$maxsize` (int): *optional* *(Default: 65536)* The maximum message size in bytes. Allowed values: 1024-65536 and -1
(for unlimited size)

Returns:

* `true` (Bool)

Throws:

* `\AndrewBreksa\RSMQ\Exceptions\QueueAlreadyExistsException`

Example:
Expand All @@ -108,6 +113,7 @@ $rsmq->createQueue('myqueue');
```

### listQueues

List all queues

Returns an array:
Expand All @@ -126,6 +132,7 @@ $queues = $rsmq->listQueues();
```

### deleteQueue

Deletes a queue and all messages.

Parameters:
Expand All @@ -136,7 +143,6 @@ Returns:

* `true` (Bool)


Throws:

* `\AndrewBreksa\RSMQ\Exceptions\QueueNotFoundException`
Expand All @@ -153,6 +159,7 @@ $rsmq->deleteQueue('myqueue');
```

### getQueueAttributes

Get queue attributes, counter and stats

Parameters:
Expand All @@ -169,8 +176,8 @@ Returns a `\AndrewBreksa\RSMQ\QueueAttributes` object with the following propert
* `created` (float): Timestamp (epoch in seconds) when the queue was created
* `modified` (float): Timestamp (epoch in seconds) when the queue was last modified with `setQueueAttributes`
* `messageCount` (int): Current number of messages in the queue
* `hiddenMessageCount` (int): Current number of hidden / not visible messages. A message can be hidden while "in flight"
due to a `vt` parameter or when sent with a `delay`
* `hiddenMessageCount` (int): Current number of hidden / not visible messages. A message can be hidden while "in flight"
due to a `vt` parameter or when sent with a `delay`

Example:

Expand All @@ -192,17 +199,17 @@ echo "current n of messages: ", $attributes->getMessageCount(), "\n";
echo "hidden messages: ", $attributes->getHiddenMessageCount(), "\n";
```


### setQueueAttributes

Sets queue parameters.

Parameters:

* `$queue` (string): The Queue name.
* `$vt` (int): *optional* * The length of time, in seconds, that a message received from a queue will be invisible to
other receiving components when they ask to receive messages. Allowed values: 0-9999999 (around 115 days)
* `$delay` (int): *optional* The time in seconds that the delivery of all new messages in the queue will be delayed.
Allowed values: 0-9999999 (around 115 days)
* `$vt` (int): *optional* * The length of time, in seconds, that a message received from a queue will be invisible to
other receiving components when they ask to receive messages. Allowed values: 0-9999999 (around 115 days)
* `$delay` (int): *optional* The time in seconds that the delivery of all new messages in the queue will be delayed.
Allowed values: 0-9999999 (around 115 days)
* `$maxsize` (int): *optional* The maximum message size in bytes. Allowed values: 1024-65536 and -1 (for unlimited size)

Note: At least one attribute (vt, delay, maxsize) must be supplied. Only attributes that are supplied will be modified.
Expand All @@ -217,10 +224,11 @@ Returns a `\AndrewBreksa\RSMQ\QueueAttributes` object with the following propert
* `created` (float): Timestamp (epoch in seconds) when the queue was created
* `modified` (float): Timestamp (epoch in seconds) when the queue was last modified with `setQueueAttributes`
* `messageCount` (int): Current number of messages in the queue
* `hiddenMessageCount` (int): Current number of hidden / not visible messages. A message can be hidden while "in flight"
due to a `vt` parameter or when sent with a `delay`
* `hiddenMessageCount` (int): Current number of hidden / not visible messages. A message can be hidden while "in flight"
due to a `vt` parameter or when sent with a `delay`

Throws:

* `\AndrewBreksa\RSMQ\QueueAttributes`
* `\AndrewBreksa\RSMQ\QueueParametersValidationException`
* `\AndrewBreksa\RSMQ\QueueNotFoundException`
Expand All @@ -243,20 +251,22 @@ $rsmq->setQueueAttributes($queue, $vt, $delay, $maxsize);
## Messages

### sendMessage

Sends a new message.

Parameters:

* `$queue` (string)
* `$message` (string)
* `$delay` (int): *optional* *(Default: queue settings)* The time in seconds that the delivery of the message will be
delayed. Allowed values: 0-9999999 (around 115 days)
* `$delay` (int): *optional* *(Default: queue settings)* The time in seconds that the delivery of the message will be
delayed. Allowed values: 0-9999999 (around 115 days)

Returns:

* `$id` (string): The internal message id.

Throws:

* `\AndrewBreksa\RSMQ\Exceptions\MessageToLongException`
* `\AndrewBreksa\RSMQ\Exceptions\QueueNotFoundException`
* `\AndrewBreksa\RSMQ\Exceptions\QueueParametersValidationException`
Expand All @@ -274,25 +284,27 @@ echo "Message Sent. ID: ", $id;
```

### receiveMessage

Receive the next message from the queue.

Parameters:

* `$queue` (string): The Queue name.
* `$vt` (int): *optional* *(Default: queue settings)* The length of time, in seconds, that the received message will be
invisible to others. Allowed values: 0-9999999 (around 115 days)
* `$vt` (int): *optional* *(Default: queue settings)* The length of time, in seconds, that the received message will be
invisible to others. Allowed values: 0-9999999 (around 115 days)

Returns a `\AndrewBreksa\RSMQ\Message` object with the following properties:

* `message` (string): The message's contents.
* `id` (string): The internal message id.
* `sent` (int): Timestamp of when this message was sent / created.
* `firstReceived` (int): Timestamp of when this message was first received.
* `receiveCount` (int): Number of times this message was received.
* `message` (string): The message's contents.
* `id` (string): The internal message id.
* `sent` (int): Timestamp of when this message was sent / created.
* `firstReceived` (int): Timestamp of when this message was first received.
* `receiveCount` (int): Number of times this message was received.

Note: Will return an empty array if no message is there
Note: Will return an empty array if no message is there

Throws:

* `\AndrewBreksa\RSMQ\Exceptions\QueueNotFoundException`
* `\AndrewBreksa\RSMQ\Exceptions\QueueParametersValidationException`

Expand All @@ -310,6 +322,7 @@ echo "Message: ", $message->getMessage();
```

### deleteMessage

Parameters:

* `$queue` (string): The Queue name.
Expand All @@ -320,6 +333,7 @@ Returns:
* `true` if successful, `false` if the message was not found (bool).

Throws:

* `\AndrewBreksa\RSMQ\Exceptions\QueueParametersValidationException`

Example:
Expand All @@ -335,9 +349,10 @@ $rsmq->deleteMessage('queue', $id);
```

### popMessage

Receive the next message from the queue **and delete it**.

**Important:** This method deletes the message it receives right away. There is no way to receive the message again if
**Important:** This method deletes the message it receives right away. There is no way to receive the message again if
something goes wrong while working on the message.

Parameters:
Expand All @@ -346,15 +361,16 @@ Parameters:

Returns a `\AndrewBreksa\RSMQ\Message` object with the following properties:

* `message` (string): The message's contents.
* `id` (string): The internal message id.
* `sent` (int): Timestamp of when this message was sent / created.
* `firstReceived` (int): Timestamp of when this message was first received.
* `receiveCount` (int): Number of times this message was received.
* `message` (string): The message's contents.
* `id` (string): The internal message id.
* `sent` (int): Timestamp of when this message was sent / created.
* `firstReceived` (int): Timestamp of when this message was first received.
* `receiveCount` (int): Number of times this message was received.

Note: Will return an empty object if no message is there

Throws:

* `\AndrewBreksa\RSMQ\Exceptions\QueueNotFoundException`
* `\AndrewBreksa\RSMQ\Exceptions\QueueParametersValidationException`

Expand All @@ -372,21 +388,23 @@ echo "Message: ", $message->getMessage();
```

### changeMessageVisibility
Change the visibility timer of a single message.
The time when the message will be visible again is calculated from the current time (now) + `vt`.

Change the visibility timer of a single message. The time when the message will be visible again is calculated from the
current time (now) + `vt`.

Parameters:

* `qname` (string): The Queue name.
* `id` (string): The message id.
* `vt` (int): The length of time, in seconds, that this message will not be visible. Allowed values: 0-9999999 (around
115 days)
* `vt` (int): The length of time, in seconds, that this message will not be visible. Allowed values: 0-9999999 (around
115 days)

Returns:
Returns:

* `true` if successful, `false` if the message was not found (bool).

Throws:

* `\AndrewBreksa\RSMQ\Exceptions\QueueParametersValidationException`
* `\AndrewBreksa\RSMQ\Exceptions\QueueNotFoundException`

Expand All @@ -406,7 +424,9 @@ if($rsmq->changeMessageVisibility($queue, $id, 60)) {
```

# QueueWorker

The QueueWorker class provides an easy way to consume RSMQ messages, to use it:

```php
<?php
/**
Expand Down Expand Up @@ -442,4 +462,5 @@ $worker->work(); // here we can optionally pass true to only process one message
```

# LICENSE

The MIT LICENSE. See [LICENSE](./LICENSE)

0 comments on commit 236611b

Please sign in to comment.