theLink 10.0
Loading...
Searching...
No Matches
Callback Signature List

List of all callback defined by atlmqmsgque

The callback is a regular ATL proc that either stands alone or is part of a class.

callback resolution

The callback is a list: [list ?class::?callback ?instance? args...], with automatic callback-name resolution occurs in the following order:

  1. The current-namespace in which the command containing the callback argument was executed.
  2. The global-namespace (::).
  3. The class-namespace (__CLASS__) if the callback is followed by an instance.

If automatic resolution does NOT produce the desired result, the callback can of course always be specified with the absolute-namespace.

additional parameters

ATL also allows additional parameters to be passed to the callback, for example, to support a specific implementation. These parameters are added at the end of the callback-call.

Example: The instance-callback with two default-arguments (arg1 and arg2), defined as:

  • define-callback-command [list callback instance add1 add2 add3]

results in the following callback call:

  • ::class::callback instance arg1 arg2 add1 add2 add3
See also
Read more about how to define a service-callback in theLink .

MkKernel callback

Callback signature

  • MkObjectDeleteCallbackSetup
    callback-args := typeName:MK_STRN[in], typeHdl:MK_HDL[in], objHdl:MK_HDL[in]
    [proc] proc callback { callback-args ?additional-args...? } ...
    MkObjectC::DeleteCallbackSetup "NAME" callback "FILTER"
    [instance] myooX::ClassN ::XXX {
    proc callback { xxxNs callback-args ?additional-args...? } ...
    }
    MkObjectC::DeleteCallbackSetup "NAME" [list callback $xxxNs] "FILTER"
    [class] myooX::ClassN ::YYY {
    proc callback { callback-args ?additional-args...? } ...
    }
    MkObjectC::DeleteCallbackSetup "NAME" ::YYY::callback "FILTER"

Callback example from RPC server

Example about the delete-callback-setup from the RPC server example/atl/LibSq3LiteRpcServer.atl

ServerSetup : The DeleteCallback is usually installed in the Setup-Callback but only once.

    if {[ConfigGetIsParent $myNs ]} {
      MkObjectC::DeleteCallbackSetup "LibSq3LiteRpcServer" [list ObjectDeleteCall $myNs] "^Sq3"
    }

The DeleteCallback is called before the deletion. In the RPC example, the RPC client is informed about the impending deletion.

  proc LibSq3LiteRpcServer::ObjectDeleteCall { myNs typeName typeHdl objHdl } {
    Send $myNs "E" "%DEL:CHH" $typeName $typeHdl $objHdl
  }

ServerCleanup : If the RPC server is deleted, the DeleteCallback is no longer needed and is therefore also deleted.

    if {[ConfigGetIsParent $myNs ]} {
      MkObjectC::DeleteCallbackCleanup "LibSq3LiteRpcServer"
    }

MqMsgque callback

There a two different types of callback:

  1. A callback used to define a context
  2. A callback used to define a service

Callback signature

