Ejemplo n.º 1
0
     },
     "testNotification": {
         "doc" : "Notification : one-way message",
         "request": [{"name": "notification", "type": "Notification"}],
         "one-way": true
     },
     "testRequestResponseException": {
         "doc" : "Request Response with Exception",
         "request": [{"name": "exception", "type": "RaiseException"}],
         "response" : "NeverSend",
         "errors" : ["AlwaysRaised"]
     }
 }
}
PROTO;
$client = NettyFramedSocketTransceiver::create('127.0.0.1', 1411);
$requestor = new Requestor(AvroProtocol::parse($protocol), $client);
try {
    $response = $requestor->request('testSimpleRequestResponse', array("message" => array("subject" => "pong")));
    echo "Response received: " . json_encode($response) . "\n";
    $response = $requestor->request('testSimpleRequestResponse', array("message" => array("subject" => "ping")));
    echo "Response received: " . json_encode($response) . "\n";
} catch (AvroRemoteException $e) {
    echo "Exception received: " . json_encode($e->getDatum()) . "\n";
}
try {
    $response = $requestor->request('testSimpleRequestWithoutParameters', array());
    echo "Response received: " . json_encode($response) . "\n";
} catch (AvroRemoteException $e) {
    echo "Exception received: " . json_encode($e->getDatum()) . "\n";
}
 public function __construct($host, $port)
 {
     $client = \NettyFramedSocketTransceiver::create($host, $port);
     parent::__construct(\AvroProtocol::parse(self::$json_protocol), $client);
 }