IRC Log


Sunday January 23, 2011

[Time] NameMessage
[02:27] kan hi guys, so I've been looking at 0mq for a couple of days and I want to know if it's advisable to publish different types of messages (eg, ping message, some business object message) on the same socket, or would one create a different socket for every type of message? I'm using the Java binding btw.
[02:37] kan hang on, i guess you have one socket and bind multiple URIs to the socket, then clients can subscribe to the URI they want to listen to?
[10:04] kanch hey guys if I want to have multiple publishers and have clients only listen to some of the publishers mesages, do I have a socket per publisher?
[10:20] mikko kanch: you would normally use topics maybe
[10:21] mikko so each subscriber would subscribe to the messages they are interested in
[10:21] kanch mikko, so your saying i should use multiple topics with one socket?
[10:21] kanch ie bind multiple urls to a socket?
[10:23] mikko kanch: not sure i follow, bind what urls?
[10:24] mikko kanch: on the publisher side you would publish messages in for example "test.A", "test.B", "test.C" topics and each subscriber would subscribe to one or more topics
[10:25] kanch mikko, yes I understand the publish/subscribe model, but I'm not sure how to apply it to zeromq. How do I create the topics? I thought they were URLs you bind to the sockets?
[10:26] mikko kanch: you don't really need to create topics. topic is just prefix matching
[10:26] mikko so you publish a message "test.A|hello there" and on subscriber side you subscribe to "test.A|"
[10:27] mikko kanch: have you read the zguide?
[10:28] kanch mikko, not in depth obviously :)
[10:29] kanch mikko, let me read the docs then. I couldn't find this information before
[10:32] mikko http://zguide.zeromq.org/chapter:all#toc7
[10:32] mikko examples/C/wuclient
[10:38] kanch thanks
[10:54] kanch mikko, so in the case of sending Java objects over the wire, i could use reflection on the client side to determine what type of message i am receiving?
[10:55] mikko kanch: i don't really code java so wouldn't know
[10:55] kanch mikko, no worries, thanks for help though. It's starting to make sense now
[10:59] kanch mikko, there is one thing that bothers me though. If the subscriber is filtering the messages, then they would be receiving messages that they don't need. Isn't that a waste?
[10:59] mikko kanch: yes, subscription forwarding is currently being worked on
[10:59] mikko in that scenario the publisher does the filtering
[11:01] kanch mikko, ok, and is there any draw backs to having multiple publisher sockets, that have different urls bound to them. Then subscribers could just connect to these URLs?
[11:03] mikko i guess not apart from more configuration
[11:03] mikko and slightly more resource usage
[11:06] kanch ok, so on that note then it's better to use filtering because of less resource usage
[11:06] mikko well, not quite true either
[11:07] mikko it depends on what is likely to be the bottleneck
[11:07] mikko with the current filtering system (before subscription forwarding is in place) there is more network usage as the messages are sent to all subscribers
[11:08] mikko but with multiple sockets you will have to create more physical connections on publisher and subscriber
[11:08] mikko there is really no harm in having multiple different sockets if you find it easy to manage
[11:09] kanch mikko, is it not possible to have the subscriber socket connect to multiple publisher sockets?
[11:10] mikko it is
[11:10] kanch mikko, ok thanks for all the information. You've been a real help
[16:28] codebeaker hi all, what's the right way to deal with errors from zmq_init and zmq_term, is it zmq_strerror(errono) or zmq_strerror(zmq_errno) ?
[16:32] codebeaker I ask because out of an (apparently failing) zmq_term(*context) "no such file or directroy"
[16:47] dbudworth What's the preferred mechanism to implement a bidirectional streaming connection? ie: client1 -> server1 where each can send a message asynchronously (similar to a regular socket between two points).
[16:50] dbudworth also, is there any means of using ephemeral ports? Say I have ~50 services + a lookup server. The alternative of assigning fixed service ports becomes a pain (especially with multiple instances on one box)
[16:52] codebeaker dbudworth: aren't there kernel methods to get a random unused port ?
[16:53] codebeaker (I read sth. about it in TLPI, but I didn't read closely enough to tell you what function)
[16:55] dbudworth codebeaker: yep, but it's always a race condition. I could create a regular socket, close it then hope I can use it before someone else does.
[17:03] codebeaker ach so, good point :) my bad
[17:50] cremes codebeaker: use zmq_strerror(zmq_errno()); the call to zmq_errno() is a wrapper of errno for unix systems so that a consistent api
[17:50] cremes can be used for windows too
[17:50] cremes dbudworth: no, 0mq doesn't support ephemeral ports; you could build such a service using 0mq but it isn't support out of the box
[17:50] codebeaker ah, thanks - cremes I'm on a Mac, actually - but if all goes well, this code will go to Windows, I hope one day
[17:51] cremes yeah... mac == unix
[17:51] codebeaker (right!)
[17:51] codebeaker cremes: does it make sense for zmq_strerror(zmq_errno()) to return "no such file or directory" ?