- 使用 Spring Initializr 创建 Spring Boot 应用程序
- 在Spring Boot中配置Cassandra
- 在 Spring Boot 上配置 Tomcat 连接池
- 将Camel消息路由到嵌入WildFly的Artemis上
本文整理了Java中org.zeromq.ZMsg.recvMsg()
方法的一些代码示例,展示了ZMsg.recvMsg()
的具体用法。这些代码示例主要来源于Github
/Stackoverflow
/Maven
等平台,是从一些精选项目中提取出来的代码,具有较强的参考意义,能在一定程度帮忙到你。ZMsg.recvMsg()
方法的具体详情如下:
包路径:org.zeromq.ZMsg
类名称:ZMsg
方法名:recvMsg
[英]Receives message from socket, returns ZMsg object or null if the recv was interrupted. Does a blocking recv, if you want not to block then use the ZLoop class or ZMQ.Poller to check for socket input before receiving or recvMsg with flag ZMQ.DONTWAIT.
[中]从套接字接收消息,如果recv被中断,则返回ZMsg对象或null。执行阻塞recv,如果不想阻塞,则使用ZLoop类或ZMQ。轮询器在接收或接收带有标志ZMQ的VMSG之前检查套接字输入。别这样。
代码示例来源:origin: twosigma/beakerx
private Message readMessage(ZMQ.Socket socket) {
ZMsg zmsg = null;
Message message = null;
try {
zmsg = ZMsg.recvMsg(socket);
ZFrame[] parts = new ZFrame[zmsg.size()];
zmsg.toArray(parts);
byte[] uuid = parts[MessageParts.UUID].getData();
byte[] header = parts[MessageParts.HEADER].getData();
byte[] parent = parts[MessageParts.PARENT].getData();
byte[] metadata = parts[MessageParts.METADATA].getData();
byte[] content = parts[MessageParts.CONTENT].getData();
byte[] expectedSig = parts[MessageParts.HMAC].getData();
verifyDelim(parts[MessageParts.DELIM]);
verifySignatures(expectedSig, header, parent, metadata, content);
message = new Message(parse(header, Header.class));
if (uuid != null) {
message.getIdentities().add(uuid);
}
message.setParentHeader(parse(parent, Header.class));
message.setMetadata(parse(metadata, LinkedHashMap.class));
message.setContent(parse(content, LinkedHashMap.class));
} finally {
if (zmsg != null) {
zmsg.destroy();
}
}
return message;
}
代码示例来源:origin: org.zeromq/jeromq
/**
* Receives message from socket, returns ZMsg object or null if the
* recv was interrupted.
* @param socket
* @param wait true to wait for next message, false to do a non-blocking recv.
* @return
* ZMsg object, null if interrupted
*/
public static ZMsg recvMsg(Socket socket, boolean wait)
{
return recvMsg(socket, wait ? 0 : ZMQ.DONTWAIT);
}
代码示例来源:origin: org.zeromq/jeromq
/**
* Receives message from socket, returns ZMsg object or null if the
* recv was interrupted. Does a blocking recv, if you want not to block then use
* the ZLoop class or ZMQ.Poller to check for socket input before receiving or recvMsg with flag ZMQ.DONTWAIT.
* @param socket
* @return
* ZMsg object, null if interrupted
*/
public static ZMsg recvMsg(Socket socket)
{
return recvMsg(socket, 0);
}
代码示例来源:origin: org.zeromq/jeromq
private boolean restart(Socket pipe, boolean hot)
{
state.restart = true;
if (hot) {
assert (provider != null);
state.hot = ZMsg.recvMsg(pipe);
// continue with the same agent
return true;
}
else {
// stop the loop and restart a new agent
// with the same started state
// the next loop will refill the updated status
return false;
}
}
代码示例来源:origin: org.zeromq/jeromq
private static ZapRequest recvRequest(Socket handler, boolean wait)
{
ZMsg request = ZMsg.recvMsg(handler, wait);
if (request == null) {
return null;
}
ZapRequest self = new ZapRequest(handler, request);
// If the version is wrong, we're linked with a bogus libzmq, so die
assert (ZAP_VERSION.equals(self.version));
request.destroy();
return self;
}
代码示例来源:origin: kawasima/enkan
@Override
public String recv(long timeout) {
ZMsg msg = ZMsg.recvMsg(socket);
clientAddress = msg.pop();
return msg.popString();
}
代码示例来源:origin: io.projectreactor/reactor-net
@Override
public int handle(ZLoop loop, ZMQ.PollItem item, Object arg) {
ZMsg msg = ZMsg.recvMsg(socket);
if (null == msg || msg.size() == 0) {
return 0;
}
if (closed) {
return -1;
}
b.onNext(msg);
return 0;
}
};
代码示例来源:origin: org.zeromq/jeromq
private boolean removeEvents(Socket pipe)
{
final ZMsg msg = ZMsg.recvMsg(pipe);
if (msg == null) {
return false; // interrupted
}
for (ZFrame frame : msg) {
final String evt = frame.getString(ZMQ.CHARSET);
final Event event = Event.valueOf(evt);
if (verbose) {
System.out.printf("ZMonitor: Removing" + " event %s%n", event);
}
events &= ~event.events;
}
return pipe.send(OK);
}
代码示例来源:origin: org.zeromq/jeromq
private boolean addEvents(Socket pipe)
{
final ZMsg msg = ZMsg.recvMsg(pipe);
if (msg == null) {
return false; // interrupted
}
for (ZFrame frame : msg) {
final String evt = frame.getString(ZMQ.CHARSET);
final Event event = Event.valueOf(evt);
if (verbose) {
System.out.printf("ZMonitor: Adding" + " event %s%n", event);
}
events |= event.events;
}
return pipe.send(OK);
}
代码示例来源:origin: kawasima/enkan
@Override
public int complete(String buffer, int cursor, List<CharSequence> candidates) {
@SuppressWarnings("MismatchedQueryAndUpdateOfCollection")
ZMsg msg = new ZMsg();
msg.add(buffer);
msg.add(Integer.toString(cursor));
msg.send(socket);
ZMsg response = ZMsg.recvMsg(socket);
while (response != null && !response.isEmpty()) {
candidates.add(response.popString());
}
if (candidates.isEmpty()) return cursor;
int delimiterPos = Math.max(buffer.lastIndexOf(' '), buffer.lastIndexOf('.'));
if (delimiterPos > 0) {
return delimiterPos + 1;
} else {
return 0;
}
}
}
代码示例来源:origin: net.unit8.enkan/enkan-repl-pseudo
@Override
public void run() {
while(!Thread.currentThread().isInterrupted()) {
ZMsg msg = ZMsg.recvMsg(socket);
ZFrame clientAddress = msg.pop();
String input = msg.popString();
int cursor = Integer.parseInt(msg.popString());
int[] anchor = {-1};
ZMsg reply = new ZMsg();
reply.add(clientAddress.duplicate());
String trimmedCommand = input.trim();
if (trimmedCommand.startsWith("/")) {
if (!trimmedCommand.contains(" ")) {
Predicate<String> filter = trimmedCommand.equals("/") ?
n -> true : n -> n.startsWith(trimmedCommand.substring(1));
commandNames.stream()
.filter(filter)
.forEach(s -> reply.add("/" + s));
anchor[0] = 0;
}
}
reply.send(socket, true);
}
}
代码示例来源:origin: kawasima/enkan
@Override
public void run() {
while(!Thread.currentThread().isInterrupted()) {
ZMsg msg = ZMsg.recvMsg(socket);
ZFrame clientAddress = msg.pop();
String input = msg.popString();
int cursor = Integer.parseInt(msg.popString());
int[] anchor = {-1};
ZMsg reply = new ZMsg();
reply.add(clientAddress.duplicate());
String trimmedCommand = input.trim();
if (trimmedCommand.startsWith("/")) {
if (!trimmedCommand.contains(" ")) {
Predicate<String> filter = trimmedCommand.equals("/") ?
n -> true : n -> n.startsWith(trimmedCommand.substring(1));
commandNames.stream()
.filter(filter)
.forEach(s -> reply.add("/" + s));
anchor[0] = 0;
}
}
reply.send(socket, true);
}
}
代码示例来源:origin: net.unit8.enkan/enkan-repl-jshell
@Override
public void run() {
while(!Thread.currentThread().isInterrupted()) {
ZMsg msg = ZMsg.recvMsg(socket);
ZFrame clientAddress = msg.pop();
String input = msg.popString();
代码示例来源:origin: org.zeromq/jeromq
@Override
public ZMsg recv(boolean wait)
{
if (locked) {
return null;
}
try {
ZMsg msg = ZMsg.recvMsg(pipe, wait);
if (msg == null) {
return null;
}
if (msg.size() == 1) {
final ZFrame frame = msg.peek();
byte[] key = frame.getData();
if (lock != null && Arrays.equals(lock, key)) {
locked = true;
// this is the last message anyway, and not a one for a public display
msg = null;
pipe.close();
}
}
return msg;
}
catch (ZMQException e) {
locked = true;
return null;
}
}
代码示例来源:origin: org.zeromq/jeromq
ZMsg cfg = ZMsg.recvMsg(pipe);
boolean rc = provider.configure(pipe, cfg, frontend, backend, capture, args);
cfg.destroy();
代码示例来源:origin: org.zeromq/jeromq
@Override
public boolean flow(Plug splug, Socket source, Socket capture, Plug dplug, Socket destination)
{
boolean success;
// we read the whole message
ZMsg msg = ZMsg.recvMsg(source);
if (msg == null) {
return false;
}
if (capture != null) {
// Copy transformed message to capture socket if any message
// TODO what if the transformer modifies or destroys the original message ?
ZMsg cpt = transformer.transform(msg, splug, Plug.CAPTURE);
// boolean destroy = !msg.equals(cpt); // TODO ?? which one
boolean destroy = msg != cpt;
success = cpt.send(capture, destroy);
if (!success) {
// not successful, but we can still try to send it to the destination
}
}
ZMsg dst = transformer.transform(msg, splug, dplug);
// we send the whole transformed message
success = dst.send(destination);
// finished
msg.destroy();
return success;
}
}
代码示例来源:origin: org.projectreactor/reactor-net
@Override
public int handle(ZLoop loop, ZMQ.PollItem item, Object arg) {
ZMsg msg = ZMsg.recvMsg(socket);
if (null == msg || msg.size() == 0) {
return 0;
}
if (closed) {
return -1;
}
String connId;
switch (ZeroMQWorker.this.socketType) {
case ZMQ.ROUTER:
connId = msg.popString();
break;
default:
connId = ZeroMQWorker.this.id.toString();
}
ZeroMQNetChannel<IN, OUT> netChannel = select(connId)
.setConnectionId(connId)
.setSocket(socket);
ZFrame content;
while (null != (content = msg.pop())) {
netChannel.read(Buffer.wrap(content.getData()));
}
msg.destroy();
return 0;
}
};
代码示例来源:origin: fiber-space/jupyter-kernel-jsr223
sockets.poll();
if (sockets.pollin(0)) {
msg = new MessageObject(ZMsg.recvMsg(Control), Control, key);
kernel.dispatch(msg);
msg = new MessageObject(ZMsg.recvMsg(Shell), Shell, key);
kernel.dispatch(msg);
msg = new MessageObject(ZMsg.recvMsg(Stdin), Stdin, key);
kernel.dispatch(msg);
代码示例来源:origin: org.opendaylight.netide/shim
poller.poll(10);
if (poller.pollin(0)) {
ZMsg message = ZMsg.recvMsg(socket);
byte[] data = message.getLast().getData();
if (coreListener != null) {
ZMsg message = ZMsg.recvMsg(controlSocket);
if (message.getFirst().toString().equals(STOP_COMMAND)) {
break;
代码示例来源:origin: kawasima/enkan
socket.monitor("inproc://socket.monitor", ZMQ.EVENT_DISCONNECTED);
ZMsg completerMsg = ZMsg.recvMsg(socket);
ReplResponse completerRes = fressian.read(completerMsg.pop().getData(), ReplResponse.class);
String completerPort = completerRes.getOut();
while (true) {
try {
ZMsg msg = ZMsg.recvMsg(this.socket);
ReplResponse res = fressian.read(msg.pop().getData(), ReplResponse.class);
if (res.getOut() != null) {
本文整理了Java中org.zeromq.ZMsg.recvMsg()方法的一些代码示例,展示了ZMsg.recvMsg()的具体用法。这些代码示例主要来源于Github/Stackoverflow/
本文整理了Java中org.zeromq.ZMsg.size()方法的一些代码示例,展示了ZMsg.size()的具体用法。这些代码示例主要来源于Github/Stackoverflow/Maven等
本文整理了Java中org.zeromq.ZMsg.add()方法的一些代码示例,展示了ZMsg.add()的具体用法。这些代码示例主要来源于Github/Stackoverflow/Maven等平台
本文整理了Java中org.zeromq.ZMsg.getFirst()方法的一些代码示例,展示了ZMsg.getFirst()的具体用法。这些代码示例主要来源于Github/Stackoverflo
本文整理了Java中org.zeromq.ZMsg.send()方法的一些代码示例,展示了ZMsg.send()的具体用法。这些代码示例主要来源于Github/Stackoverflow/Maven等
本文整理了Java中org.zeromq.ZMsg.destroy()方法的一些代码示例,展示了ZMsg.destroy()的具体用法。这些代码示例主要来源于Github/Stackoverflow/
本文整理了Java中org.zeromq.ZMsg.pop()方法的一些代码示例,展示了ZMsg.pop()的具体用法。这些代码示例主要来源于Github/Stackoverflow/Maven等平台
本文整理了Java中org.zeromq.ZMsg.isEmpty()方法的一些代码示例,展示了ZMsg.isEmpty()的具体用法。这些代码示例主要来源于Github/Stackoverflow/
本文整理了Java中org.zeromq.ZMsg.()方法的一些代码示例,展示了ZMsg.()的具体用法。这些代码示例主要来源于Github/Stackoverflow/Maven等平台,是从一些精
我是一名优秀的程序员,十分优秀!