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

List of all callback defined by libmqmsgque

The servive-callback have to be a function-pointer of type MqServiceCallbackF (MqTokenF)

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

Callback used to call a service

#define MQ_SERVICE_CALL_ARGS MK_RT_ARGS MQ_CTX const mqctx, MK_PTR const __data__
#define MQ_SERVICE_CALL MK_RT_CALL mqctx, __data__
__parser__(flags=public-internal)

Callback used to free a service

#define MQ_SERVICE_FREE_ARGS MK_RT_ARGS MQ_CTX const mqctx, MK_PTR *dataP __parser__(inout)
__parser__(flags=public-internal)

Callback used to copy a service

#define MQ_SERVICE_COPY_ARGS MK_RT_ARGS MQ_CTX const mqctx, MK_PTR *dataP __parser__(inout)
__parser__(flags=public-internal)

Example from Callback.c using MqServiceCreate with callback

#include "common.h"

mk_inline MK_STRN MyConcat2C(MK_STRN s1, MK_STRN s2) {
  static MkThreadLocal MK_STRB tmpS[256];
  snprintf(tmpS,256,"%s%s",s1,s2);
  return tmpS;
}

// General rules for defining a callback in ATL
// --------------------------------------------
// The \e servive-callback have to be a \e function-pointer of type \RCNs{ServiceCallbackF} (\RCNs{TokenF})

// =============================================================================
// OtherServerC

  // The "otherInstanceService" require an extra argument, the "mqctx".
  enum MkErrorE otherInstanceService (MQ_SERVICE_CALL_ARGS) {
    return MqSend(mqctx,"R", "C", MyConcat2C(MqReadSTR_e(mqctx),"-World-Other-Instance"));
  error:
    return MqSendRETURN (mqctx);
  }
  // The "otherClassService" require an extra argument, the "mqctx".
  static enum MkErrorE otherClassService (MQ_SERVICE_CALL_ARGS) {
    return MqSend(mqctx,"R", "C", MyConcat2C(MqReadSTR_e(mqctx),"-World-Other-Class"));
  error:
    return MqSendRETURN (mqctx);
  }

// =============================================================================
// The "procService" require an extra argument, the "mqctx".
enum MkErrorE procService (MQ_SERVICE_CALL_ARGS) {
  return MqSend(mqctx,"R", "C", MyConcat2C(MqReadSTR_e(mqctx),"-World-Proc"));
  error:
    return MqSendRETURN (mqctx);
}

// =============================================================================
// CallbackC

  // The "ownInstanceService" require no extra argument.
  enum MkErrorE ownInstanceService (MQ_SERVICE_CALL_ARGS) {
    return MqSend(mqctx,"R", "C", MyConcat2C(MqReadSTR_e(mqctx),"-World-Own-Instance"));
  error:
    return MqSendRETURN (mqctx);
  }

  // The "ownClassService" require an extra argument, the "mqctx".
  static enum MkErrorE ownClassService (MQ_SERVICE_CALL_ARGS) {
    return MqSend(mqctx,"R", "C", MyConcat2C(MqReadSTR_e(mqctx), "-World-Own-Class"));
  error:
    return MqSendRETURN (mqctx);
  }

  // the "serverSetup" defines the test-services
  static enum MkErrorE ServerSetup (MQ_SERVICE_CALL_ARGS) {
    // 1. The "otherInstanceCallback" require an extra argument, the "otherCtx".
      MqServiceCreate_E(mqctx,"HLW1",otherInstanceService,NULL,NULL,NULL);

    // 2. The "otherClassCallback" require no extra argument.
      // -> remember: use the *absolute-namespace* for the callback
      MqServiceCreate_E(mqctx,"HLW2",otherClassService,NULL,NULL,NULL);

    // 3. The "ownInstanceCallback" require no extra argument.
      MqServiceCreate_E(mqctx,"HLW3",ownInstanceService,NULL,NULL,NULL);

    // 4. The "otherClassCallback" require no extra argument.
      MqServiceCreate_E(mqctx,"HLW4",ownClassService,NULL,NULL,NULL);

    // 5. The "procCallback" require NO extra argument
      MqServiceCreate_E(mqctx,"HLW5",procService,NULL,NULL,NULL);

    return MK_OK;
  error:
    return MkErrorStack_1X(mqctx);
  }

// package-item
enum MkErrorE
CallbackCSetup ( MQ_CALLBACK_FACTORY_CTOR_ARGS )
{ 
  MQ_CTX const mqctx = *contextP = MqContextCreate(NULL,tmpl);
  MqConfigSetServerSetup    (mqctx, ServerSetup,    NULL, NULL, NULL);
  return MK_OK;
}

// package-main
int main (int argc, MK_STRN argv[]) 
{
  AllRtSetup_NULL;

  // setup commandline arguments for later use
  MK_BFL largv = MkBufferListCreateVC(argc, argv);
  MQ_CTX mqctx = NULL;

  // create "MyServer" factory… and make it to the default.
  MqFactoryDefault( MqFactoryAdd_2(CallbackCSetup, "CallbackC"));
  // inspect commandline-argument for the "factory" to choose… and create a object
  MqFactoryNew_E (MqFactoryGetCalledL(largv), NULL, &mqctx);

  // start listen for incoming call's
  MqLinkCreate_E (mqctx, largv);
  MqCheckForLeftOverArguments_E (mqctx, largv);
  MqProcessEvent_E (mqctx,MQ_WAIT_FOREVER,MK_TIMEOUT_DEFAULT);
error:
  MkBufferListDelete(largv);
  MqExit_1(mqctx);
}

Callbacks defined by libmqmsgque

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