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();
}
Aggregations