netmq | A 100 % native C # implementation of ZeroMQ for .NET | Messaging library
kandi X-RAY | netmq Summary
kandi X-RAY | netmq Summary
NetMQ is a 100% native C# port of the lightweight messaging library ZeroMQ. NetMQ extends the standard socket interfaces with features traditionally provided by specialised messaging middleware products. NetMQ sockets provide an abstraction of asynchronous message queues, multiple messaging patterns, message filtering (subscriptions), seamless access to multiple transport protocols, and more.
Support
Quality
Security
License
Reuse
Top functions reviewed by kandi - BETA
Currently covering the most popular Java, JavaScript and Python libraries. See a Sample of netmq
netmq Key Features
netmq Examples and Code Snippets
Community Discussions
Trending Discussions on netmq
QUESTION
I am using ZMQ NetMQ package in c# to receive the message from the subscriber. I am able to receive the msg but I am sticking in the while loop. I want to break the while loop if the publisher is stopped sending data.
Here is my subscriber code:
...ANSWER
Answered 2022-Feb-22 at 21:27Q : "How to check ZMQ publisher is alive or not in c# ?"
A :
There are at least two ways to do so :
a )
modify the code on both thePUB
-side andSUB
-side, so that the Publisher sends both thePUB/SUB
-channel messages, and independently of that alsoPUSH/PULL
-keep-alive messages to prove to theSUB
-side it is still alive, as being autonomously received as confirmations from thePULL
-AccessPoint on theSUB
-side loop. Not receiving such soft-keep-alive message for some time may trigger theSUB
-side loop to become sure tobreak
. The same principle may get served by a reversedPUSH/PULL
-channel, whereSUB
-side, from time to time, asks thePUB
-side, listening on thePULL
-side, using asynchronously sent soft-request message to inject a soft-keep-alive message into thePUB
-channel ( remember the TOPIC-filter is a plain ASCII-filtering from the left to the right of the message-payload, soPUSH
-delivered message could as easily send the exact text to be looped-back viaPUB/SUB
back to the sender, matching the locally known TOPIC-filter maintained by the very sameSUB
-side entity )b )
in cases, where you cannot modify thePUB
-side code, we still can setup a time-based counter, after expiring which, without receiving a single message ( be it using a loop of a known multiple of precisely timed-aSUB.poll( ... )
-s, which allows for a few, priority-ordered interleaved control-loops to be operated without uncontrolled mutual blocking, or by using a straight, non-blocking form ofaSUB.recv( zmq.NOBLOCK )
aligned within the loop with some busy-loop avoiding, CPU-relievingsleep()
-s ). In case such timeout happens, having received no actual message so far, we can autonomously break theSUB
-side loop, as requested above.
Q.E.D.
QUESTION
I would like to transfer messages back and forth between Android and Python using ZMQ. I'm using NetMQ/ZMQ to do so. Following is my Requester code.
...ANSWER
Answered 2021-Jul-13 at 21:01You are using
QUESTION
sorry for my english
I start a new thread with a while(true) to receive information from socket but when I want to quit I have to use the Windows task manager. In fact, the method OnApplicationQuit() is never reached and Unity freeze.
I would like to know if there a way to know if someone try to quit or other method.
Thank you in advance
PS : I've already seen this post : https://github.com/zeromq/netmq/issues/526
The method start :
...ANSWER
Answered 2020-Jun-23 at 09:32I just replace : var timeout = new System.TimeSpan(0, 0, 20); by var timeout = new System.TimeSpan(0, 0, 0);
and now it's ok
QUESTION
The following in translated from the Divide and Conquer example in the ZeroMQ guide.
...ANSWER
Answered 2020-May-11 at 15:43open System
open System.IO
open System.Threading
open System.Threading.Tasks
open NetMQ
open NetMQ.Sockets
let parallel_task () =
let task_number = 100
let uri_source, uri_sink =
let uri = "ipc://parallel_task"
Path.Join(uri,"source"), Path.Join(uri,"sink")
let ventilator () =
let rnd = Random()
use source = new PushSocket()
source.Bind(uri_source)
use sink = new PushSocket()
sink.Connect(uri_sink)
let tasks = Array.init task_number (fun _ -> rnd.Next 100+1)
printf "Press enter when workers are ready.\n"
printf "Total expected time: %A\n" (TimeSpan.FromMilliseconds(Array.sum tasks |> float))
Console.ReadLine() |> ignore
sink.SendFrame("0")
printf "Sending tasks to workers.\n"
Array.iter (string >> source.SendFrame) tasks
Thread.Sleep(1)
let worker i () =
printf "Starting worker %i\n" i
use source = new PullSocket()
source.Connect(uri_source)
use sink = new PushSocket()
sink.Connect(uri_sink)
while true do
let msg = source.ReceiveFrameString()
printf "Worker %i received message.\n" i
Thread.Sleep(int msg)
sink.SendFrame("")
let sink () =
use sink = new PullSocket()
sink.Bind(uri_sink)
let watch = Diagnostics.Stopwatch()
for i=1 to task_number do
let _ = sink.ReceiveFrameString()
if watch.IsRunning = false then watch.Start()
printf (if i % 10 = 0 then ":" else ".")
printf "\nTotal elapsed time: %A msec\n" watch.Elapsed
Task.Run ventilator |> ignore
for i=1 to 4 do Task.Run (worker i) |> ignore
Task.Run(sink).Wait()
QUESTION
I put simply delay before subscriber reads next frame, so I expected that this will simulate slow subscriber and give some effects of HighWatermark option. I don't observe anything, subscriber doesn't skip (drop) any messages neither slow down the publisher. I have run 1 publisher and x subscribers.
I try to play with a pub-sub example taken from documentation https://netmq.readthedocs.io/en/latest/pub-sub/
Is there any way to detect that subscriber is slow? I mean the number of queued messages to be received exceeded the HighWatermark value. Shall I expect any exception or event in NetMqMonitor? I am also looking if there is a option to disconnect such a slow subscriber.
...ANSWER
Answered 2020-Feb-25 at 09:55NetMqMonitor
doesn't trigger events to indicate that some messages have been dropped.
Subscriber has to verify the generation time and decide itself what to do. http://zguide.zeromq.org/php:chapter5#Slow-Subscriber-Detection-Suicidal-Snail-Pattern
Ps. To observe effect of ReceiveHighWatermark the example code from question has to be modified. The messages were too small.
Community Discussions, Code Snippets contain sources that include Stack Exchange Network
Vulnerabilities
No vulnerabilities reported
Install netmq
Support
Reuse Trending Solutions
Find, review, and download reusable Libraries, Code Snippets, Cloud APIs from over 650 million Knowledge Items
Find more librariesStay Updated
Subscribe to our newsletter for trending solutions and developer bootcamps
Share this Page