Anyways. In my project I'm using ZeroMQ which is a very good socket library. I use that to make my workers communicate with each other.
Lately my main concern was message loss. Since I increase and decrease the number of workers, it may happen that some worker gets shut down when it is receiving, processing or sending a message.
The very first approach I had to solve the issue was to save the timestamp when a message was received and then wait some time. If a message was not received within that time (last_received_message - time_now > some_variable) then no messages will ever arrive anymore and I would shut down the worker. Moreover a flag would help me if a message is being processed (that is, when receiving a message a flag is set to true, when the message leaves the worker, the flag is set to false).
The problem is that I cannot possibly access the socket's queue to check what is inside and if I have to wait some more time before shutting the worker down. Eventually I found out about the getsockopt() function and its return values.
Before showing the code, I have to tell that this is not a final solution, nor the very right way to do it. For what concerns my sockets, I use PULL and PUSH. This means that I can only have two valid options for both. For the PULL socket which is read-only:
0 = nothing to read
1 = have something to read
For the PUSH socket which is write-only they are:
0 = can't write
2 = can write
BUT. The getsockopt(ZMQ_EVENTS) & ZMQ_POLLOUT > 0 does not mean there are no messages in the queue. It just means that the queue is not full and the socket is ready to accept some more for sending. On the other hand getsockopt(ZMQ_EVENTS) & ZMQ_POLLIN == 0 guarantees that the incoming queue is empty.
if(msg.command == 'kill'){ setInterval(function(){ var time_now = new Date().getTime(); //if 10 seconds passed without receiving any message or no message received at all (producer or useless worker) if(time_now - last_message_received > 10000 && !execution_flag || !last_message_received || receiver.getsockopt(zmq.ZMQ_EVENTS) | zmq.ZMQ_POLLIN == 0 && !execution_flag){ //kill } }, 1000); }
So basically I set up a timeout each second that checks if something has been received, if the worker is working on something or if is not working at something AND the POLLIN value is 0.
I still have to check this approach, but the given values for the bitmasks are correct.
If you have a better idea I'm open to suggestions. For now I think I will keep it this way.
yurtdışı kargo
ReplyDeleteresimli magnet
instagram takipçi satın al
yurtdışı kargo
sms onay
dijital kartvizit
dijital kartvizit
https://nobetci-eczane.org/
5TT
seferihisar transfer
ReplyDeletebalıklıova transfer
ıldır transfer
davutlar transfer
gümüldür transfer
APWR
Portekiz yurtdışı kargo
ReplyDeleteRomanya yurtdışı kargo
Slovakya yurtdışı kargo
Slovenya yurtdışı kargo
İngiltere yurtdışı kargo
4LMS
salt likit
ReplyDeletesalt likit
dr mood likit
big boss likit
dl likit
dark likit
RK2G
Samsun
ReplyDeleteUrfa
Erzincan
Mersin
Kayseri
Q43
ankara
ReplyDeletesakarya
tekirdağ
kastamonu
amasya
B7ZQ8
sakarya
ReplyDeleteelazığ
sinop
siirt
van
Q80
görüntülü show
ReplyDeleteücretlishow
7UF
görüntülüshow
ReplyDeleteücretli show
Q7V
kırklareli evden eve nakliyat
ReplyDeleteısparta evden eve nakliyat
istanbul evden eve nakliyat
ankara evden eve nakliyat
kırıkkale evden eve nakliyat
P2Z4S1
D1620
ReplyDeleteNiğde Evden Eve Nakliyat
Çankırı Lojistik
Burdur Parça Eşya Taşıma
Muş Parça Eşya Taşıma
Ankara Evden Eve Nakliyat
3BE25
ReplyDeleteKaraman Parça Eşya Taşıma
Bartın Parça Eşya Taşıma
Burdur Lojistik
Sakarya Parça Eşya Taşıma
Kırıkkale Evden Eve Nakliyat
86BEA
ReplyDeleteTekirdağ Şehirler Arası Nakliyat
İzmir Parça Eşya Taşıma
Bolu Lojistik
Denizli Parça Eşya Taşıma
Mamak Boya Ustası
Antep Lojistik
Kırıkkale Şehirler Arası Nakliyat
Probit Güvenilir mi
Urfa Şehirler Arası Nakliyat
368C8
ReplyDeleteMuğla Parça Eşya Taşıma
Erzurum Lojistik
Kırıkkale Parça Eşya Taşıma
Karabük Şehir İçi Nakliyat
Sinop Lojistik
Ağrı Şehir İçi Nakliyat
Tekirdağ Boya Ustası
Uşak Parça Eşya Taşıma
Bayburt Lojistik
F4C62
ReplyDeleteGiresun Şehirler Arası Nakliyat
Pursaklar Fayans Ustası
Çerkezköy Çilingir
Ünye Asma Tavan
Eskişehir Şehirler Arası Nakliyat
Çerkezköy Çekici
Erzincan Lojistik
Bartın Şehirler Arası Nakliyat
Bursa Şehir İçi Nakliyat
DA1F1
ReplyDeleteSamsun Lojistik
Sinop Şehirler Arası Nakliyat
Eskişehir Parça Eşya Taşıma
Antalya Evden Eve Nakliyat
Bursa Şehirler Arası Nakliyat
Kastamonu Şehirler Arası Nakliyat
Batıkent Parke Ustası
Çerkezköy Sineklik
Kastamonu Evden Eve Nakliyat
0857E
ReplyDeleteTrabzon Kadınlarla Sohbet Et
bedava sohbet uygulamaları
tokat kadınlarla rastgele sohbet
kars en iyi görüntülü sohbet uygulaması
hakkari rastgele sohbet uygulaması
kırklareli canlı sohbet siteleri
Rize Yabancı Sohbet
Bolu En İyi Ücretsiz Sohbet Siteleri
trabzon ücretsiz görüntülü sohbet uygulamaları
42DA2
ReplyDeletePeriscope Beğeni Satın Al
Alya Coin Hangi Borsada
Vector Coin Hangi Borsada
Facebook Grup Üyesi Satın Al
Sweat Coin Hangi Borsada
Btcst Coin Hangi Borsada
Btcturk Borsası Güvenilir mi
Bitcoin Madenciliği Nasıl Yapılır
Bee Coin Hangi Borsada
CDF36
ReplyDeleteShinja Coin Hangi Borsada
Likee App Takipçi Satın Al
Facebook Beğeni Hilesi
Periscope Takipçi Satın Al
Telegram Abone Hilesi
Likee App Takipçi Hilesi
Shibanomi Coin Hangi Borsada
Kripto Para Üretme Siteleri
Binance Hangi Ülkenin