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

List of all callback defined by pymqmsgque

The callback have to be a Python 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.
callback-args := service-ctx:MqContextC[in]
[static] def callback ( callback-args )
[instance] class YYY:
def callback ( self, callback-args )
[class] class ZZZ:
@staticmethod
def callback ( callback-args )

There are 3 different types of callback :

type code self argument
procedure ... proc-callback yes
class-method ... CLASS.callback yes
instance-method ... INSTANCE.callback yes

Example from Callback.py using MqServiceCreate with callback

import sys
from pymqmsgque import *

# General rules for defining a callback in PATHON
# -----------------------------------------------
# 1.  A callback always begins with the "Object", either the "instanceObject" or the "classObject":
#       `Object.Method`
# 2.  If the callback is an "instanceMethod" of another instance, the callback is defined as:
#       `instanceObject.instanceMethod
# 3.  If the callback is an "instanceMethod" of its own instance, the callback is defined as:
#       `self.instanceMethod`
# 4.  If the callback is a "classMethod," the callback is defined as:
#       `classObject.classMethod`

class OtherServerC():
  def __init__(self,wht):
    self.wht = wht
  # The "otherInstanceService" require an extra argument, the "cbCtx".
  def otherInstanceService(self,cbCtx):
    cbCtx.Send("R","C",cbCtx.ReadSTR() + "-" + self.wht + "-Other-Instance")
  # The "otherClassService" require an extra argument, the "cbCtx".
  @staticmethod
  def otherClassService(cbCtx):
    cbCtx.Send("R","C",cbCtx.ReadSTR() + "-World-Other-Class")

# The "procService" require an extra argument, the "cbCtx".
def procService(cbCtx):
  cbCtx.Send("R","C",cbCtx.ReadSTR() + "-World-Proc")

# package-item
class CallbackC(MqContextC):

  # The "ownInstanceService" require no extra argument.
  def ownInstanceService(self):
    self.Send("R","C",self.ReadSTR() + "-World-Own-Instance")

  # The "ownClassService" require an extra argument, the "cbCtx".
  @staticmethod
  def ownClassService(cbCtx):
    cbCtx.Send("R","C",cbCtx.ReadSTR() + "-World-Own-Class")

  # the "serverSetup" defines the test-services
  def serverSetup(self):

    # 1. The "otherInstanceCallback" require an extra argument, the "otherCtx".
      self.ServiceCreate("HLW1",self.otherCtx.otherInstanceService)

    # 2. The "otherClassCallback" require NO extra argument.
      self.ServiceCreate("HLW2",OtherServerC.otherClassService)

    # 3. The "ownInstanceCallback" require no extra argument.
      self.ServiceCreate("HLW3",self.ownInstanceService)

    # 4. The "otherClassCallback" require NO extra argument.
      self.ServiceCreate("HLW4",CallbackC.ownClassService)

    # 5. The "procCallback" require NO extra argument
      self.ServiceCreate("HLW5",procService)

  # factory startup (constructor)
  def __init__(self,tmpl=None):
    super().__init__(self,tmpl)
    self.ConfigSetServerSetup(CallbackC.serverSetup)
    self.otherCtx = OtherServerC("World")   ; # just for test purpose

# package-main
if __name__ == "__main__":

  # create the "Callback" factory… and the object
  srv = MqFactoryC.Add(CallbackC).New()

  try:
    srv.LinkCreate(sys.argv)
    srv.ProcessEvent(MqWaitOnEventE.FOREVER)
  except Exception as ex:
    srv.ErrorCatch(ex)
  finally:
    srv.Exit()

Callbacks defined by pymqmsgque

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