1. The *service-ctx* is the *context* for which the service was defined.
2. If the *callback* is **not** an instance of the calling *context*, the *service-ctx* is added as an argument.
callback-args := service-ctx:MqContextC[in]
[static] proc callback { callback-args ?additional-args...? } ...
[own] myooX::ClassN ::XXX {
SuperI MqContextC
proc callback { ?additional-args...? } ...
[instance] myooX::ClassN ::YYY {
proc callback { myNs callback-args ?additional-args...? } ...
[class] myooX::ClassN ::ZZZ {
proc callback { callback-args ?additional-args...? } ...

There are 4 different types of callback :

type code self argument
procedure ... proc yes
class-method ... ?CLASS?::callback yes
instance-method of own class ... callback no
instance-method of other class ... CLASS::callback INSTANCE yes

Callback example

Example from Callback.atl using MqServiceCreate with callback

package require atlmqmsgque

# General rules for defining a callback in ATL
# --------------------------------------------
# 1.  A callback always begins with the "Method" follwed by the "instanceObject" if required.
# 2.  If the callback is an "instanceMethod" of another instance, the callback is defined as:
#       `[list ::CLASS::instanceMethod instanceObject]`
# 3.  If the callback is an "instanceMethod" of its own instance, the callback is defined as:
#       `instanceMethod`
# 4.  If the callback is a "classMethod," the callback is defined as:
#       `::CLASS::classMethod`

# attention, the "::OtherServerC" has no "::MqContextC" as "base-class" and require the "MqContextC::" prefix.
myooX::ClassN ::OtherServerC {
  proc OtherServerC {otherNs wht} {
    namespace upvar $otherNs my my
    set my(wht) $wht
  }
  # The "otherInstanceService" require an extra argument, the "cbNs".
  proc otherInstanceService {otherNs cbNs} {
    namespace upvar $otherNs my my
    MqContextC::Send $cbNs "R" "C" "[MqContextC::ReadSTR $cbNs]-$my(wht)-Other-Instance"
  }
  # The "otherClassService" require an extra argument, the "cbNs".
  proc otherClassService {cbNs} {
    MqContextC::Send $cbNs "R" "C" "[MqContextC::ReadSTR $cbNs]-World-Other-Class"
  }
} 

# The "procService" require an extra argument, the "cbNs".
proc procService {cbNs} {
  MqContextC::Send $cbNs "R" "C" "[MqContextC::ReadSTR $cbNs]-World-Proc"
}

# package-item
myooX::ClassN ::CallbackC {
  SuperI ::MqContextC

  # The "ownInstanceService" require no extra argument.
  proc ownInstanceService {cbNs} {
    Send $cbNs "R" "C" "[ReadSTR $cbNs]-World-Own-Instance"
  }

  # The "ownClassService" require an extra argument, the "cbNs".
  proc ownClassService {cbNs} {
    Send $cbNs "R" "C" "[ReadSTR $cbNs]-World-Own-Class"
  }

  # the "serverSetup" defines the test-services
  proc serverSetup {cbNs} {
    namespace upvar $cbNs my my

    # 1. The "otherInstanceCallback" require an extra argument, the "otherNs".
      # -> remember: use the *absolute-namespace* for the callback
      ServiceCreate $cbNs "HLW1" [list OtherServerC::otherInstanceService $my(otherNs)]

    # 2. The "otherClassCallback" require no extra argument.
      # -> remember: use the *absolute-namespace* for the callback
      ServiceCreate $cbNs "HLW2" OtherServerC::otherClassService

    # 3. The "ownInstanceCallback" require no extra argument.
      ServiceCreate $cbNs "HLW3" ownInstanceService

    # 4. The "ownClassCallback" require no extra argument.
      ServiceCreate $cbNs "HLW4" ownClassService

    # 5. The "procCallback" require NO extra argument
      ServiceCreate $cbNs "HLW5" procService
  }

  # factory startup (constructor)
  proc CallbackC {cbNs {tmpl ""}} {
    namespace upvar $cbNs my my
    MqContextC $cbNs $tmpl
    ConfigSetServerSetup    $cbNs serverSetup
    set my(otherNs) [myooX::NewN ::OtherServerC "World"]    ; # just for test purpose
  }

  proc ~CallbackC {cbNs} {
    namespace upvar $cbNs my my
    DestroyN $my(otherNs)
  }
} 

# package-main
MqMsgque::Main {

  # setup commandline arguments for later use
  set args  [MkBufferListC::CreateLA {*}$argv]

  # create "Callback" factory... and make it to the default.
  set fct   [MqFactoryC::Default [MqFactoryC::Add ::CallbackC]]

  # inspect commandline-argument for the "factory" to choose... and create a object
  set fct   [MqFactoryC::GetCalledL $args]
  set srv   [MqFactoryC::New $fct]

  try {
    MqContextC::LinkCreate $srv $args
    MqContextC::ProcessEvent $srv MQ_WAIT_FOREVER
  } on error {} {
    MqContextC::ErrorCatch $srv
  } finally {
    MqContextC::Exit $srv
  }
}

Callbacks defined by atlmqmsgque

Global MqSendEND_AND_CALLBACK_RT (MK_RT mkrt, MQ_CTX const ctx, MQ_TOK const token, MqServiceCallbackF const fCall, MK_CBP callback, MqDataFreeF fFree, MK_TIME_T const timeout)
MqSendEND_AND_CALLBACK
Global MqSendEND_AND_SUB_RT (MK_RT mkrt, MQ_CTX const ctx, MQ_TOK const token, MqServiceCallbackF const fCall, MK_CBP callback, MqDataFreeF fFree, MK_TIME_T timeout)
MqSendEND_AND_SUB
Global MqServiceCreate_RT (MK_RT mkrt, MQ_CTX const ctx, MQ_TOK const token, MqServiceCallbackF const fCall, MK_CBP callback, MqDataFreeF fFree, MkMarkF fMark)
MqServiceCreate
Global MqSetupS::BgError
ConfigApi_MqBgErrorIF
Global MqSetupS::Event
ConfigApi_MqEventIF
Global MqSetupS::ServerCleanup
ConfigApi_MqServerCleanupIF
Global MqSetupS::ServerSetup
ConfigApi_MqServerSetupIF