List of usage examples for com.rabbitmq.client.impl Method hasContent
public abstract boolean hasContent();
From source file:de.htwk_leipzig.bis.connection.handshake.clientRewrite.AMQCommand.java
License:Mozilla Public License
/** * Sends this command down the named channel on the channel's connection, * possibly in multiple frames./* w ww. j a v a 2 s .c o m*/ * * @param channel * the channel on which to transmit the command * @throws IOException * if an error is encountered */ public void transmit(AMQChannel channel) throws IOException { int channelNumber = channel.getChannelNumber(); AMQConnection connection = channel.getConnection(); synchronized (assembler) { Method m = this.assembler.getMethod(); connection.writeFrame(m.toFrame(channelNumber)); if (m.hasContent()) { byte[] body = this.assembler.getContentBody(); connection.writeFrame(this.assembler.getContentHeader().toFrame(channelNumber, body.length)); int frameMax = connection.getFrameMax(); int bodyPayloadMax = (frameMax == 0) ? body.length : frameMax - EMPTY_FRAME_SIZE; for (int offset = 0; offset < body.length; offset += bodyPayloadMax) { int remaining = body.length - offset; int fragmentLength = (remaining < bodyPayloadMax) ? remaining : bodyPayloadMax; Frame frame = Frame.fromBodyFragment(channelNumber, body, offset, fragmentLength); connection.writeFrame(frame); } } } connection.flush(); }
From source file:de.htwk_leipzig.bis.connection.handshake.clientRewrite.CommandAssembler.java
License:Mozilla Public License
public CommandAssembler(Method method, AMQContentHeader contentHeader, byte[] body) { this.method = method; this.contentHeader = contentHeader; this.bodyN = new ArrayList<byte[]>(2); this.bodyLength = 0; this.remainingBodyBytes = 0; appendBodyFragment(body);//from w ww.j av a 2 s . c om if (method == null) { this.state = CAState.EXPECTING_METHOD; } else if (contentHeader == null) { this.state = method.hasContent() ? CAState.EXPECTING_CONTENT_HEADER : CAState.COMPLETE; } else { this.remainingBodyBytes = contentHeader.getBodySize() - this.bodyLength; updateContentBodyState(); } }