Documentation of the MyTransaction tool used for example.test
.
The MyTransaction tool is used to test the longterm-transaction-feature of ccmqmsgque.
To test this feature the client connect to the server and send two service-calls:
The service-call itself is quite simple:
Privat_Data_1 or Privat_Data_2
1111 or 2222
The GOAL for this test is:
#include <iostream> using namespace ccmqmsgque; void callback(MqContextC *ctx) { ctx->ReadT_START(); MK_STRN myPrivateHandle = ctx->ReadSTR(); ctx->ReadT_END(); MK_I32 myServiceResult = ctx->ReadI32(); std::cout << "myPrivateHandle=" << myPrivateHandle << ", myServiceResult=" << myServiceResult << std::endl; } int MK_CDECL main(int argc, MK_STRN argv[]) { MqMsgque::Setup(); MqContextC ctx; try { ctx.ConfigSetName("MyTransaction"); // setup commandline arguments used for parsing MkBufferListC args = {argc, argv}; // check if the '--token' option is available, default "SRVC" MK_STRN token = args.CheckOptionSTR("--token", "SRVC"); // connect to the server ctx.LinkCreate(args); // register callback ctx.ServiceCreate("CLB1", MqContextC::MqTokenCCB(callback)); // send block using the LOW-Api ctx.SendSTART(); ctx.SendT_START(); ctx.SendSTR("Privat_Data_1"); ctx.SendT_END(); ctx.SendI32(11111); ctx.SendEND_AND_TRANSACTION(token, "CLB1"); // send block using the HIGN-Api -> same as above, but shorter char buffer[30]; sprintf(buffer, "%s:(C)I",token); ctx.Send("T", "CLB1", buffer, "Privat_Data_2", 22222); // now we wait for exact ONE result of the "ctx" ctx.ProcessEvent(MQ_WAIT_OWN); } catch (const std::exception& e) { ctx.ErrorCatch(e); } ctx.Exit(); }