|
|||||||||
| PREV CLASS NEXT CLASS | FRAMES NO FRAMES | ||||||||
| SUMMARY: NESTED | FIELD | CONSTR | METHOD | DETAIL: FIELD | CONSTR | METHOD | ||||||||
java.lang.Objectorg.zeromq.ZMsg
public class ZMsg
The ZMsg class provides methods to send and receive multipart messages across 0MQ sockets. This class provides a list-like container interface, with methods to work with the overall container. ZMsg messages are composed of zero or more ZFrame objects.
// 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 Summary | |
|---|---|
ZMsg()
Class Constructor |
|
| Method Summary | ||
|---|---|---|
boolean |
add(byte[] data)
|
|
boolean |
add(String stringValue)
|
|
boolean |
add(ZFrame e)
|
|
boolean |
addAll(Collection<? extends ZFrame> arg0)
|
|
void |
addFirst(byte[] data)
|
|
void |
addFirst(String stringValue)
|
|
void |
addFirst(ZFrame e)
|
|
void |
addLast(byte[] data)
|
|
void |
addLast(String stringValue)
|
|
void |
addLast(ZFrame e)
|
|
void |
addString(String str)
Add a String as a new ZFrame to the end of list |
|
void |
clear()
|
|
boolean |
contains(Object o)
|
|
boolean |
containsAll(Collection<?> arg0)
|
|
long |
contentSize()
Return total number of bytes contained in all ZFrames in this ZMsg |
|
Iterator<ZFrame> |
descendingIterator()
|
|
void |
destroy()
Destructor. |
|
void |
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. |
|
void |
push(byte[] data)
|
|
void |
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,
int flag)
Receives message from socket, returns ZMsg object or null if the recv was interrupted. |
|
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. |
|
void |
send(ZMQ.Socket socket)
Send message to 0MQ socket. |
|
void |
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()
|
|
|
toArray(T[] arg0)
|
|
ZFrame |
unwrap()
Pop frame off front of message, caller now owns frame. |
|
void |
wrap(ZFrame frame)
Push frame plus empty frame to front of message, before 1st frame. |
|
| Methods inherited from class java.lang.Object |
|---|
clone, finalize, getClass, notify, notifyAll, toString, wait, wait, wait |
| Constructor Detail |
|---|
public ZMsg()
| Method Detail |
|---|
public void destroy()
public long contentSize()
public void addString(String str)
str - String to add to listpublic ZMsg duplicate()
public void wrap(ZFrame frame)
frame - public ZFrame unwrap()
public void send(ZMQ.Socket socket)
socket - 0MQ socket to send ZMsg on.
public void 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,
int flag)
socket - flag - see ZMQ constants
public static boolean save(ZMsg msg,
DataOutputStream file)
msg - ZMsg to savefile - DataOutputStream
public static ZMsg load(DataInputStream file)
file - DataInputStream connected to file
public 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 void dump(Appendable out)
public void addFirst(String stringValue)
public void addFirst(byte[] data)
public void addLast(String stringValue)
public void addLast(byte[] data)
public void push(String str)
public void push(byte[] data)
public boolean add(String stringValue)
public boolean add(byte[] data)
public Iterator<ZFrame> iterator()
iterator in interface Iterable<ZFrame>iterator in interface Collection<ZFrame>iterator in interface Deque<ZFrame>public 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)
add in interface Collection<ZFrame>add in interface Deque<ZFrame>add in interface Queue<ZFrame>public void addFirst(ZFrame e)
addFirst in interface Deque<ZFrame>public void addLast(ZFrame e)
addLast in interface Deque<ZFrame>public boolean contains(Object o)
contains in interface Collection<ZFrame>contains in interface Deque<ZFrame>public Iterator<ZFrame> descendingIterator()
descendingIterator in interface Deque<ZFrame>public ZFrame element()
element in interface Deque<ZFrame>element in interface Queue<ZFrame>public ZFrame getFirst()
getFirst in interface Deque<ZFrame>public ZFrame getLast()
getLast in interface Deque<ZFrame>public boolean offer(ZFrame e)
offer in interface Deque<ZFrame>offer in interface Queue<ZFrame>public boolean offerFirst(ZFrame e)
offerFirst in interface Deque<ZFrame>public boolean offerLast(ZFrame e)
offerLast in interface Deque<ZFrame>public ZFrame peek()
peek in interface Deque<ZFrame>peek in interface Queue<ZFrame>public ZFrame peekFirst()
peekFirst in interface Deque<ZFrame>public ZFrame peekLast()
peekLast in interface Deque<ZFrame>public ZFrame poll()
poll in interface Deque<ZFrame>poll in interface Queue<ZFrame>public ZFrame pollFirst()
pollFirst in interface Deque<ZFrame>public ZFrame pollLast()
pollLast in interface Deque<ZFrame>public ZFrame pop()
pop in interface Deque<ZFrame>public String popString()
public void push(ZFrame e)
push in interface Deque<ZFrame>public ZFrame remove()
remove in interface Deque<ZFrame>remove in interface Queue<ZFrame>public boolean remove(Object o)
remove in interface Collection<ZFrame>remove in interface Deque<ZFrame>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()
size in interface Collection<ZFrame>size in interface Deque<ZFrame>
|
|||||||||
| PREV CLASS NEXT CLASS | FRAMES NO FRAMES | ||||||||
| SUMMARY: NESTED | FIELD | CONSTR | METHOD | DETAIL: FIELD | CONSTR | METHOD | ||||||||