It is much cleaner and faster to just send a multipart message using zeromq. The multipart is still considered a single ZMQ message and will be delivered atomically. The guide has some more examples.

Joshua


It would look something like this:

import org.zeromq.ZMQ;

String xml = "<somexml/>"
byte[] attachment = new byte[]{1, 2, 3, 4};

ZMQ.Context context = ZMQ.context(1);
ZMQ.Socket push = context.socket(ZMQ.PUSH);
push.connect("tcp://127.0.0.1:1234");

ZMQ.Socket pull = context.socket(ZMQ.PULL);
pull.bind("tcp://*:1234");


push.send(xml.getBytes(), ZMQ.SND_MORE);
push.send(attachment, 0);

String rxml = new String(pull.recv(0));
byte[] rattachment = pull.recv(0);

January 10, 2013 6:06 AM
so if i understand it right , 
( in Java ) i need instead of sending XML marshaled as my main massaging structure ( using Jaxb) 
i will created new java class that has 2 members 1 for the xml and the second as the file as base64 encoded. 
then i will just send this class on the wire ? 
and in the client i will just decode the class and handle the 2 members of the class ?



_______________________________________________
zeromq-dev mailing list
[email protected]
http://lists.zeromq.org/mailman/listinfo/zeromq-dev
January 10, 2013 5:46 AM
seems like you could just [compress and/or] base64 encode the entire thing before it hits the zmq stack and de-combobulate it on the other end, then the multi-messaging should be easier(?). that way you're just handing a string to the zmq stack and leaving the heavy lifting to your application.


--
Wes
wesyoung.me

_______________________________________________
zeromq-dev mailing list
[email protected]
http://lists.zeromq.org/mailman/listinfo/zeromq-dev
January 10, 2013 3:23 AM
Hi,

Maybe the easiest is to keep the xml format for messages,
and to encode the binary file into base64 for example.

Or you can maybe use multi-part messages of zmq, first part
being xml and second (optional ?) part a binary chunk
corresponding to your file.

Cheers,
Matias.

_______________________________________________
zeromq-dev mailing list
[email protected]
http://lists.zeromq.org/mailman/listinfo/zeromq-dev
January 10, 2013 3:16 AM
Hello all
im new to zeromq, i setup basic multithreaded server and simple client that are working great , 
but the communication between  them is xml ( using Jaxb marshaling ) . 
now i want to keep the xml massaging and to add sending binary file on the wire from the server to client . 
what is the best approach to do it ?
Thanks 

_______________________________________________
zeromq-dev mailing list
[email protected]
http://lists.zeromq.org/mailman/listinfo/zeromq-dev
_______________________________________________
zeromq-dev mailing list
[email protected]
http://lists.zeromq.org/mailman/listinfo/zeromq-dev

Reply via email to