This repository was archived by the owner on Dec 12, 2018. It is now read-only.
-
Notifications
You must be signed in to change notification settings - Fork 2
/
Copy pathPsrMessage.php
178 lines (157 loc) · 5.56 KB
/
PsrMessage.php
1
2
3
4
5
6
7
8
9
10
11
12
13
14
15
16
17
18
19
20
21
22
23
24
25
26
27
28
29
30
31
32
33
34
35
36
37
38
39
40
41
42
43
44
45
46
47
48
49
50
51
52
53
54
55
56
57
58
59
60
61
62
63
64
65
66
67
68
69
70
71
72
73
74
75
76
77
78
79
80
81
82
83
84
85
86
87
88
89
90
91
92
93
94
95
96
97
98
99
100
101
102
103
104
105
106
107
108
109
110
111
112
113
114
115
116
117
118
119
120
121
122
123
124
125
126
127
128
129
130
131
132
133
134
135
136
137
138
139
140
141
142
143
144
145
146
147
148
149
150
151
152
153
154
155
156
157
158
159
160
161
162
163
164
165
166
167
168
169
170
171
172
173
174
175
176
177
178
<?php
namespace Enqueue\Psr;
/**
* The Message interface is the root interface of all transport messages.
* Most message-oriented middleware (MOM) products
* treat messages as lightweight entities that consist of a header and a payload.
* The header contains fields used for message routing and identification;
* the payload contains the application data being sent.
*
* Within this general form, the definition of a message varies significantly across products.
*
* @see https://docs.oracle.com/javaee/7/api/javax/jms/Message.html
*/
interface PsrMessage
{
/**
* @return string
*/
public function getBody();
/**
* @param string $body
*/
public function setBody($body);
/**
* @param array $properties
*/
public function setProperties(array $properties);
/**
* @return array [name => value, ...]
*/
public function getProperties();
/**
* @param string $name
* @param mixed $value
*/
public function setProperty($name, $value);
/**
* @param string $name
* @param mixed $default
*
* @return mixed
*/
public function getProperty($name, $default = null);
/**
* @param array $headers
*/
public function setHeaders(array $headers);
/**
* @return array [name => value, ...]
*/
public function getHeaders();
/**
* @param string $name
* @param mixed $value
*/
public function setHeader($name, $value);
/**
* @param string $name
* @param mixed $default
*
* @return mixed
*/
public function getHeader($name, $default = null);
/**
* @param bool $redelivered
*/
public function setRedelivered($redelivered);
/**
* Gets an indication of whether this message is being redelivered.
* The message is considered as redelivered,
* when it was sent by a broker to consumer but consumer does not ACK or REJECT it.
* The broker brings the message back to the queue and mark it as redelivered.
*
* @return bool
*/
public function isRedelivered();
/**
* Sets the correlation ID for the message.
* A client can use the correlation header field to link one message with another.
* A typical use is to link a response message with its request message.
*
* @param string $correlationId the message ID of a message being referred to
*
* @throws Exception if the provider fails to set the correlation ID due to some internal error
*/
public function setCorrelationId($correlationId);
/**
* Gets the correlation ID for the message.
* This method is used to return correlation ID values that are either provider-specific message IDs
* or application-specific String values.
*
* @throws Exception if the provider fails to get the correlation ID due to some internal error
*
* @return string
*/
public function getCorrelationId();
/**
* Sets the message ID.
* Providers set this field when a message is sent.
* This method can be used to change the value for a message that has been received.
*
* @param string $messageId the ID of the message
*
* @throws Exception if the provider fails to set the message ID due to some internal error
*/
public function setMessageId($messageId);
/**
* Gets the message Id.
* The MessageId header field contains a value that uniquely identifies each message sent by a provider.
*
* When a message is sent, MessageId can be ignored.
*
* @throws Exception if the provider fails to get the message ID due to some internal error
*
* @return string
*/
public function getMessageId();
/**
* Gets the message timestamp.
* The timestamp header field contains the time a message was handed off to a provider to be sent.
* It is not the time the message was actually transmitted,
* because the actual send may occur later due to transactions or other client-side queueing of messages.
*
* @return int
*/
public function getTimestamp();
/**
* Sets the message timestamp.
* Providers set this field when a message is sent.
* This method can be used to change the value for a message that has been received.
*
* @param int $timestamp
*
* @throws Exception if the provider fails to set the timestamp due to some internal error
*/
public function setTimestamp($timestamp);
/**
* Sets the destination to which a reply to this message should be sent.
* The ReplyTo header field contains the destination where a reply to the current message should be sent. If it is null, no reply is expected.
* The destination may be a Queue only. A topic is not supported at the moment.
* Messages sent with a null ReplyTo value may be a notification of some event, or they may just be some data the sender thinks is of interest.
* Messages with a ReplyTo value typically expect a response.
* A response is optional; it is up to the client to decide. These messages are called requests.
* A message sent in response to a request is called a reply.
* In some cases a client may wish to match a request it sent earlier with a reply it has just received.
* The client can use the CorrelationID header field for this purpose.
*
* @param string|null $replyTo
*/
public function setReplyTo($replyTo);
/**
* Gets the destination to which a reply to this message should be sent.
*
* @return string|null
*/
public function getReplyTo();
}