protected AMQFrameDecodingException newUnknownMethodException(final int classId, final int methodId, ProtocolVersion protocolVersion) { return new AMQFrameDecodingException(ErrorCodes.COMMAND_INVALID, "Method " + methodId + " unknown in AMQP version " + protocolVersion + " (while trying to decode class " + classId + " method " + methodId + ".", null); }
private static int toNumber(final byte digit) throws AMQFrameDecodingException { if (digit >= '0' && digit <= '9') { return digit - (byte) '0'; } throw new AMQFrameDecodingException(String.format("Unexpected character '%c' in string representing long value", digit)); }
public BasicContentHeaderProperties createContentHeaderProperties(int classId, int propertyFlags, QpidByteBuffer buffer, int size) throws AMQFrameDecodingException { BasicContentHeaderProperties properties; if (classId == BasicConsumeBody.CLASS_ID) { properties = new BasicContentHeaderProperties(buffer, propertyFlags, size); } else { throw new AMQFrameDecodingException("Unsupported content header class id: " + classId, null); } return properties; } }
protected void processInput(final QpidByteBuffer in) throws AMQFrameDecodingException, AMQProtocolVersionException { final byte type = in.get(); final int channel = in.getUnsignedShort(); final long bodySize = in.getUnsignedInt(); // bodySize can be zero if ((channel < 0) || (bodySize < 0)) { throw new AMQFrameDecodingException( "Undecodable frame: type = " + type + " channel = " + channel + " bodySize = " + bodySize); } processFrame(channel, type, bodySize, in); byte marker = in.get(); if ((marker & 0xFF) != 0xCE) { throw new AMQFrameDecodingException( "End of frame marker not found. Read " + marker + " length=" + bodySize + " type=" + type); } }
protected int decodable(final QpidByteBuffer in) throws AMQFrameDecodingException { final int remainingAfterAttributes = in.remaining() - FRAME_HEADER_SIZE; // type, channel, body length and end byte if (remainingAfterAttributes < 0) { return -remainingAfterAttributes; } // Get an unsigned int, lifted from MINA ByteBuffer getUnsignedInt() final long bodySize = ((long)in.getInt(in.position()+3)) & 0xffffffffL; if (bodySize > _maxFrameSize) { throw new AMQFrameDecodingException( "Incoming frame size of " + bodySize + " is larger than negotiated maximum of " + _maxFrameSize); } long required = (1L+bodySize)-remainingAfterAttributes; return required > 0 ? (int) required : 0; }
protected void processFrame(final int channel, final byte type, final long bodySize, final QpidByteBuffer in) throws AMQFrameDecodingException { switch (type) { case 1: processMethod(channel, in); break; case 2: ContentHeaderBody.process(in, _methodProcessor.getChannelMethodProcessor(channel), bodySize); break; case 3: ContentBody.process(in, _methodProcessor.getChannelMethodProcessor(channel), bodySize); break; case 8: HeartbeatBody.process(channel, in, _methodProcessor, bodySize); break; default: throw new AMQFrameDecodingException("Unsupported frame type: " + type); } }
public static void process(final QpidByteBuffer buffer, final ChannelMethodProcessor methodProcessor, final long size) throws AMQFrameDecodingException { int classId = buffer.getUnsignedShort(); buffer.getUnsignedShort(); long bodySize = buffer.getLong(); int propertyFlags = buffer.getUnsignedShort(); BasicContentHeaderProperties properties; if (classId != CLASS_ID) { throw new AMQFrameDecodingException("Unsupported content header class id: " + classId, null); } properties = new BasicContentHeaderProperties(buffer, propertyFlags, (int)(size-14)); if(!methodProcessor.ignoreAllButCloseOk()) { methodProcessor.receiveMessageHeader(properties, bodySize); } else { properties.dispose(); } }