From the documentation, a req socket :
...is reliable, in that a the requester will keep retrying until a reply is received.
Specifically:
The request is resent if no reply arrives, until a reply is received or the request times out.
Q1:
This just means that a rep socket must package and send a message back to the req socket object to prevent retries, right?
However, using a lower-level reliable transport should make some guarantees about delivery even without req/rep, for example using normal nng_pair, shouldn't it?
For example, if I specify endpoints as "tcp://x.x.x.x", then shouldn't TCP itself perform reliable transport of the packets assuming sockets are connected? And, since nng_socket handles reconnects ...
When the pipe is closed, the dialer attempts to re-establish the connection. Dialers will also periodically retry a connection automatically if an attempt to connect asynchronously fails.
Q2:
... then it seems TCP+pair should be enough to ensure eventual delivery of packets?
What is different between dehydrated and rehydrated activities for BizTalk messages process?
And when I can get dehydrated messages to suspended and resume instance?
Any one can get explained with examples that will be appreciate!
A message & orchestration will dehydrate if they are generally either waiting for a response. It will rehydrate once the response is received.
A message will suspend if it times out or receives a error condition.
You have a process tree you want to kill, so you send an exit(PID, shutdown) to the supervisor. There's other stuff you need to do, but it can't be done until this process tree is shutdown. For instance, let's say this process tree writes to a database. You want to shut everything down cleanly. You want to shut down the database, but obviously you need to shut down the process tree first, else the tree could be in the middle of a write to the database.
My question is, when I send the exit signal, is it synchronous or asynchronous? If it is synchronous, it seems I have no worries, but if it is asynchronous, I will need to do something like establish a process monitor and check whether the tree shut down before I proceed with database shutdown, correct?
Thanks.
Short answer: OTP shutdown is synchronous. exit/2 is a single asynchronous message.
Long answer: All messages in Erlang are asynchronous. The shutdown message is no different. However, there is more to shutdown than just sending a message. The supervisor listens for {'DOWN', ...} messages after sending the exit signal. Only after it receives a 'DOWN' message or times out does it proceed, so in effect it is synchronous. Checkout the supervisor source code. On line 894 is where the functions that actually makes the exit call is defined:
shutdown(Pid, Time) ->
case monitor_child(Pid) of
ok ->
exit(Pid, shutdown), %% Try to shutdown gracefully
receive
{'DOWN', _MRef, process, Pid, shutdown} ->
ok;
{'DOWN', _MRef, process, Pid, OtherReason} ->
{error, OtherReason}
after Time ->
exit(Pid, kill), %% Force termination.
receive
{'DOWN', _MRef, process, Pid, OtherReason} ->
{error, OtherReason}
end
end;
{error, Reason} ->
{error, Reason}
end.
The source code can be viewed on GitHub here: https://github.com/erlang/otp/blob/maint/lib/stdlib/src/supervisor.erl#L894
erlang:exit/2 calls on the other hand is simply an asynchronous exit signal
If you need to manage this yourself, do your own monitoring:
sneak_attack(BankGuard) ->
monitor(process, BankGuard),
exit(BankGuard, kill),
Cash = receive {'DOWN', _, process, BankGuard, _} -> rob_bank() end,
send_to_bahamas(Cash).
In this example rob_bank() and anything after is blocked waiting on the 'DOWN' message from BankGuard.
Also, note that this is a much more general concept than just shutting something down. All messages in Erlang are asynchronous but unlike UDP, ordering (between two processes) and delivery (so long as the destination is alive) is guaranteed. So synchronous messaging is simply monitoring the target, sending a tagged message, and blocking on receipt of the return message.
If I send a messag using SignalR, is it possible that the client does not receive the message? How can you verify if any errors apeared in the communication? Iam thinking of sending a message back to server after the server notification was sent, but is there any better way?
Yes, it's possible that the client doesn't receive the message. SignalR keeps messages in memory for 30 seconds (by default, you can tweak that or use a persistent message bus), so if the client isn't connected for whatever reason and this timeout passes the client will miss the message. Note that if he reconnects within this period he receives all messages he hasn't got yet, including those that were sent when he was disconnected.
I don't know if SignalR provides a way of telling you when a broadcast failed, so it might be safer to just send an acknowledgement back to the server.
As long as the client is connected, it will get the messages. You can subscribe to connection state changes in client side code. In server side code you can implement IConnected and IDisconnect interfaces to handle the Connect, Disconnect, and Reconnect events.
I found an interesting question about retransmission queue on TCP, I've been reading this
, I can see from this article that there are so many timers on TCP, but what I don't get is how they all sync with each other, for example when when the messages is sent, it's placed on a retransmission queue, and a retransmission timer will check this queue when the time reached 0 on the queue to be retransmitted.
Is this queue a Queue data structure? and it seems to be that two TCP function will check this queue, the first one is the retransmission queue retransmit the message, and the synak timer that delete the packet that has been been delivered successfully, in this case there must be some sync mechanism between those timers as they access the same queue, right?
Can you any one help understand how this works?
I think you have the wrong conception of timers. It's not an application. These are operating system timers: there is no issue about keeping them in synchronization. I think you have the wrong conception of queues too: I don't know exactly what you mean by 'is this queue a Queue data structure'? The question doesn't really make sense. A queue is a queue. In this case again it is a kernel queue. How it is implemented isn't any concern of anybody except the kernel authors.