The hub_safe_sub_set command is executed in the DMH server process. It causes the DMH server to periodically check to see if unread messages are accumulating in a DMH mailbox queue, and if so, to invoke user-provided cleanup code.
The hub_safe_sub_cleanup procedure can be invoked to execute the cleanup code and cancel further checking for the specified DMH mailbox. The optional argument trace is used as a boolean flag. If the value is non-zero, a diagnostic message is sent to the DMH system mailbox TRACE. DMH messages sent to the TRACE mailbox are printed to the console of the server process or shown in a window from the server process unless the application has defined custom handling.
The hub_safe_sub_unset procedure may be used to end the checking for a particular mailbox.
Use of the hub_safe_set facility is highly recommended for subscription data feeds to user interfaces and similar processes that may go away ungracefully.
The DMH server uses an array named ::dmh::hub_safe_sub to manage the periodic checking. This array can be inspected to diagnose the status of the periodic checking.
The command is part of the dmh package and it exists in the ::dmh namespace.
package require dmh proc my_safe_client_open {sendto subname table {max_msgs 200}} { # use safe_open to monitor for lost subscriber set close_code "SQL {close sub $subname to $table}" eval $close_code SQL "open sub $subname to $table sendto=$sendto insert update delete *" ::dmh::hub_safe_sub_set $sendto $max_msgs $close_code }