本文整理了Java中org.apache.qpid.proton.engine.Transport.getInputBuffer()
方法的一些代码示例,展示了Transport.getInputBuffer()
的具体用法。这些代码示例主要来源于Github
/Stackoverflow
/Maven
等平台,是从一些精选项目中提取出来的代码,具有较强的参考意义,能在一定程度帮忙到你。Transport.getInputBuffer()
方法的具体详情如下:
包路径:org.apache.qpid.proton.engine.Transport
类名称:Transport
方法名:getInputBuffer
[英]Get a buffer that can be used to write input data into the transport. Once the client has finished putting into the input buffer, #processInput()must be called. Successive calls to this method are not guaranteed to return the same object. Once #processInput() is called the buffer must not be used.
[中]获取一个可用于将输入数据写入传输的缓冲区。客户机完成输入缓冲区的输入后,必须调用#processInput()。对该方法的连续调用不能保证返回相同的对象。一旦调用了#processInput(),就不能使用缓冲区。
代码示例来源:origin: apache/activemq-artemis
@Override
public void run() {
ByteBuffer source = incoming.nioBuffer();
LOG.trace("Client Received from Broker {} bytes:", source.remaining());
if (protonTransport.isClosed()) {
LOG.debug("Ignoring incoming data because transport is closed");
return;
}
do {
ByteBuffer buffer = protonTransport.getInputBuffer();
int limit = Math.min(buffer.remaining(), source.remaining());
ByteBuffer duplicate = source.duplicate();
duplicate.limit(source.position() + limit);
buffer.put(duplicate);
protonTransport.processInput();
source.position(source.position() + limit);
}
while (source.hasRemaining());
ReferenceCountUtil.release(incoming);
// Process the state changes from the latest data and then answer back
// any pending updates to the Broker.
processUpdates();
pumpToProtonTransport();
}
});
代码示例来源:origin: EnMasseProject/enmasse
private void readFromNetwork(Connection connection, InputStream in, BooleanSupplier test) throws IOException, LoginException {
Transport transport = connection.getTransport();
while(test.getAsBoolean()) {
ByteBuffer buf = transport.getInputBuffer();
byte[] tmpBuf = new byte[buf.remaining()];
int bytesRead = in.read(tmpBuf);
LOG.tracev("read {0} bytes", bytesRead);
if (bytesRead == -1) {
throw new LoginException("Unexpected EOS experienced when authenticating using SASL delegation");
} else {
buf.put(tmpBuf, 0, bytesRead);
TransportResult result = transport.processInput();
if(!result.isOk()) {
LoginException e = new LoginException("Unexpected error when authenticating using SASL delegation");
e.initCause(result.getException());
throw e;
}
}
}
}
内容来源于网络,如有侵权,请联系作者删除!