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

List of all callback defined by tclmqmsgque

The callback have to be a Tcl proc or method

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] ::oo::class create XXX {
superclass MqContextC
method callback { ?additional-args...? } ...
[instance] ::oo::class create YYY {
method callback { callback-args ?additional-args...? } ...
[class] ::oo::class create ZZZ {
self method callback { callback-args ?additional-args...? } ...

There are 4 different types of callback :

type code self argument
procedure ... proc-callback yes
class-method ... [list CLASS callback] yes
instance-method of own class ... callback no
instance-method of other class ... [list INSTANCE callback] yes

Example from Callback.tcl using MqServiceCreate with callback

package require tclmqmsgque
namespace import tclmqmsgque::*
namespace import tclmkkernel::*

# General rules for defining a callback in TCL
# --------------------------------------------
# 1.  A callback always begins with the "Object" argument, either the "instanceObject" or the "classObject".
# 2.  If the callback is an "instanceMethod" of another instance, the callback is defined as:
#       `[list instanceObject instanceMethod]`
# 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:
#       `[list classObject classMethod]`

oo::class create OtherServerC {
  variable wht
  constructor {_wht} { set wht $_wht }
  # The "otherInstanceService" require an extra argument, the "cbCtx".
  method otherInstanceService {cbCtx} {
    $cbCtx Send "R" "C" "[$cbCtx ReadSTR]-$wht-Other-Instance"
  }
  # The "otherClassService" require an extra argument, the "cbCtx".
  self method otherClassService {cbCtx} {
    $cbCtx Send "R" "C" "[$cbCtx ReadSTR]-World-Other-Class"
  }
} 

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

# package-item
oo::class create CallbackC {
  superclass MqContextC

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

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

  # the "serverSetup" defines the test-services
  method serverSetup {} {

    # 1. The "otherInstanceCallback" require an extra argument, the "otherCtx".
      my ServiceCreate "HLW1" [list otherCtx otherInstanceService]

    # 2. The "otherClassCallback" require NO extra argument.
      my ServiceCreate "HLW2" [list OtherServerC otherClassService]

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

    # 4. The "otherClassCallback" require NO extra argument.
      my ServiceCreate "HLW4" [list CallbackC ownClassService]

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

  # factory startup (constructor)
  constructor {{tmpl ""}} {
    next $tmpl
    my ConfigSetServerSetup    serverSetup

    OtherServerC create otherCtx "World"   ; # just for test purpose
  }
} 

# package-main
tclmqmsgque::Main {

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

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

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

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

Callbacks defined by tclmqmsgque

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