php-amqplib

AMQPMessage
in package

A Message for use with the Channnel.basic_* methods.

Table of Contents

DELIVERY_MODE_NON_PERSISTENT  = 1
DELIVERY_MODE_PERSISTENT  = 2
$body  : string
$body_size  : int
$content_encoding  : string
$is_truncated  : bool
$properties  : array<string|int, mixed>
$propertyDefinitions  : array<string|int, mixed>
$serialized_properties  : null|string
$channel  : AMQPChannel|null
$consumerTag  : string|null
$deliveryTag  : int
$exchange  : string|null
$messageCount  : int|null
$redelivered  : bool|null
$responded  : bool
$routingKey  : string|null
__construct()  : mixed
ack()  : mixed
Acknowledge one or more messages.
get()  : mixed|AMQPChannel
Look for additional properties in the 'properties' dictionary, and if present - the 'delivery_info' dictionary.
get_properties()  : array<string|int, mixed>
Returns the properties content
getBody()  : string
getBodySize()  : int
getChannel()  : AMQPChannel|null
getConsumerTag()  : string|null
getContentEncoding()  : string
getDeliveryTag()  : int
getExchange()  : string|null
getMessageCount()  : int|null
getRoutingKey()  : string|null
has()  : bool
Check whether a property exists in the 'properties' dictionary or if present - in the 'delivery_info' dictionary.
isRedelivered()  : bool|null
isTruncated()  : bool
load_properties()  : $this
Given the raw bytes containing the property-flags and property-list from a content-frame-header, parse and insert into a dictionary stored in this object as an attribute named 'properties'.
nack()  : mixed
Reject one or more incoming messages.
reject()  : mixed
Reject an incoming message.
serialize_properties()  : string
Serializes the 'properties' attribute (a dictionary) into the raw bytes making up a set of property flags and a property list, suitable for putting into a content frame header.
set()  : mixed
Sets a property value
setBody()  : $this
Sets the message payload
setBodySize()  : AMQPMessage
setChannel()  : $this
setConsumerTag()  : $this
setDeliveryInfo()  : $this
setDeliveryTag()  : $this
setIsTruncated()  : AMQPMessage
setMessageCount()  : $this
assertUnacked()  : mixed
onResponse()  : mixed

Constants

DELIVERY_MODE_NON_PERSISTENT

public mixed DELIVERY_MODE_NON_PERSISTENT = 1

DELIVERY_MODE_PERSISTENT

public mixed DELIVERY_MODE_PERSISTENT = 2

Properties

$body

public string $body
Tags
deprecated

Will be removed in version 4.0, use getBody() instead.

$body_size

public int $body_size
Tags
deprecated

Will be removed in version 4.0, use getBodySize() instead.

$content_encoding

public string $content_encoding
Tags
deprecated

Will be removed in version 4.0, use getContentEncoding() instead.

$is_truncated

public bool $is_truncated = false
Tags
deprecated

Will be removed in version 4.0, use isTruncated() instead.

$properties

protected array<string|int, mixed> $properties = array()

Properties content

$propertyDefinitions

protected static array<string|int, mixed> $propertyDefinitions = array('content_type' => 'shortstr', 'content_encoding' => 'shortstr', 'application_headers' => 'table_object', 'delivery_mode' => 'octet', 'priority' => 'octet', 'correlation_id' => 'shortstr', 'reply_to' => 'shortstr', 'expiration' => 'shortstr', 'message_id' => 'shortstr', 'timestamp' => 'timestamp', 'type' => 'shortstr', 'user_id' => 'shortstr', 'app_id' => 'shortstr', 'cluster_id' => 'shortstr')

$serialized_properties

protected null|string $serialized_properties

Compiled properties

Methods

__construct()

public __construct([string $body = '' ][, array<string|int, mixed> $properties = array() ]) : mixed
Parameters
$body : string = ''
$properties : array<string|int, mixed> = array()
Return values
mixed

ack()

Acknowledge one or more messages.

public ack([bool $multiple = false ]) : mixed
Parameters
$multiple : bool = false

If true, the delivery tag is treated as "up to and including", so that multiple messages can be acknowledged with a single method.

Tags
since
2.12.0
link
https://www.rabbitmq.com/amqp-0-9-1-reference.html#basic.ack
Return values
mixed

get()

