List of all callback defined by PythonMqMsgque
The callback have to be a Python proc or method …
There a two different types of callback:
- A callback used to define a context
- A callback used to define a service
Callback signature
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 *
class MyServer(MqContextC):
def __init__(self, tmpl=None):
self.ConfigSetServerSetup(self.ServerSetup)
super().__init__(tmpl)
def MyFirstService(self):
self.SendSTART()
self.SendSTR(self.ReadSTR() + " World")
self.SendRETURN()
def ServerSetup(self):
self.ServiceCreate("HLWO",self.MyFirstService)
if __name__ == "__main__":
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