public void commit(String transactionId, FrameDecorator frameDecorator) { checkNotNull(transactionId, "transactionId cannot be null"); Frame frame = new Frame(Command.COMMIT); frame.transaction(transactionId); preprocessor.decorate(frame, frameDecorator); send(frame); }
@Override public void ack(String messageId, FrameDecorator frameDecorator) { checkNotNull(messageId, "messageId cannot be null"); Frame frame = new Frame(Command.ACK); frame.messageId(messageId); preprocessor.decorate(frame, frameDecorator); send(frame); }
@Override public void unsubscribe(String id, FrameDecorator frameDecorator) { checkNotNull(id, "id cannot be null"); Frame frame = new Frame(Command.UNSUBSCRIBE); frame.subscriptionId(id); preprocessor.decorate(frame, frameDecorator); send(frame); }
@Override public void send(String destination, FrameDecorator frameDecorator) { checkNotNull(destination, "destination cannot be null"); Frame frame = new Frame(Command.SEND); frame.destination(destination); preprocessor.decorate(frame, frameDecorator); send(frame); }
@Override public String subscribe(String id, String destination, FrameDecorator frameDecorator) throws StompException { checkNotNull(id, "id cannot be null"); checkNotNull(destination, "destination cannot be null"); Frame frame = new Frame(Command.SUBSCRIBE); frame.destination(destination); frame.subscriptionId(id); preprocessor.decorate(frame, frameDecorator); send(frame); return id; }
@Override public String subscribe(String destination, FrameDecorator frameDecorator) { checkNotNull(destination, "destination cannot be null"); Frame frame = new Frame(Command.SUBSCRIBE); frame.destination(destination); preprocessor.decorate(frame, frameDecorator); String subscriptionId = frame.subscriptionId(); if (subscriptionId == null) { subscriptionId = UUID.randomUUID().toString(); } frame.subscriptionId(subscriptionId); send(frame); return subscriptionId; }
@Test(expected = StompInvalidHeaderException.class) public void validationFails() { Frame frame = new Frame(Command.BEGIN); frame.transaction("tx-1"); FrameDecorator decorator = new FrameDecorator() { @Override public void decorateFrame(Frame frame) { frame.transaction("tx-2"); } }; FramePreprocessor processor = new FrameValidator(); processor.decorate(frame, decorator); }