Git Product home page Git Product logo

Comments (7)

miniway avatar miniway commented on June 2, 2024

Basically it is not easy getting the list of connected peer in ZMQ without a lock. This would have a negative impact on its performance.

The monitor approach might be still the best option. At a point the monitor call was improved at libzmq, but jeromq is a little behind of the change.

We need to improve the jeromq monitor code together by investigating how libzmq works.

from jeromq.

cwolfinger avatar cwolfinger commented on June 2, 2024

Hi what I am really looking for is the following scenario:

  1. I have a point to point connection between 2 servers (push / pull).
  2. If the server peer goes down I want the app to be notified so that it
    stops sending requests.

Not sure how to accomplish this with ZMQ
Chase

On Tue, May 14, 2013 at 8:48 AM, Dongmin Yu [email protected]:

Basically it is not easy getting the list of connected peer in ZMQ without
a lock. This would have a negative impact on its performance.

The monitor approach might be still the best option. At a point the
monitor call was improved at libzmq, but jeromq is a little behind of the
change.

We need to improve the jeromq monitor code together by investigating how
libzmq works.


Reply to this email directly or view it on GitHubhttps://github.com//issues/61#issuecomment-17880766
.

from jeromq.

hintjens avatar hintjens commented on June 2, 2024

The classic answer to this question is, this isn't the ZeroMQ/JeroMQ
layer's work, you should do that on top using the right mix of heartbeats
and socket patterns. There is lots of discussion of this in the Guide.

It's still the right answer: knowing too much about peers breaks the
abstractions. Over time we may learn how to do this correctly but we're not
there yet. The monitor approach is not the right approach.

-Pieter

On Tue, May 14, 2013 at 5:52 PM, cwolfinger [email protected]:

Hi what I am really looking for is the following scenario:

  1. I have a point to point connection between 2 servers (push / pull).
  2. If the server peer goes down I want the app to be notified so that it
    stops sending requests.

Not sure how to accomplish this with ZMQ
Chase

On Tue, May 14, 2013 at 8:48 AM, Dongmin Yu [email protected]:

Basically it is not easy getting the list of connected peer in ZMQ
without
a lock. This would have a negative impact on its performance.

The monitor approach might be still the best option. At a point the
monitor call was improved at libzmq, but jeromq is a little behind of
the
change.

We need to improve the jeromq monitor code together by investigating how
libzmq works.


Reply to this email directly or view it on GitHub<
https://github.com/zeromq/jeromq/issues/61#issuecomment-17880766>
.


Reply to this email directly or view it on GitHubhttps://github.com//issues/61#issuecomment-17885271
.

from jeromq.

cwolfinger avatar cwolfinger commented on June 2, 2024

Thank you for the clarification. I was missing this point.

On Tue, May 14, 2013 at 11:37 AM, Pieter Hintjens
[email protected]:

The classic answer to this question is, this isn't the ZeroMQ/JeroMQ
layer's work, you should do that on top using the right mix of heartbeats
and socket patterns. There is lots of discussion of this in the Guide.

It's still the right answer: knowing too much about peers breaks the
abstractions. Over time we may learn how to do this correctly but we're
not
there yet. The monitor approach is not the right approach.

-Pieter

On Tue, May 14, 2013 at 5:52 PM, cwolfinger [email protected]:

Hi what I am really looking for is the following scenario:

  1. I have a point to point connection between 2 servers (push / pull).
  2. If the server peer goes down I want the app to be notified so that it
    stops sending requests.

Not sure how to accomplish this with ZMQ
Chase

On Tue, May 14, 2013 at 8:48 AM, Dongmin Yu [email protected]:

Basically it is not easy getting the list of connected peer in ZMQ
without
a lock. This would have a negative impact on its performance.

The monitor approach might be still the best option. At a point the
monitor call was improved at libzmq, but jeromq is a little behind of
the
change.

We need to improve the jeromq monitor code together by investigating
how
libzmq works.


Reply to this email directly or view it on GitHub<
https://github.com/zeromq/jeromq/issues/61#issuecomment-17880766>
.


