Comments (7)
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.
Hi what I am really looking for is the following scenario:
- I have a point to point connection between 2 servers (push / pull).
- 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.
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:
- I have a point to point connection between 2 servers (push / pull).
- 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
ChaseOn 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.
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:
- I have a point to point connection between 2 servers (push / pull).
- 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
ChaseOn 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.
@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.
@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.
@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)
- Socket#connect hangs for ever on wrong host/port
- ZCertStore's loadFiles recursion logic is incorrect only recursing into first subdir. HOT 3
- Will there be another release? HOT 3
- Problem: Changelog is out of date
- Problem: No clear examples for Curve usage
- Problem: No automated way to deploy a release to maven central HOT 2
- socket.CLIENT does not seem to do anything in java8 HOT 2
- ipc:// protocol with zeromq. Java does support UNIX domain socket since JDK 16 HOT 1
- periodic index-out-of-bounds error HOT 9
- issue with kvmsg get/set operation HOT 2
- NPE after uplift jeromq from 0.5.2 to 0.5.3 HOT 3
- 0.5.4 and 0.6 versions HOT 3
- MsgsendBlockAndCpuIs100% HOT 7
- ipc HOT 3
- New client cannot receive any data in PUB/SUB mode HOT 1
- How to split `ZMsg` in reply envelope and request? HOT 1
- reaper-1 thread consuming 99.9% CPU HOT 2
- DEALER recv sometimes hangs HOT 5
- Export own and subscription addresses for testing HOT 3
- [Question] Message Persistence HOT 6
Recommend Projects
-
React
A declarative, efficient, and flexible JavaScript library for building user interfaces.
-
Vue.js
🖖 Vue.js is a progressive, incrementally-adoptable JavaScript framework for building UI on the web.
-
Typescript
TypeScript is a superset of JavaScript that compiles to clean JavaScript output.
-
TensorFlow
An Open Source Machine Learning Framework for Everyone
-
Django
The Web framework for perfectionists with deadlines.
-
Laravel
A PHP framework for web artisans
-
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.
-
Visualization
Some thing interesting about visualization, use data art
-
Game
Some thing interesting about game, make everyone happy.
Recommend Org
-
Facebook
We are working to build community through open source technology. NB: members must have two-factor auth.
-
Microsoft
Open source projects and samples from Microsoft.
-
Google
Google ❤️ Open Source for everyone.
-
Alibaba
Alibaba Open Source for everyone
-
D3
Data-Driven Documents codes.
-
Tencent
China tencent open source team.
from jeromq.