Look for additional properties in the 'properties' dictionary, and if present - the 'delivery_info' dictionary.

public get(string $name) : mixed|AMQPChannel
Parameters
$name : string
Tags
throws
OutOfBoundsException
Return values
mixed|AMQPChannel

get_properties()

Returns the properties content

public get_properties() : array<string|int, mixed>
Return values
array<string|int, mixed>

getBody()

public getBody() : string
Return values
string

getBodySize()

public getBodySize() : int
Return values
int

getConsumerTag()

public getConsumerTag() : string|null
Tags
since
2.12.0
Return values
string|null

getContentEncoding()

public getContentEncoding() : string
Return values
string

getExchange()

public getExchange() : string|null
Tags
since
2.12.0
Return values
string|null

getMessageCount()

public getMessageCount() : int|null
Tags
since
2.12.0
Return values
int|null

getRoutingKey()

public getRoutingKey() : string|null
Tags
since
2.12.0
Return values
string|null

has()

Check whether a property exists in the 'properties' dictionary or if present - in the 'delivery_info' dictionary.

public has(string $name) : bool
Parameters
$name : string
Return values
bool

isRedelivered()

public isRedelivered() : bool|null
Tags
since
2.12.0
Return values
bool|null

isTruncated()

public isTruncated() : bool
Return values
bool

load_properties()

Given the raw bytes containing the property-flags and property-list from a content-frame-header, parse and insert into a dictionary stored in this object as an attribute named 'properties'.

public load_properties(AMQPReader $reader) : $this
Parameters
$reader : AMQPReader

NOTE: do not mutate $reader

Return values
$this

nack()

Reject one or more incoming messages.

public nack([bool $requeue = false ][, bool $multiple = false ]) : mixed
Parameters
$requeue : bool = false

If true, the server will attempt to requeue the message. If requeue is false or the requeue attempt fails the messages are discarded or dead-lettered.

$multiple : bool = false

If true, the delivery tag is treated as "up to and including", so that multiple messages can be rejected with a single method.

Tags
since
2.12.0
link
https://www.rabbitmq.com/amqp-0-9-1-reference.html#basic.nack
Return values
mixed

reject()

Reject an incoming message.

public reject([bool $requeue = true ]) : mixed
Parameters
$requeue : bool = true

If requeue is true, the server will attempt to requeue the message. If requeue is false or the requeue attempt fails the messages are discarded or dead-lettered.

Tags
since
2.12.0
link
https://www.rabbitmq.com/amqp-0-9-1-reference.html#basic.reject
Return values
mixed

serialize_properties()

Serializes the 'properties' attribute (a dictionary) into the raw bytes making up a set of property flags and a property list, suitable for putting into a content frame header.

public serialize_properties() : string
Tags
todo

Inject the AMQPWriter to make the method easier to test

Return values
string

set()

Sets a property value

public set(string $name, mixed $value) : mixed
Parameters
$name : string

The property name (one of the property definition)

$value : mixed

The property value

Tags
throws
OutOfBoundsException
Return values
mixed

setBody()

Sets the message payload

public setBody(string $body) : $this
Parameters
$body : string
Return values
$this

setChannel()

public setChannel(AMQPChannel $channel) : $this
Parameters
$channel : AMQPChannel
Tags
throws
RuntimeException
since
2.12.0
Return values
$this

setConsumerTag()

public setConsumerTag(string $consumerTag) : $this
Parameters
$consumerTag : string
Tags
since
2.12.0
Return values
$this

setDeliveryInfo()

public setDeliveryInfo(int $deliveryTag, bool $redelivered, string $exchange, string $routingKey) : $this
Parameters
$deliveryTag : int
$redelivered : bool
$exchange : string
$routingKey : string
Tags
since
2.12.0
Return values
$this

setDeliveryTag()

public setDeliveryTag(int|string $deliveryTag) : $this
Parameters
$deliveryTag : int|string
Tags
since
2.12.0
Return values
$this

setMessageCount()

public setMessageCount(int $messageCount) : $this
Parameters
$messageCount : int
Tags
since
2.12.0
Return values
$this

assertUnacked()

protected assertUnacked() : mixed
Tags
throws
LogicException

When response to broker was already sent.

Return values
mixed

onResponse()

protected onResponse() : mixed
Return values
mixed

Search results