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

List of all callback defined by PythonMqMsgque

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
1. global or namespace proc
The python-proc require an extra argument, the calling context.
def myCB(self):
...
...
class MyServerMqContextC):
def serverSetup(self):
self.ServiceCreate("MYTO",myCB)
2. class method (static)
The class-method require an extra argument, the calling context.
The callback is a list of TWO items, the CLASS and the class-METHOD
The METHOD can be from the CLASS itself or from a superclass of the CLASS or from an other CLASS
class MySuper {
@staticmethod
def staticCB(self):
...
class MyServer(MqContextC):
def serverSetup(self):
self.ServiceCreate("MYTO",MySuper.staticCB)
3. own instance method (dynamic)
The own-instance-method has NO extra argument
class MyServer(MyContextC):
def dynamicCB(self):
...
def serverSetup(self):
self.ServiceCreate("MYTO",self.myCB)
...
4. other instance method (dynamic)
The instance-method require an extra argument, the calling context.
class MyOther:
def otherCB(otherInstance,ctx);
...
otherInstance = MyOther()
class MyServer(MqContextC):
def serverSetup(self):
self.ServiceCreate("MYTO",otherInstance.myCB)

The ONLY argument of the callback-proc have to be the self object.

Example from MyServer.py using MqServiceCreate with instance-callback

import sys
from pymqmsgque import *

# package-item
class MyServer(MqContextC):

  # factory startup
  def __init__(self, tmpl=None):
    self.ConfigSetServerSetup(self.ServerSetup)
    super().__init__(tmpl)

  # service to serve all incoming requests for token "HLWO"
  def MyFirstService(self):
    self.SendSTART()
    self.SendSTR(self.ReadSTR() + " World")
    self.SendRETURN()

  # define a service as link between the token "HLWO" and the callback "MyFirstService"
  def ServerSetup(self):
    self.ServiceCreate("HLWO",self.MyFirstService)

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

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

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

Callbacks defined by PythonMqMsgque

Global MqSendEND_AND_CALLBACK_RT (MK_RT const 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 const 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 const mkrt, MQ_CTX const ctx, MQ_TOK const token, MqServiceCallbackF const fCall, MK_CBP callback, MqDataFreeF fFree, MkMarkF fMark)
MqServiceCreate
Global MqSetupS::BgError
ConfigApi_IBgError
Global MqSetupS::Event
ConfigApi_IEvent
Global MqSetupS::ServerCleanup
ConfigApi_IServerCleanup
Global MqSetupS::ServerSetup
ConfigApi_IServerSetup