Search in sources :

Example 6 with StompFrameMessage

use of com.sun.messaging.bridge.api.StompFrameMessage in project openmq by eclipse-ee4j.

the class StompMessageDispatchFilter method handleRead.

@Override
public NextAction handleRead(final FilterChainContext ctx) throws IOException {
    synchronized (this) {
        if (_bc == null || _jmsprop == null || _logger == null || _sbr == null) {
            if (_logger != null) {
                _logger.log(Level.WARNING, "Stomp service not ready yet");
            }
            throw new IOException("Stomp service not ready yet");
        }
    }
    StompProtocolHandlerImpl sph = null;
    try {
        final StompFrameMessage msg = ctx.getMessage();
        sph = (StompProtocolHandlerImpl) ctx.getAttributes().getAttribute(StompMessageFilter.STOMP_PROTOCOL_HANDLER);
        switch(msg.getCommand()) {
            case CONNECT:
            case STOMP:
                sph.onCONNECT(msg, this, ctx);
                break;
            case SEND:
                sph.onSEND(msg, this, ctx);
                break;
            case SUBSCRIBE:
                StompOutputHandler soh = new AsyncStompOutputHandler(ctx, sph);
                sph.onSUBSCRIBE(msg, this, soh, ctx);
                return ctx.getForkAction();
            case UNSUBSCRIBE:
                sph.onUNSUBSCRIBE(msg, this, ctx);
                break;
            case BEGIN:
                sph.onBEGIN(msg, this, ctx);
                break;
            case COMMIT:
                sph.onCOMMIT(msg, this, ctx);
                break;
            case ABORT:
                sph.onABORT(msg, this, ctx);
                break;
            case ACK:
                sph.onACK(msg, this, ctx);
                break;
            case DISCONNECT:
                sph.onDISCONNECT(msg, this, ctx);
                break;
            case ERROR:
                sendToClient(msg, sph, ctx);
                break;
            default:
                throw new IOException(((StompFrameMessageImpl) msg).getKStringX_UNKNOWN_STOMP_CMD(msg.getCommand().toString()));
        }
    } catch (Throwable t) {
        _logger.log(Level.SEVERE, t.getMessage(), t);
        try {
            StompFrameMessage err = sph.toStompErrorMessage("StompProtocolFilter", t, (t instanceof IOException));
            sendToClient(err, sph, ctx);
        } catch (Exception e) {
            _logger.log(Level.SEVERE, _sbr.getKString(_sbr.E_UNABLE_SEND_ERROR_MSG, t.toString(), e.toString()), e);
        }
    }
    return ctx.getInvokeAction();
}
Also used : StompOutputHandler(com.sun.messaging.bridge.api.StompOutputHandler) StompFrameMessage(com.sun.messaging.bridge.api.StompFrameMessage) IOException(java.io.IOException) IOException(java.io.IOException)

Aggregations

StompFrameMessage (com.sun.messaging.bridge.api.StompFrameMessage)6 IOException (java.io.IOException)3 StompDestination (com.sun.messaging.bridge.api.StompDestination)2 StompMessage (com.sun.messaging.bridge.api.StompMessage)2 StompProtocolException (com.sun.messaging.bridge.api.StompProtocolException)2 StompFrameParseException (com.sun.messaging.bridge.api.StompFrameParseException)1 StompOutputHandler (com.sun.messaging.bridge.api.StompOutputHandler)1 StompUnrecoverableAckException (com.sun.messaging.bridge.api.StompUnrecoverableAckException)1 BrokerException (com.sun.messaging.jmq.jmsserver.util.BrokerException)1 ConsumerClosedNoDeliveryException (com.sun.messaging.jmq.jmsservice.ConsumerClosedNoDeliveryException)1 JMSAck (com.sun.messaging.jmq.jmsservice.JMSAck)1 JMSServiceException (com.sun.messaging.jmq.jmsservice.JMSServiceException)1 BASE64Decoder (com.sun.messaging.jmq.util.BASE64Decoder)1 JsonObject (jakarta.json.JsonObject)1 JsonReader (jakarta.json.JsonReader)1 JsonString (jakarta.json.JsonString)1 StringReader (java.io.StringReader)1 Method (java.lang.reflect.Method)1 Enumeration (java.util.Enumeration)1