From 189b8dcfc211f9699f0bb6df7f6aff07fae6faa0 Mon Sep 17 00:00:00 2001 From: Pierrick Charron Date: Sun, 7 Dec 2014 13:22:01 -0500 Subject: [PATCH] Fixed bug #64671 (Add stomp_nack and Stomp::nack functions). --- package.xml | 1 + php_stomp.c | 38 +++++++++++++++++++++++++++++++++----- php_stomp.h | 1 + 3 files changed, 35 insertions(+), 5 deletions(-) diff --git a/package.xml b/package.xml index 073ee3a..c456ef4 100644 --- a/package.xml +++ b/package.xml @@ -24,6 +24,7 @@ This extension allows php applications to communicate with any Stomp compliant M - Fixed bug #59970 (acking a message makes rabbitmq disconnect the server). (Pierrick) - Fixed bug #67170 (Disable Nagle's Algorithm with TCP_NODELAY, it delays sending small messages). (Yarek Tyshchenko) - Fixed bug #68497 (Stomp client doesn't parse ERROR response on CONNECT). (Lorenzo Fontana) +- Fixed bug #64671 (Add stomp_nack and Stomp::nack functions). (Pierrick) diff --git a/php_stomp.c b/php_stomp.c index 2d574a5..e1d68f3 100755 --- a/php_stomp.c +++ b/php_stomp.c @@ -177,6 +177,17 @@ ZEND_ARG_INFO(0, msg) ZEND_ARG_ARRAY_INFO(0, headers, 1) ZEND_END_ARG_INFO() +ZEND_BEGIN_ARG_INFO_EX(stomp_nack_args, 0, 0, 2) +ZEND_ARG_INFO(0, link) +ZEND_ARG_INFO(0, msg) +ZEND_ARG_ARRAY_INFO(0, headers, 1) +ZEND_END_ARG_INFO() + +ZEND_BEGIN_ARG_INFO_EX(stomp_oop_nack_args, 0, 0, 1) +ZEND_ARG_INFO(0, msg) +ZEND_ARG_ARRAY_INFO(0, headers, 1) +ZEND_END_ARG_INFO() + ZEND_BEGIN_ARG_INFO_EX(stomp_set_read_timeout_args, 0, 0, 2) ZEND_ARG_INFO(0, link) ZEND_ARG_INFO(0, seconds) @@ -211,6 +222,7 @@ zend_function_entry stomp_functions[] = { PHP_FE(stomp_commit, stomp_transaction_args) PHP_FE(stomp_abort, stomp_transaction_args) PHP_FE(stomp_ack, stomp_ack_args) + PHP_FE(stomp_nack, stomp_nack_args) PHP_FE(stomp_error, stomp_link_only) PHP_FE(stomp_set_read_timeout, stomp_set_read_timeout_args) PHP_FE(stomp_get_read_timeout, stomp_link_only) @@ -232,6 +244,7 @@ static zend_function_entry stomp_methods[] = { PHP_FALIAS(commit, stomp_commit, stomp_oop_transaction_args) PHP_FALIAS(abort, stomp_abort, stomp_oop_transaction_args) PHP_FALIAS(ack, stomp_ack, stomp_oop_ack_args) + PHP_FALIAS(nack, stomp_nack, stomp_oop_nack_args) PHP_FALIAS(error, stomp_error, stomp_no_args) PHP_FALIAS(setReadTimeout, stomp_set_read_timeout, stomp_oop_set_read_timeout_args) PHP_FALIAS(getReadTimeout, stomp_get_read_timeout, stomp_no_args) @@ -1092,10 +1105,9 @@ PHP_FUNCTION(stomp_abort) } /* }}} */ -/* {{{ proto boolean Stomp::ack(mixed msg [, array headers]) - Acknowledge consumption of a message from a subscription using client acknowledgment */ -PHP_FUNCTION(stomp_ack) -{ +/* {{{ _php_stomp_acknowledgment + */ +static void _php_stomp_acknowledgment(INTERNAL_FUNCTION_PARAMETERS, char *cmd) { zval *stomp_object = getThis(); zval *msg = NULL, *headers = NULL; stomp_t *stomp = NULL; @@ -1116,7 +1128,7 @@ PHP_FUNCTION(stomp_ack) ZEND_FETCH_RESOURCE(stomp, stomp_t *, &arg, -1, PHP_STOMP_RES_NAME, le_stomp); } - INIT_FRAME(frame, "ACK"); + INIT_FRAME(frame, cmd); if (NULL != headers) { FRAME_HEADER_FROM_HASHTABLE(frame.headers, Z_ARRVAL_P(headers)); @@ -1144,6 +1156,22 @@ PHP_FUNCTION(stomp_ack) } /* }}} */ +/* {{{ proto boolean Stomp::ack(mixed msg [, array headers]) + Acknowledge consumption of a message from a subscription using client acknowledgment */ +PHP_FUNCTION(stomp_ack) +{ + _php_stomp_acknowledgment(INTERNAL_FUNCTION_PARAM_PASSTHRU, "ACK"); +} +/* }}} */ + +/* {{{ proto boolean Stomp::nack(mixed msg [, array headers]) + Negative Acknowledgment of a message from a subscription */ +PHP_FUNCTION(stomp_nack) +{ + _php_stomp_acknowledgment(INTERNAL_FUNCTION_PARAM_PASSTHRU, "NACK"); +} +/* }}} */ + /* {{{ proto string Stomp::error() Get the last error message */ PHP_FUNCTION(stomp_error) diff --git a/php_stomp.h b/php_stomp.h index 9362700..89200a4 100644 --- a/php_stomp.h +++ b/php_stomp.h @@ -82,6 +82,7 @@ PHP_FUNCTION(stomp_begin); PHP_FUNCTION(stomp_commit); PHP_FUNCTION(stomp_abort); PHP_FUNCTION(stomp_ack); +PHP_FUNCTION(stomp_nack); PHP_FUNCTION(stomp_error); PHP_FUNCTION(stomp_set_read_timeout); PHP_FUNCTION(stomp_get_read_timeout);