本文整理汇总了Java中org.apache.activemq.artemis.api.core.ActiveMQBuffer.byteBuf方法的典型用法代码示例。如果您正苦于以下问题:Java ActiveMQBuffer.byteBuf方法的具体用法?Java ActiveMQBuffer.byteBuf怎么用?Java ActiveMQBuffer.byteBuf使用的例子?那么恭喜您, 这里精选的方法代码示例或许可以为您提供帮助。您也可以进一步了解该方法所在类org.apache.activemq.artemis.api.core.ActiveMQBuffer
的用法示例。
在下文中一共展示了ActiveMQBuffer.byteBuf方法的4个代码示例,这些例子默认根据受欢迎程度排序。您可以为喜欢或者感觉有用的代码点赞,您的评价将有助于系统推荐出更棒的Java代码示例。
示例1: write
import org.apache.activemq.artemis.api.core.ActiveMQBuffer; //导入方法依赖的package包/类
@Override
public void write(ActiveMQBuffer bytes, boolean sync, IOCallback callback) throws IOException {
if (callback == null) {
throw new NullPointerException("callback parameter need to be set");
}
checkIsOpen(callback);
try {
final ByteBuf byteBuf = bytes.byteBuf();
final int writerIndex = byteBuf.writerIndex();
final int readerIndex = byteBuf.readerIndex();
final int readableBytes = writerIndex - readerIndex;
if (readableBytes > 0) {
this.mappedFile.write(byteBuf, readerIndex, readableBytes);
if (factory.isDatasync() && sync) {
this.mappedFile.force();
}
}
callback.done();
} catch (IOException e) {
if (this.criticalErrorListener != null) {
this.criticalErrorListener.onIOException(new ActiveMQIOErrorException(e.getMessage(), e), e.getMessage(), this);
}
callback.onError(ActiveMQExceptionType.IO_ERROR.getCode(), e.getMessage());
throw e;
}
}
示例2: writeInEventLoop
import org.apache.activemq.artemis.api.core.ActiveMQBuffer; //导入方法依赖的package包/类
private void writeInEventLoop(ActiveMQBuffer buffer,
final boolean flush,
final boolean batched,
final ChannelFutureListener futureListener) {
//no need to lock because the Netty's channel is thread-safe
//and the order of write is ensured by the order of the write calls
final ChannelPromise promise;
if (futureListener != null) {
promise = channel.newPromise();
} else {
promise = channel.voidPromise();
}
final ChannelFuture future;
final ByteBuf bytes = buffer.byteBuf();
final int readableBytes = bytes.readableBytes();
final int writeBatchSize = this.batchLimit;
if (this.batchingEnabled && batched && !flush && readableBytes < writeBatchSize) {
future = writeBatch(bytes, readableBytes, promise);
} else {
future = channel.writeAndFlush(bytes, promise);
}
if (futureListener != null) {
future.addListener(futureListener);
}
}
示例3: encode
import org.apache.activemq.artemis.api.core.ActiveMQBuffer; //导入方法依赖的package包/类
public void encode(final ActiveMQBuffer buffer1) {
super.encodeHeadersAndProperties(buffer1.byteBuf());
}
示例4: decode
import org.apache.activemq.artemis.api.core.ActiveMQBuffer; //导入方法依赖的package包/类
public void decode(final ActiveMQBuffer buffer1) {
file = null;
super.decodeHeadersAndProperties(buffer1.byteBuf());
}