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

Apostolis Xekoukoulotakis xekoukou at gmail.com
Thu May 23 00:28:04 CEST 2013


You are probably disconnecting push before it is able to send the msgs.


2013/5/23 Trevor Bernard <trevor.bernard at gmail.com>

> I'm using libzmq 3.2.3
>
>
>
> On Wed, May 22, 2013 at 12:05 PM, Trevor Bernard <trevor.bernard at gmail.com
> > wrote:
>
>> 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?
>>
>> -Trev
>>
>
>
> _______________________________________________
> zeromq-dev mailing list
> zeromq-dev at lists.zeromq.org
> http://lists.zeromq.org/mailman/listinfo/zeromq-dev
>
>


-- 


Sincerely yours,

     Apostolis Xekoukoulotakis
-------------- next part --------------
An HTML attachment was scrubbed...
URL: <https://lists.zeromq.org/pipermail/zeromq-dev/attachments/20130523/f403e4e6/attachment.htm>


More information about the zeromq-dev mailing list