@Override
public void run()
{
final FrameWriter frameWriter = _frameWriter;
final ByteBuffer buffer = ByteBuffer.wrap(_buffer);
try
{
while(_connection.isOpen() && !_frameSource.closed())
{
AMQFrame frame = _frameSource.getNextFrame(true);
if(frame instanceof HeaderFrame)
{
_connection.sendMessage(frame.getPayload().array(),
frame.getPayload().arrayOffset(),
frame.getPayload().remaining());
}
else if(frame != null)
{
frameWriter.setValue(frame);
buffer.clear();
int length = frameWriter.writeToBuffer(buffer);
_connection.sendMessage(_buffer,0,length);
}
}
if(_frameSource.closed() && _connection.isOpen())
{