com.github.andyshao.io.BlockingMessageFactory Maven / Gradle / Ivy
Go to download
Show more of this group Show more artifacts with this name
Show all versions of Gear Show documentation
Show all versions of Gear Show documentation
Enhance and formating the coding of JDK
The newest version!
package com.github.andyshao.io;
import java.nio.ByteBuffer;
/**
*
* Title:
* Descript:
* Copyright: Copryright(c) Nov 9, 2015
* Encoding:UNIX UTF-8
*
* @author Andy.Shao
*
*/
public interface BlockingMessageFactory extends MessageFactory {
@Override
public default MessageWritable buildMessageWritable(MessageContext context) {
return (channel , ctxt) -> {
byte[] writeBytes = (byte[]) ctxt.get(MessageContext.OUTPUT_MESSAGE_BYTES);
if (writeBytes.length == 0) return;
ByteBuffer writeBuffer = ByteBuffer.wrap(writeBytes);
while (writeBuffer.hasRemaining())
channel.write(writeBuffer);
};
}
}
© 2015 - 2025 Weber Informatics LLC | Privacy Policy