Skip to end of metadata
Go to start of metadata

Handling Errors

Basically 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 Errors

In 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.

PHP4

Since 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:

  • error contains a short description of the error
  • exception contains a full stack trace retruned from the broker (if applicable)

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 used with ActiveMQ broker and try to send an unauthorized message it will return the following errors

  • error
    User guest is not authorized to write to: queue://test
  • exception
    java.lang.SecurityException: User guest is not authorized to write to: queue://test
            at org.apache.activemq.security.AuthorizationBroker.send(AuthorizationBroker.java:173)
            at org.apache.activemq.broker.MutableBrokerFilter.send(MutableBrokerFilter.java:135)
            at org.apache.activemq.broker.TransportConnection.processMessage(TransportConnection.java:433)
            at org.apache.activemq.command.ActiveMQMessage.visit(ActiveMQMessage.java:623)
            at org.apache.activemq.broker.TransportConnection.service(TransportConnection.java:280)
            at org.apache.activemq.broker.TransportConnection$1.onCommand(TransportConnection.java:177)
            at org.apache.activemq.transport.TransportFilter.onCommand(TransportFilter.java:67)
            at org.apache.activemq.transport.stomp.StompTransportFilter.sendToActiveMQ(StompTransportFilter.java:79)
            at org.apache.activemq.transport.stomp.ProtocolConverter.sendToActiveMQ(ProtocolConverter.java:128)
            at org.apache.activemq.transport.stomp.ProtocolConverter.onStompSend(ProtocolConverter.java:222)
            at org.apache.activemq.transport.stomp.ProtocolConverter.onStompCommad(ProtocolConverter.java:149)
            at org.apache.activemq.transport.stomp.StompTransportFilter.onCommand(StompTransportFilter.java:69)
            at org.apache.activemq.transport.TransportSupport.doConsume(TransportSupport.java:83)
            at org.apache.activemq.transport.tcp.TcpTransport.doRun(TcpTransport.java:189)
            at org.apache.activemq.transport.tcp.TcpTransport.run(TcpTransport.java:176)
            at java.lang.Thread.run(Thread.java:595)User guest is not authorized to read from: queue://test
    

PHP5

TODO