List of all callback defined by jvmqmsgque
The callback must be an instance of a class with the interface jvmqmsgque.MqServiceIF.
There a two different types of callback:
The callback in an interface using a single virtual function called Callback.
Example from Callback.java
→ using MqServiceCreate with callback
package example; import jvmkkernel.*; import jvmqmsgque.*; // General rules for defining a callback in RUBY // --------------------------------------------- // 1. The callback must be an \e instance of a class with the interface \WNS{MqServiceIF} final class OtherServerC implements MqServiceIF { private String wht = "" ; public OtherServerC(String _wht) { wht = _wht; }; // The "otherInstanceService" require an extra argument, the "cbCtx". public void Callback(MqContextC cbCtx) { cbCtx.Send("R", "C", cbCtx.ReadSTR() + "-" + wht + "-Other-Instance"); } // The "otherClassService" require an extra argument, the "cbCtx". public static class otherClassService implements MqServiceIF { public void Callback(MqContextC cbCtx) { cbCtx.Send("R", "C", cbCtx.ReadSTR() + "-World-Other-Class"); } } } // package-item final class Callback extends MqContextC implements MqServiceIF, MqServerSetupIF { private OtherServerC otherCtx = new OtherServerC("World") ; // just for test purpose; // factory startup (constructor) public Callback(MqContextC tmpl) { super(tmpl); } // The "procService" require an extra argument, the "cbCtx". public static class procService implements MqServiceIF { public void Callback(MqContextC cbCtx) { cbCtx.Send("R", "C", cbCtx.ReadSTR() + "-World-Proc"); } } // The "ownInstanceService" require no extra argument. public void Callback(MqContextC cbCtx) { Send("R", "C", ReadSTR() + "-World-Own-Instance"); } // The "ownClassService" require an extra argument, the "cbCtx". public static class ownClassService implements MqServiceIF { public void Callback(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. ServiceCreate("HLW2",new OtherServerC.otherClassService()); // 3. The "ownInstanceCallback" require no extra argument. ServiceCreate("HLW3",this); // 4. The "otherClassCallback" require NO extra argument. ServiceCreate("HLW4",new ownClassService()); // 5. The "procCallback" require NO extra argument ServiceCreate("HLW5",new procService()); } // ------------------------------------------------------------- // package-main public static void main(String[] argv) { // create the "Callback" factory… and return the initial (top) object MqContextC srv = MqFactoryC.Add(Callback.class).New(); try { srv.LinkCreate(argv); srv.ProcessEvent(MqWaitOnEventE.FOREVER); } catch (Throwable e) { srv.ErrorCatch(e); } srv.Exit(); } }