theLink 10.0
|
List of all callback defined by csmqmsgque
The callback have to be a instance-method, a class-method or an interface …
There a two different types of callback:
The callback is an interface using a single virtual function called Servive :
or a MqContextC instance-method :
or a MqContextC class-method :
Example from Callback.cs
→ using MqServiceCreate with callback
using System; using csmqmsgque; namespace example { // General rules for defining a callback in ATL // -------------------------------------------- // 1. The \e callback have to be a \e instance-method, a \e class-method or an \e interface. // attention, the "::OtherServerC" has no "::MqContextC" as "base-class" and require the "MqContextC::" prefix. class OtherServerC : MqServiceIF { private string wht = ""; public OtherServerC(string _wht) { wht = _wht; } // The "otherInstanceService" require an extra argument, the "cbCtx". public void Service (MqContextC cbCtx) { cbCtx.Send("R", "C", cbCtx.ReadSTR() + "-" + wht + "-Other-Instance"); } // The "otherClassService" require an extra argument, the "cbCtx". public static void otherClassService (MqContextC cbCtx) { cbCtx.Send("R", "C", cbCtx.ReadSTR() + "-World-Other-Class"); } }; class CallbackC : MqContextC, MqServerSetupIF { private OtherServerC otherCtx = new OtherServerC("World"); // factory startup (constructor) public CallbackC (MqContextC tmpl=null) : base(tmpl) { } // The "procService" require an extra argument, the "cbCtx". public void procService(MqContextC cbCtx) { cbCtx.Send("R", "C", cbCtx.ReadSTR() + "-World-Proc"); } // The "ownInstanceService" require no extra argument. void ownInstanceService () { Send("R", "C", ReadSTR() + "-World-Own-Instance"); } // The "ownClassService" require an extra argument, the "cbCtx". static void ownClassService (MqContextC cbCtx) { cbCtx.Send("R", "C", cbCtx.ReadSTR() + "-World-Own-Class"); } // the "serverSetup" defines the test-services public void ServerSetup () { // 1. The "otherInstanceCallback" require an extra argument, the "otherCtx". ServiceCreate("HLW1",otherCtx); // 2. The "otherClassCallback" require no extra argument. // -> remember: use the *absolute-namespace* for the callback ServiceCreate("HLW2",OtherServerC.otherClassService); // 3. The "ownInstanceCallback" require no extra argument. ServiceCreate("HLW3",ownInstanceService); // 4. The "otherClassCallback" require no extra argument. ServiceCreate("HLW4",CallbackC.ownClassService); // 5. The "procCallback" require NO extra argument ServiceCreate("HLW5",procService); } // package-main static void Main(string[] argv) { // create the "MyServer" factory… and the object var srv = MqFactoryCT<CallbackC>.Add().New(); try { srv.LinkCreate(argv); srv.ProcessEvent(MqWaitOnEventE.FOREVER); } catch (Exception ex) { srv.ErrorCatch (ex); } srv.Exit(); } } }