|
|||||
|
|
|||||
PHP Handling Errors
Handling ErrorsBasically there are two kind of errors you can expiricene when using this client: errors while trying to connect to a broker and errors after sending a certain command to the broker (like authorization errors for example). Also, there is a difference in how errors and hanlded in PHP4 and PHP5 compatible clients. Broker ErrorsIn case you use the client (or at least the current operation) in a sychronous mode , the client will wait for the broker to send a receipt for every synchronous command. In case that error is received instead of the receipt, the client will report the error. In case you have sent a command in an asynchronous mode the erros will be ignored. PHP4Since PHP4 doesn't support exceptions and it is not nice that library triggers fatal errors, there's a simple error handling approach implemented in PHP4 compatible Stomp client. A false value returned from the method call indicates an error. Also, there are two StompConnection class properties that holds error descriptions:
So, when you use PHP4 client, be sure that you always check a return value of the method call. Take a look at the folloing code snippet PHP4 code sample if (!$conn->send("/queue/test", "test")) { echo $conn->error . "\n"; echo $conn->exception . "\n"; trigger_error("Sending failed", E_USER_ERROR); } If used with ActiveMQ broker and try to send an unauthorized message it will return the following errors
|
|||||
|
Copyright 2003-2006 - The Codehaus. All rights reserved unless otherwise noted.
Powered by Atlassian Confluence
|
|||||