IT. Expert System.

PHP

Acknowledge the receipt of a message


AMQPQueue::ack

(PECL amqp >= Unknown)

AMQPQueue::ackAcknowledge the receipt of a message

Description

public bool AMQPQueue::ack ( int $delivery_tag [, int $flags = AMQP_NOPARAM ] )

This method allows the acknowledgement of a message that is retrieved without the AMQP_AUTOACK flag through AMQPQueue::get() or AMQPQueue::consume()

Parameters

delivery_tag

The message delivery tag of which to acknowledge receipt.

flags

The only valid flag that can be passed is AMQP_MULTIPLE.

Errors/Exceptions

Throws AMQPChannelException if the channel is not open.

Throws AMQPConnectionException if the connection to the broker was lost.

Return Values

Returns TRUE on success or FALSE on failure.

Examples

Example #1 AMQPQueue::ack() example with AMQPQueue::get()

<?php

/* Create a connection using all default credentials: */
$connection = new AMQPConnection();
$connection->connect();

$channel = new AMQPChannel($connection);

/* create a queue object */
$queue = new AMQPQueue($channel);

//declare the queue
$queue->declare('myqueue');

//get the next message, but don't mark it as delivered
$message $queue->get(AMQP_NOPARAM);

echo 
$message['msg'];

//acknowledge the message as received
$queue->ack($message['delivery_tag']);

?>

Example #2 AMQPQueue::ack() example with AMQPQueue::consume()

<?php

/* Create a connection using all default credentials: */
$connection = new AMQPConnection();
$connection->connect();

/* create a queue object */
$queue = new AMQPQueue($connection);

//declare the queue
$queue->declare('myqueue');

$options = array(
    
'min' => 1,
    
'max' => 10,
    
'ack' => false
);

//get the messages, but don't mark them as delivered
$messages $queue->consume($options);

foreach (
$messages as $message) {
    echo 
$message['message_body'];
    
//acknowledge the message as received
    
$queue->ack($message['delivery_tag']);
}

?>



Content

Android Reference

Java basics

Java Enterprise Edition (EE)

Java Standard Edition (SE)

SQL

HTML

PHP

CSS

Java Script

MYSQL

JQUERY

VBS

REGEX

C

C++

C#

Design patterns

RFC (standard status)

RFC (proposed standard status)

RFC (draft standard status)

RFC (informational status)

RFC (experimental status)

RFC (best current practice status)

RFC (historic status)

RFC (unknown status)

IT dictionary

License.
All information of this service is derived from the free sources and is provided solely in the form of quotations. This service provides information and interfaces solely for the familiarization (not ownership) and under the "as is" condition.
Copyright 2016 © ELTASK.COM. All rights reserved.
Site is optimized for mobile devices.
Downloads: 202 / 158795230. Delta: 0.97576 с