Reply to this email directly or view it on GitHub<
https://github.com/zeromq/jeromq/issues/61#issuecomment-17885271>
.


Reply to this email directly or view it on GitHubhttps://github.com//issues/61#issuecomment-17892172
.

from jeromq.

miniway avatar miniway commented on June 2, 2024

@cwolfinger right, you don't have fully trust ZMQ monitoring as it doesn't reflect the networking, server and application status. If you still want to use monitoring as a helper for status check, say logging, please refer

https://github.com/zeromq/jeromq/blob/master/src/test/java/zmq/TestMonitor.java

Actually it should be revised but as a interim solution, you can try

Here's a sudo code

push_sock.monitor("inproc://my-monitor", ZMQ.EVENT_ALL);
new Runnable() {
      void run() {
            monitor_sock = ctx.socket(ZMQ.PAIR);
            monitor_sock.connect("inproc://my-monitor");
            while (true) {
                  byte[] event = monitor_sock.recv();    //  4bytes-event-type, 1byte-address-length, length bytes address, 1byte-flag, optional-integer(errno)                    
                  // do your stuff like logging
            }
      }
}.start();

from jeromq.

raffian avatar raffian commented on June 2, 2024

@miniway I'm using your monitor example above to watch messages on a PULL socket accumulate in receive buffer, I want to take action before HWM is exceeded, but there's no event generated when a message is received. I only see events on peer connect and other things, but no events generated, is that normal?

    final ZContext ctx = new ZContext();        
    Socket pull = ctx.createSocket(ZMQ.PULL);
    pull.bind("tcp://*:5555");
            pull.monitor("inproc://events", ZMQ.EVENT_ALL);

    Socket push = ctx.createSocket(ZMQ.PUSH);

    Runnable r = new Runnable() {
           public void run() {
            Socket monitor_sock = ctx.createSocket(ZMQ.PAIR);
            monitor_sock.connect("inproc://events");
            while (true) {
                  byte[] event = monitor_sock.recv();                 
                  //just dump event as string
                  log( new String(event));
            }
        }
    };
    (new Thread(r)).start();

    push.setSndHWM(100);
    push.connect("tcp://localhost:5555");
    push.send("hello");
    push.send("world");

Output:
?? tcp://localhost:555?? //for initial connect

from jeromq.

miniway avatar miniway commented on June 2, 2024

@raffian It is normal. There's no event related with HWM.

If you want to handle HWM, try sending messages with ZMQ_DONTWAIT or ZMQ_SNDTIMEO=1. The send method will return false incase of HWM.

from jeromq.

Related Issues (20)

Recommend Projects

  • React photo React

    A declarative, efficient, and flexible JavaScript library for building user interfaces.

  • Vue.js photo Vue.js

    🖖 Vue.js is a progressive, incrementally-adoptable JavaScript framework for building UI on the web.

  • Typescript photo Typescript

    TypeScript is a superset of JavaScript that compiles to clean JavaScript output.

  • TensorFlow photo TensorFlow

    An Open Source Machine Learning Framework for Everyone

  • Django photo Django

    The Web framework for perfectionists with deadlines.

  • D3 photo D3

    Bring data to life with SVG, Canvas and HTML. 📊📈🎉

Recommend Topics

  • javascript

    JavaScript (JS) is a lightweight interpreted programming language with first-class functions.

  • web

    Some thing interesting about web. New door for the world.

  • server

    A server is a program made to process requests and deliver data to clients.

  • Machine learning

    Machine learning is a way of modeling and interpreting data that allows a piece of software to respond intelligently.

  • Game

    Some thing interesting about game, make everyone happy.

Recommend Org

  • Facebook photo Facebook

    We are working to build community through open source technology. NB: members must have two-factor auth.

  • Microsoft photo Microsoft

    Open source projects and samples from Microsoft.

  • Google photo Google

    Google ❤️ Open Source for everyone.

  • D3 photo D3

    Data-Driven Documents codes.