use of org.apache.qpid.server.protocol.v1_0.framing.AMQFrame in project qpid-broker-j by apache.
the class FrameEncoder method encode.
@Override
public ByteBuffer encode(final Object msg) {
if (msg instanceof AMQFrame) {
List<ByteBuffer> buffers = new ArrayList<>();
FrameWriter _frameWriter = new FrameWriter(TYPE_REGISTRY, new ByteBufferSender() {
@Override
public boolean isDirectBufferPreferred() {
return false;
}
@Override
public void send(final QpidByteBuffer msg) {
byte[] data = new byte[msg.remaining()];
msg.get(data);
buffers.add(ByteBuffer.wrap(data));
}
@Override
public void flush() {
}
@Override
public void close() {
}
});
AMQFrame frame = (AMQFrame) msg;
FRAME_LOGGER.debug("SEND: " + frame.getFrameBody());
_frameWriter.send(frame);
int remaining = 0;
for (ByteBuffer byteBuffer : buffers) {
remaining += byteBuffer.remaining();
}
ByteBuffer result = ByteBuffer.allocate(remaining);
for (ByteBuffer byteBuffer : buffers) {
result.put(byteBuffer);
}
result.flip();
return result;
}
return null;
}
use of org.apache.qpid.server.protocol.v1_0.framing.AMQFrame in project qpid-broker-j by apache.
the class AMQPConnection_1_0Impl method send.
public void send(short channel, FrameBody body) {
AMQFrame frame = AMQFrame.createAMQFrame(channel, body);
send(frame);
}
Aggregations