MAKS\AmqpAgent\RPC\ServerEndpoint::respond
Listens on requests coming via the passed queue and processes them with the passed callback.
Signature
public function respond([callable
$callback = NULL,
[string
$queueName = NULL]] )
Parameters
$callback
—
callable
- [optional] The callback to process the request. This callback will be passed an `AMQPMessage` and must return a string.
$queueName
—
string
- [optional] The name of the queue to listen on.
Returns
- string
- The last processed request.
Errors/Exceptions
-
RPCEndpointException
- If the server is not connected yet or if the passed callback didn't return a string.
Defined by Interface
ServerEndpointInterface
Test Coverage
Information
- Coverage: 27/27 Lines (100%)
- Tests: 3
- Passed: 3 (100%)
Tests
- [ PASSED ] — MAKS\AmqpAgent\Tests\RPC\ServerEndpointTest::testRespondMethodViaAliasMethodServe
- [ PASSED ] — MAKS\AmqpAgent\Tests\RPC\ServerEndpointTest::testRespondMethodRaisesAnExceptionIfTheServerIsNotConnectedYet
- [ PASSED ] — MAKS\AmqpAgent\Tests\RPC\ServerEndpointTest::testAnExceptionIsRaisedIfPassedCallbackDoesNotReturnString