[zeromq-dev] Functionality of connect/disconnect bind/unbind

Trevor Bernard trevor.bernard at gmail.com
Wed May 22 17:05:30 CEST 2013

What should the functionality be for the following scenario?

;; Conceptually, assume push and pull sockets are different processes
(def ctx (zcontext 1))
(def ctx2 (zcontext 2))

(def push (-> (socket ctx :push)
              (connect "tcp://localhost:12345")))
(send push (.getBytes "msg1")) ;; true
(send push (.getBytes "msg2")) ;; true

(def pull (-> (socket ctx2 :pull)
              (bind "tcp://*:12345")))

;; receive queued messages as expected
(String. (recv pull)) "msg1"
(String. (recv pull)) "msg2"
(close pull) ;; simulate loss of connection

(send push (.getBytes "msg3"))
(send push (.getBytes "msg4"))
(send push (.getBytes "msg5"))

(def pull2 (-> (socket ctx2 :pull)
               (bind "tcp://*:12345")))

;; Again, received queued messages
(String. (recv pull2)) ;; "msg3"
(String. (recv pull2)) ;; "msg4"
(String. (recv pull2)) ;; "msg5"
(close pull2)

(send push (.getBytes "msg6")) ;; true
(send push (.getBytes "msg7")) ;; true
(send push (.getBytes "msg8")) ;; true

 ;; Simulate failover to a new endpoint
(disconnect push "tcp://localhost:12345")
(connect push "tcp://localhost:1337")

(send push (.getBytes "msg9")) ;; true
(def pull3 (-> (socket ctx2 :pull)
               (bind "tcp://*:1337")))

;; Expected to receive msg6-9
(String. (recv pull3)) ;; "msg9"

I expected the messages to be queued up and to receive msg6..9 but only
received msg9. Are messages 6-8 lost?

-------------- next part --------------
An HTML attachment was scrubbed...
URL: <https://lists.zeromq.org/pipermail/zeromq-dev/attachments/20130522/55389f65/attachment.htm>

More information about the zeromq-dev mailing list