1
|
|
|
<?php |
2
|
|
|
|
3
|
|
|
/** |
4
|
|
|
* AppserverIo\Messaging\QueueResponse |
5
|
|
|
* |
6
|
|
|
* NOTICE OF LICENSE |
7
|
|
|
* |
8
|
|
|
* This source file is subject to the Open Software License (OSL 3.0) |
9
|
|
|
* that is available through the world-wide-web at this URL: |
10
|
|
|
* http://opensource.org/licenses/osl-3.0.php |
11
|
|
|
* |
12
|
|
|
* PHP version 5 |
13
|
|
|
* |
14
|
|
|
* @author Tim Wagner <[email protected]> |
15
|
|
|
* @copyright 2015 TechDivision GmbH <[email protected]> |
16
|
|
|
* @license http://opensource.org/licenses/osl-3.0.php Open Software License (OSL 3.0) |
17
|
|
|
* @link https://github.com/appserver-io/messaging |
18
|
|
|
* @link http://www.appserver.io |
19
|
|
|
*/ |
20
|
|
|
|
21
|
|
|
namespace AppserverIo\Messaging; |
22
|
|
|
|
23
|
|
|
/** |
24
|
|
|
* A message queue response implementation. |
25
|
|
|
* |
26
|
|
|
* @author Tim Wagner <[email protected]> |
27
|
|
|
* @copyright 2015 TechDivision GmbH <[email protected]> |
28
|
|
|
* @license http://opensource.org/licenses/osl-3.0.php Open Software License (OSL 3.0) |
29
|
|
|
* @link https://github.com/appserver-io/messaging |
30
|
|
|
* @link http://www.appserver.io |
31
|
|
|
*/ |
32
|
|
|
class QueueResponse |
33
|
|
|
{ |
34
|
|
|
|
35
|
|
|
/** |
36
|
|
|
* The message status. |
37
|
|
|
* |
38
|
|
|
* @var integer |
39
|
|
|
*/ |
40
|
|
|
protected $statusCode = MessageQueueProtocol::STATUS_CODE_UNKNOWN; |
41
|
|
|
|
42
|
|
|
/** |
43
|
|
|
* The message status message. |
44
|
|
|
* |
45
|
|
|
* @var string |
46
|
|
|
*/ |
47
|
|
|
protected $message = ''; |
48
|
|
|
|
49
|
|
|
/** |
50
|
|
|
* Initializes the response with the parts splitted from the message queue response. |
51
|
|
|
* |
52
|
|
|
* @param integer $statusCode The response status from the queue |
53
|
|
|
* @param string $message The status message sent along with status code |
54
|
|
|
*/ |
55
|
1 |
|
public function __construct($statusCode, $message) |
56
|
|
|
{ |
57
|
1 |
|
$this->statusCode = $statusCode; |
58
|
1 |
|
$this->message = $message; |
59
|
1 |
|
} |
60
|
|
|
|
61
|
|
|
/** |
62
|
|
|
* Returns true if the message was successfully delivered |
63
|
|
|
* to the message queue. |
64
|
|
|
* |
65
|
|
|
* @return boolean TRUE if the message was successfully delivered, else FALSE |
66
|
|
|
*/ |
67
|
1 |
|
public function success() |
68
|
|
|
{ |
69
|
1 |
|
return $this->getStatusCode() === MessageQueueProtocol::STATUS_CODE_OK; |
70
|
|
|
} |
71
|
|
|
|
72
|
|
|
/** |
73
|
|
|
* Returns the status from the message queue response. |
74
|
|
|
* |
75
|
|
|
* @return integer The status itself |
76
|
|
|
*/ |
77
|
1 |
|
public function getStatusCode() |
78
|
|
|
{ |
79
|
1 |
|
return $this->statusCode; |
80
|
|
|
} |
81
|
|
|
|
82
|
|
|
/** |
83
|
|
|
* Returns the status message from the message queue response. |
84
|
|
|
* |
85
|
|
|
* @return string The status message |
86
|
|
|
*/ |
87
|
|
|
public function getMessage() |
88
|
|
|
{ |
89
|
|
|
return $this->message; |
90
|
|
|
} |
91
|
|
|
} |
92
|
|
|
|