本文整理汇总了Java中org.zeromq.ZFrame.getData方法的典型用法代码示例。如果您正苦于以下问题:Java ZFrame.getData方法的具体用法?Java ZFrame.getData怎么用?Java ZFrame.getData使用的例子?那么, 这里精选的方法代码示例或许可以为您提供帮助。您也可以进一步了解该方法所在类org.zeromq.ZFrame
的用法示例。
在下文中一共展示了ZFrame.getData方法的4个代码示例,这些例子默认根据受欢迎程度排序。您可以为喜欢或者感觉有用的代码点赞,您的评价将有助于系统推荐出更棒的Java代码示例。
示例1: gunzipMultifameZMsg
import org.zeromq.ZFrame; //导入方法依赖的package包/类
public static String[] gunzipMultifameZMsg(ZMsg msg) throws IOException {
Iterator<ZFrame> frames = msg.iterator();
// pop off first frame, which contains "/GOVI/KV8" (the feed name)
// (isn't there a method for this?)
String header = frames.next().toString();
ByteArrayOutputStream buffer = new ByteArrayOutputStream();
while (frames.hasNext()) {
ZFrame frame = frames.next();
byte[] frameData = frame.getData();
buffer.write(frameData);
}
if (buffer.size() == 0) {
return null;
}
// chain input streams to gunzip contents of byte buffer
InputStream gzippedMessageStream = new ByteArrayInputStream(
buffer.toByteArray());
InputStream messageStream = new GZIPInputStream(gzippedMessageStream);
// copy input stream back to transport stream
buffer.reset();
byte[] b = new byte[4096];
for (int n; (n = messageStream.read(b)) != -1;) {
buffer.write(b, 0, n);
}
return new String[] { header, buffer.toString() };
}
示例2: verifyDelim
import org.zeromq.ZFrame; //导入方法依赖的package包/类
private String verifyDelim(ZFrame zframe) {
String delim = new String(zframe.getData(), StandardCharsets.UTF_8);
if (!DELIM.equals(delim)) {
throw new RuntimeException("Delimiter <IDS|MSG> not found");
}
return delim;
}
示例3: TransferWrapperRaw
import org.zeromq.ZFrame; //导入方法依赖的package包/类
/**
* Expect multipart message at least three parts:
*
* 0 envelope frame -> envelope[N-4]
* ...
* N-4 envelope frame -> envelope[0]
* N-3 Empty Delimiter Frame
* N-2 Serialized callback ID -> callbackId
* N-1 Serialized payload -> payload
*
* @param message input
* @throws TransferHelper.ProtocolException if protocol is violated
*/
public TransferWrapperRaw(ZMsg message) throws TransferHelper.ProtocolException {
if (message == null) { throw new IllegalArgumentException(); }
int N = message.size();
if (N <= 2) {
throw new TransferHelper.ProtocolException("Wrong number of Frames. Expected lower than 3: " + message.size());
}
ZFrame payloadFrame = message.pollLast();
ZFrame callbackFrame = message.pollLast();
ZFrame delimiterFrame = message.pollLast();
if (delimiterFrame.size() != 0) {
throw new TransferHelper.ProtocolException("Delimiter frame not empty.");
}
callbackId = TransferHelper.bytes2int(callbackFrame.getData());
payload = payloadFrame.getData();
envelope = new ZFrame[N-3];
for(int i = 0; i < N-3; i++) {
envelope[i] = message.pollLast();
}
if (message.size() != 0) throw new IllegalStateException("Message not empty.");
}
示例4: Worker
import org.zeromq.ZFrame; //导入方法依赖的package包/类
protected Worker(ZFrame address) {
this.address = address;
identity = new String(address.getData(), ZMQ.CHARSET);
expiry = System.currentTimeMillis() + HEARTBEAT_INTERVAL * HEARTBEAT_LIVENESS;
}