MqContextC - construct an outgoing send-data-package … More...
Topics | |
MqContextC_SendApi_Basics_C_API | |
MqContextC - finish the send-data-block and call synchronous/asynchronous a remote-service … | |
MqContextC_SendApi_Atom_C_API | |
MqContextC - append a native PRIMITIVE TYPE value to the send-data-package … | |
MqContextC_SendApi_Block_C_API | |
MqContextC - a wrapper to send a list-block or a transaction-block … | |
MqContextC_SendApi_Return_C_API | |
MqContextC - finish the send-data-block on the server and optional return the results. … | |
Functions | |
MQ_EXTERN enum MkErrorE | libmqmsgque::MqSendSetHandShake (MQ_CTX const ctx, enum MqHandShakeE handShake) MK_ATTR_HDL |
set the hand-shake of the send-data-package | |
MqContextC - construct an outgoing send-data-package …
A data-package is send in two different scenarios:
Sending data is an active task and the opposite of reading data, which is a passive task. Active means that the send process is triggered by the software workflow or by the user.
For each basic type defined in MkBufferC*, there is a send function and some help functions.
If timeout != 0 is used, the application enters the event loop and waits in the current process or thread for timeout seconds until the service call is finished.
While waiting for a result, the application can continue to work on other events that are in the same or in a different process or thread.
Example-1: a service call, send and read a data-package
On a client: perform a service call
send the service-call | MqSendSTART → SendTT... → MqSendEND_AND_WAIT |
read the result package | ReadTT... → ... |
on a server: answer a service call
read the service-call | ReadTT... → ... |
send the result package | MqSendSTART → SendTT... → MqSendRETURN |
Important in the code from above is the last command MqSendEND_AND_WAIT because this is just one of five possibilities:
command | synchron | database | result |
---|---|---|---|
MqSendEND | no | no | no |
MqSendEND_AND_WAIT | yes | no | single return data |
MqSendEND_AND_SUB | yes | no | multiple return data |
MqSendEND_AND_CALLBACK | no | no | single return data |
MqSendEND_AND_TRANSACTION | no | yes | two return data |
To send a data-package is one task, to send it to the right receiver is an other one. The right receiver is identified using the token parameter argument. This parameter have to be a 4 character string. You'll probably ask "why 4?" the answer is that this string should be "human" readable and easy to "compare". As solution this string is mapped to a 4 byte integer used to find the proper key/value entry in the service-hash-table on the server. (in short: to search an integer is much faster as to search a string)
Example-2: (in C) At the client, calling the service and wait for an answer
... or using the MqContextC HIGH API
Example-3: (in C) At the server, answer the service call
... or using the MqContextC HIGH API
MQ_EXTERN enum MkErrorE libmqmsgque::MqSendSetHandShake | ( | MQ_CTX const | ctx, |
enum MqHandShakeE | handShake ) |
set the hand-shake of the send-data-package
[in] | ctx | the MqContextS instance to work on |
[in] | handShake | the value to set |