svn: /pecl/amqp/trunk/ amqp.c amqp_queue.c amqp_queue.h
| From: | Pieter de Zwart | Date: | Mon, 09 Jan 2012 17:56:10 +0000 |
| Subject: | svn: /pecl/amqp/trunk/ amqp.c amqp_queue.c amqp_queue.h | ||
| Groups: | php.pecl.cvs | ||
| Request: | Send a blank email to pecl-cvs+get-17442@lists.php.net to get a copy of this message | ||
pdezwart Mon, 09 Jan 2012 17:56:10 +0000
Revision: http://svn.php.net/viewvc?view=revision&revision=321959
Log:
* Adding untested support for basic.reject
Changed paths:
U pecl/amqp/trunk/amqp.c
U pecl/amqp/trunk/amqp_queue.c
U pecl/amqp/trunk/amqp_queue.h
Modified: pecl/amqp/trunk/amqp.c
===================================================================
--- pecl/amqp/trunk/amqp.c 2012-01-09 17:41:17 UTC (rev 321958)
+++ pecl/amqp/trunk/amqp.c 2012-01-09 17:56:10 UTC (rev 321959)
@@ -212,6 +212,11 @@
ZEND_ARG_INFO(0, flags)
ZEND_END_ARG_INFO()
+ZEND_BEGIN_ARG_INFO_EX(arginfo_amqp_queue_class_reject, ZEND_SEND_BY_VAL, ZEND_RETURN_VALUE, 1)
+ ZEND_ARG_INFO(0, delivery_tag)
+ ZEND_ARG_INFO(0, flags)
+ZEND_END_ARG_INFO()
+
ZEND_BEGIN_ARG_INFO_EX(arginfo_amqp_queue_class_purge, ZEND_SEND_BY_VAL, ZEND_RETURN_VALUE, 1)
ZEND_ARG_INFO(0, queue_name)
ZEND_END_ARG_INFO()
@@ -417,6 +422,7 @@
PHP_ME(amqp_queue_class, consume, arginfo_amqp_queue_class_consume, ZEND_ACC_PUBLIC)
PHP_ME(amqp_queue_class, ack, arginfo_amqp_queue_class_ack, ZEND_ACC_PUBLIC)
PHP_ME(amqp_queue_class, nack, arginfo_amqp_queue_class_nack, ZEND_ACC_PUBLIC)
+ PHP_ME(amqp_queue_class, reject, arginfo_amqp_queue_class_reject, ZEND_ACC_PUBLIC)
PHP_ME(amqp_queue_class, purge, arginfo_amqp_queue_class_purge, ZEND_ACC_PUBLIC)
PHP_ME(amqp_queue_class, cancel, arginfo_amqp_queue_class_cancel, ZEND_ACC_PUBLIC)
Modified: pecl/amqp/trunk/amqp_queue.c
===================================================================
--- pecl/amqp/trunk/amqp_queue.c 2012-01-09 17:41:17 UTC (rev 321958)
+++ pecl/amqp/trunk/amqp_queue.c 2012-01-09 17:56:10 UTC (rev 321959)
@@ -1065,7 +1065,59 @@
/* }}} */
+/* {{{ proto int AMQPQueue::reject(long deliveryTag, [bit flags=AMQP_NOPARAM]);
+ acknowledge the message
+*/
+PHP_METHOD(amqp_queue_class, reject)
+{
+ zval *id;
+ amqp_queue_object *queue;
+ amqp_channel_object *channel;
+ amqp_connection_object *connection;
+
+ long deliveryTag = 0;
+ long flags = AMQP_NOPARAM;
+ amqp_basic_reject_t s;
+
+ if (zend_parse_method_parameters(ZEND_NUM_ARGS() TSRMLS_CC, getThis(), "Ol|l", &id,
amqp_queue_class_entry, &deliveryTag, &flags ) == FAILURE) {
+ return;
+ }
+
+ queue = (amqp_queue_object *)zend_object_store_get_object(id TSRMLS_CC);
+ /* Check that the given connection has a channel, before trying to pull the connection off the
stack */
+ if (queue->is_connected != '\1') {
+ zend_throw_exception(amqp_queue_exception_class_entry, "Could not reject message. No
connection available.", 0 TSRMLS_CC);
+ return;
+ }
+
+ channel = AMQP_GET_CHANNEL(queue);
+ AMQP_VERIFY_CHANNEL(channel, "Could not reject message.");
+
+ connection = AMQP_GET_CONNECTION(channel);
+ AMQP_VERIFY_CONNECTION(connection, "Could not reject message.");
+
+ s.delivery_tag = deliveryTag;
+ s.requeue = (AMQP_REQUEUE & flags) ? 1 : 0;
+
+ int res = amqp_send_method(
+ connection->connection_resource->connection_state,
+ channel->channel_id,
+ AMQP_BASIC_REJECT_METHOD,
+ &s
+ );
+
+ if (res) {
+ channel->is_connected = 0;
+ zend_throw_exception_ex(amqp_queue_exception_class_entry, 0 TSRMLS_CC, "Could not reject
message, error code=%d", res);
+ return;
+ }
+
+ RETURN_TRUE;
+}
+/* }}} */
+
+
/* {{{ proto int AMQPQueue::purge();
purge queue
*/
Modified: pecl/amqp/trunk/amqp_queue.h
===================================================================
--- pecl/amqp/trunk/amqp_queue.h 2012-01-09 17:41:17 UTC (rev 321958)
+++ pecl/amqp/trunk/amqp_queue.h 2012-01-09 17:56:10 UTC (rev 321959)
@@ -46,6 +46,7 @@
PHP_METHOD(amqp_queue_class, consume);
PHP_METHOD(amqp_queue_class, ack);
PHP_METHOD(amqp_queue_class, nack);
+PHP_METHOD(amqp_queue_class, reject);
PHP_METHOD(amqp_queue_class, purge);
PHP_METHOD(amqp_queue_class, cancel);