Networking Reference
In-Depth Information
int length = zmq_msg_size(&reply);
char* value = malloc(length + 1);
memcpy(value, zmq_msg_data(&reply), length);
unsigned long t_timer;
sscanf(value, "%lu", &t_timer);
int res = abs(current_time - t_timer);
if(res > DELAY) {
printf("Subscriber is too slow. Aborting.\n");
return 0;
We have defined a DELAY constant in our subscriber code and we calculate
the time the server takes to send a message and the local time of the subscriber.
If the difference between these values is larger than the DELAY constant, we
abort the subscriber as it means it runs slower. This is also known as suicidal
snail pattern in ZeroMQ terminology.
In this chapter we briefly looked at some advanced patterns, reliability, and how
to deal with slow subscribers in the publish-subscribe pattern.
ZeroMQ is a flexible, easy-to-use, and fast message queuing service. Unlike other
message queuing libraries, it allows developers to implement their own message
queuing services.
Search MirCeyron ::

Custom Search