public class ZMsg extends Object implements Iterable<ZFrame>, Deque<ZFrame>
// Send a simple single-frame string message on a ZMQSocket "output" socket object
ZMsg.newStringMsg("Hello").send(output);
// Add several frames into one message
ZMsg msg = new ZMsg();
for (int i = 0 ; i < 10 ; i++) {
msg.addString("Frame" + i);
}
msg.send(output);
// Receive message from ZMQSocket "input" socket object and iterate over frames
ZMsg receivedMessage = ZMsg.recvMsg(input);
for (ZFrame f : receivedMessage) {
// Do something with frame f (of type ZFrame)
}
Based on zmsg.c in czmq| Constructor and Description |
|---|
ZMsg()
Class Constructor
|
| Modifier and Type | Method and Description |
|---|---|
boolean |
add(byte[] data) |
boolean |
add(String stringValue) |
boolean |
add(ZFrame e) |
boolean |
addAll(Collection<? extends ZFrame> arg0) |
ZMsg |
addFirst(byte[] data) |
ZMsg |
addFirst(String stringValue) |
void |
addFirst(ZFrame e) |
ZMsg |
addLast(byte[] data) |
ZMsg |
addLast(String stringValue) |
void |
addLast(ZFrame e) |
ZMsg |
addString(String str)
Add a String as a new ZFrame to the end of list
|
ZMsg |
append(byte[] data)
Adds bytes as a new frame in the message.
|
ZMsg |
append(String stringValue)
Adds a string as a new frame in the message.
|
ZMsg |
append(ZMsg msg) |
void |
clear() |
boolean |
contains(Object o) |
boolean |
containsAll(Collection<?> arg0) |
long |
contentSize() |
Iterator<ZFrame> |
descendingIterator() |
void |
destroy()
Destructor.
|
ZMsg |
dump() |
ZMsg |
dump(Appendable out)
Dump the message in human readable format.
|
ZMsg |
duplicate()
Creates copy of this ZMsg.
|
ZFrame |
element() |
boolean |
equals(Object o) |
ZFrame |
getFirst() |
ZFrame |
getLast() |
int |
hashCode() |
boolean |
isEmpty() |
Iterator<ZFrame> |
iterator() |
static ZMsg |
load(DataInputStream file)
Load / append a ZMsg from an open DataInputStream
|
static ZMsg |
newStringMsg(String... strings)
Create a new ZMsg from one or more Strings
|
boolean |
offer(ZFrame e) |
boolean |
offerFirst(ZFrame e) |
boolean |
offerLast(ZFrame e) |
ZFrame |
peek() |
ZFrame |
peekFirst() |
ZFrame |
peekLast() |
ZFrame |
poll() |
ZFrame |
pollFirst() |
ZFrame |
pollLast() |
ZFrame |
pop() |
String |
popString()
Pop a ZFrame and return the toString() representation of it.
|
ZMsg |
push(byte[] data) |
ZMsg |
push(String str) |
void |
push(ZFrame e) |
static ZMsg |
recvMsg(ZMQ.Socket socket)
Receives message from socket, returns ZMsg object or null if the
recv was interrupted.
|
static ZMsg |
recvMsg(ZMQ.Socket socket,
boolean wait)
Receives message from socket, returns ZMsg object or null if the
recv was interrupted.
|
static ZMsg |
recvMsg(ZMQ.Socket socket,
int flag)
Receives message from socket, returns ZMsg object or null if the
recv was interrupted.
|
static void |
recvMsg(ZMQ.Socket socket,
int flags,
Consumer<ZMsg> handler)
This API is in DRAFT state and is subject to change at ANY time until declared stable
handle incoming message with a handler
|
static void |
recvMsg(ZMQ.Socket socket,
int flags,
Consumer<ZMsg> handler,
Consumer<ZMQException> exceptionHandler)
This API is in DRAFT state and is subject to change at ANY time until declared stable
handle incoming message with a handler
|
ZFrame |
remove() |
boolean |
remove(Object o) |
boolean |
removeAll(Collection<?> arg0) |
ZFrame |
removeFirst() |
boolean |
removeFirstOccurrence(Object o) |
ZFrame |
removeLast() |
boolean |
removeLastOccurrence(Object o) |
boolean |
retainAll(Collection<?> arg0) |
static boolean |
save(ZMsg msg,
DataOutputStream file)
Save message to an open data output stream.
|
boolean |
send(ZMQ.Socket socket)
Send message to 0MQ socket.
|
boolean |
send(ZMQ.Socket socket,
boolean destroy)
Send message to 0MQ socket, destroys contents after sending if destroy param is set to true.
|
int |
size() |
Object[] |
toArray() |
<T> T[] |
toArray(T[] arg0) |
String |
toString()
Returns pretty string representation of multipart message:
[ frame0, frame1, ..., frameN ]
|
ZFrame |
unwrap()
Pop frame off front of message, caller now owns frame.
|
ZMsg |
wrap(ZFrame frame)
Push frame plus empty frame to front of message, before 1st frame.
|
clone, finalize, getClass, notify, notifyAll, wait, wait, waitparallelStream, removeIf, streampublic void destroy()
public long contentSize()
public ZMsg addString(String str)
str - String to add to listpublic ZMsg duplicate()
public ZMsg wrap(ZFrame frame)
frame - public ZFrame unwrap()
public boolean send(ZMQ.Socket socket)
socket - 0MQ socket to send ZMsg on.public boolean send(ZMQ.Socket socket, boolean destroy)
socket - 0MQ socket to send ZMsg on.public static ZMsg recvMsg(ZMQ.Socket socket)
socket - public static ZMsg recvMsg(ZMQ.Socket socket, boolean wait)
socket - wait - true to wait for next message, false to do a non-blocking recv.public static ZMsg recvMsg(ZMQ.Socket socket, int flag)
socket - flag - see ZMQ constantspublic static void recvMsg(ZMQ.Socket socket, int flags, Consumer<ZMsg> handler, Consumer<ZMQException> exceptionHandler)
socket - flags - see ZMQ constantshandler - handler to handle incoming messageexceptionHandler - handler to handle exceptionspublic static void recvMsg(ZMQ.Socket socket, int flags, Consumer<ZMsg> handler)
socket - flags - see ZMQ constantshandler - handler to handle incoming messagepublic static boolean save(ZMsg msg, DataOutputStream file)
msg - ZMsg to savefile - DataOutputStreampublic static ZMsg load(DataInputStream file)
file - DataInputStream connected to filepublic static ZMsg newStringMsg(String... strings)
strings - Strings to add as frames.public boolean equals(Object o)
equals in interface Collection<ZFrame>equals in class Objectpublic int hashCode()
hashCode in interface Collection<ZFrame>hashCode in class Objectpublic ZMsg dump(Appendable out)
public ZMsg dump()
public ZMsg addFirst(byte[] data)
public ZMsg addLast(byte[] data)
public ZMsg push(byte[] data)
public boolean add(String stringValue)
public boolean add(byte[] data)
public ZMsg append(String stringValue)
stringValue - the value to addpublic ZMsg append(byte[] data)
data - the value to addpublic boolean addAll(Collection<? extends ZFrame> arg0)
addAll in interface Collection<ZFrame>public void clear()
clear in interface Collection<ZFrame>public boolean containsAll(Collection<?> arg0)
containsAll in interface Collection<ZFrame>public boolean isEmpty()
isEmpty in interface Collection<ZFrame>public boolean removeAll(Collection<?> arg0)
removeAll in interface Collection<ZFrame>public boolean retainAll(Collection<?> arg0)
retainAll in interface Collection<ZFrame>public Object[] toArray()
toArray in interface Collection<ZFrame>public <T> T[] toArray(T[] arg0)
toArray in interface Collection<ZFrame>public boolean add(ZFrame e)
public boolean contains(Object o)
public Iterator<ZFrame> descendingIterator()
descendingIterator in interface Deque<ZFrame>public ZFrame element()
public boolean offer(ZFrame e)
public boolean offerFirst(ZFrame e)
offerFirst in interface Deque<ZFrame>public ZFrame peek()
public ZFrame poll()
public String popString()
public ZFrame remove()
public boolean remove(Object o)
public ZFrame removeFirst()
removeFirst in interface Deque<ZFrame>public boolean removeFirstOccurrence(Object o)
removeFirstOccurrence in interface Deque<ZFrame>public ZFrame removeLast()
removeLast in interface Deque<ZFrame>public boolean removeLastOccurrence(Object o)
removeLastOccurrence in interface Deque<ZFrame>public int size()
Copyright © 2020. All rights reserved.