Documentation of the MyTransaction tool used for example.test
.
The MyTransaction tool is used to test the longterm-transaction-feature of libmqmsgque.
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 "msgque_mq.h" static enum MkErrorE callback( MQ_SERVICE_CALL_ARGS ) { MqReadT_START_E(mqctx); MK_STRN myPrivateHandle = MqReadSTR_e(mqctx); MqReadT_END(mqctx); MK_I32 myServiceResult = MqReadI32_e(mqctx); fprintf(stdout,"myPrivateHandle=%s, myServiceResult=%d\n", myPrivateHandle, myServiceResult); fflush(stdout); error: return MkErrorStack_1M_Check(mqctx); } int main (int argc, MK_STRN argv[]) { MkRtSetup_NULL; MQ_CTX ctx = MqContextCreate(NULL,NULL); MqConfigSetName(ctx, "MyTransaction"); // setup commandline arguments used for parsing MK_BFL args = MkBufferListCreateVC(argc, argv); // check if the '--token' option is available, default "SRVC" MK_STRN token = MkBufferListCheckOptionSTR_e(args, "--token", "SRVC", true); // connect to the server MqLinkCreate_E(ctx, args); // register callback MqServiceCreate_E(ctx, "CLB1", callback, NULL, NULL, NULL); // send block using the LOW-Api MqSendSTART_E(ctx); MqSendT_START_E(ctx); MqSendSTR_E(ctx, "Privat_Data_1"); MqSendT_END_E(ctx); MqSendI32_E(ctx, 11111); MqSendEND_AND_TRANSACTION_E(ctx, token, "CLB1", MK_TIMEOUT_DEFAULT); // send block using the HIGN-Api -> same as above, but shorter char buffer[30]; sprintf(buffer, "%s:(C)I",token); MqSend_E(ctx, "T", "CLB1", buffer, "Privat_Data_2", 22222); // now we wait for exact ONE result of the "ctx" MqProcessEvent_E(ctx, MQ_WAIT_OWN, MK_TIMEOUT_DEFAULT); error: MkBufferListDelete(args); // delete the context using the libmqmsgque APPLICATION-DTOR function "MqExit_1" MqExit_1(ctx); }