'Last message only' option in ZMQ Subscribe socket
<p>A ZMQ subscriber socket keeps only the last message in queue when the CONFLATE option is set to true. <a href="http://api.zeromq.org/4-0:zmq-setsockopt" rel="nofollow">(zmq_docs)</a> However, it does not seem to be working for me. Typically in python i would do something like the following and it would work:</p>

<pre><code>context = zmq.Context()
subscriber = context.socket(zmq.SUB)
subscriber.setsockopt(zmq.CONFLATE, 1)
subscriber.connect("tcp://localhost:5555")
</code></pre>

<p>The subscriber in pub/sub pattern below simply ignores the CONFLATE option set to 1. You can observe by the minute and second being displayed on the subscriber that the program is tied up as it is processing old messages (fib 42). If fib is set to a trivial value, you can see that the subscriber is indeed receiving messages from the publisher.</p>

<p>Here is the publisher:</p>

<pre><code>open System
open fszmq
open fszmq.Context
open fszmq.Socket


let funcPublish () =
  use context   = new Context()
  use publisher = pub context
  "tcp://*:5563" |&gt; bind publisher

  while true do
    let tm = System.DateTime.Now
    let t = String.Concat([tm.Minute.ToString(); " "; tm.Second.ToString()])
    t |&gt; s_send publisher
    sleep 1

  EXIT_SUCCESS


[&lt;EntryPoint&gt;]
let main argv = 
    funcPublish ()
    0
</code></pre>

<p>And here is the subscriber:</p>

<pre><code>open fszmq
open fszmq.Context
open fszmq.Socket

let rec fib n =
    match n with
    | 1 | 2 -&gt; 1
    | n -&gt; fib(n-1) + fib(n-2)

let funcSubscribe () = 
  use context    = new Context()
  use subscriber = sub context
  "tcp://localhost:5563" |&gt; connect subscriber
  Socket.setOption subscriber (ZMQ.CONFLATE, 1)
  [ ""B ] |&gt; subscribe subscriber


  while true do
    let contents = s_recv subscriber
    fib 42
    contents |&gt; printfn "%A"

  EXIT_SUCCESS


[&lt;EntryPoint&gt;]
let main argv = 
    funcSubscribe ()
    0
</code></pre>

<p>Thanks.</p>