NATS C Client with JetStream and Streaming support
3.9.1
The nats.io C Client, Supported by Synadia Communications Inc.
|
Functions | |
NATS_EXTERN natsStatus | jsPubOptions_Init (jsPubOptions *opts) |
Initializes a publish options structure. More... | |
NATS_EXTERN natsStatus | js_Publish (jsPubAck **pubAck, jsCtx *js, const char *subj, const void *data, int dataLen, jsPubOptions *opts, jsErrCode *errCode) |
Publishes data on a subject to JetStream. More... | |
NATS_EXTERN natsStatus | js_PublishMsg (jsPubAck **pubAck, jsCtx *js, natsMsg *msg, jsPubOptions *opts, jsErrCode *errCode) |
Publishes a message to JetStream. More... | |
NATS_EXTERN void | jsPubAck_Destroy (jsPubAck *pubAck) |
Destroys the publish acknowledgment object. More... | |
NATS_EXTERN natsStatus | js_PublishAsync (jsCtx *js, const char *subj, const void *data, int dataLen, jsPubOptions *opts) |
Publishes data to JetStream but does not wait for a jsPubAck. More... | |
NATS_EXTERN natsStatus | js_PublishMsgAsync (jsCtx *js, natsMsg **msg, jsPubOptions *opts) |
Publishes a message to JetStream but does not wait for a jsPubAck. More... | |
NATS_EXTERN natsStatus | js_PublishAsyncComplete (jsCtx *js, jsPubOptions *opts) |
Wait for all outstanding messages to be acknowledged. More... | |
NATS_EXTERN natsStatus | js_PublishAsyncGetPendingList (natsMsgList *pending, jsCtx *js) |
Returns the list of pending messages published asynchronously. More... | |
Publishing functions
NATS_EXTERN natsStatus jsPubOptions_Init | ( | jsPubOptions * | opts | ) |
Use this before setting specific publish options and passing this configuration to the JetStream publish APIs.
opts | the pointer to the jsPubOptions to initialize. |
NATS_EXTERN natsStatus js_Publish | ( | jsPubAck ** | pubAck, |
jsCtx * | js, | ||
const char * | subj, | ||
const void * | data, | ||
int | dataLen, | ||
jsPubOptions * | opts, | ||
jsErrCode * | errCode | ||
) |
Publishes the data to the given subject to JetStream.
See js_PublishMsg for details.
pubAck | the location where to store the pub acknowledgment, or NULL if not needed. |
js | the pointer to the jsCtx object. |
subj | the subject the data is sent to. |
data | the data to be sent, can be NULL . |
dataLen | the length of the data to be sent. |
opts | the publish options, possibly NULL . |
errCode | the location where to store the JetStream specific error code, or NULL if not needed. |
NATS_EXTERN natsStatus js_PublishMsg | ( | jsPubAck ** | pubAck, |
jsCtx * | js, | ||
natsMsg * | msg, | ||
jsPubOptions * | opts, | ||
jsErrCode * | errCode | ||
) |
Publishes the given message to JetStream.
NULL
, but keep in mind that the publish acknowledgment is still sent by the server. pubAck | the location where to store the pub acknowledgment, or NULL if not needed. |
js | the pointer to the jsCtx object. |
msg | the pointer to the natsMsg object to send. |
opts | the publish options, possibly NULL . |
errCode | the location where to store the JetStream specific error code, or NULL if not needed. |
NATS_EXTERN void jsPubAck_Destroy | ( | jsPubAck * | pubAck | ) |
Releases memory allocated for this publish acknowledgment object.
pubAck | the jsPubAck object to destroy. |
NATS_EXTERN natsStatus js_PublishAsync | ( | jsCtx * | js, |
const char * | subj, | ||
const void * | data, | ||
int | dataLen, | ||
jsPubOptions * | opts | ||
) |
See js_PublishMsgAsync for details.
js | the pointer to the jsCtx object. |
subj | the subject the data is sent to. |
data | the data to be sent, can be NULL . |
dataLen | the length of the data to be sent. |
opts | the publish options, possibly NULL . |
NATS_EXTERN natsStatus js_PublishMsgAsync | ( | jsCtx * | js, |
natsMsg ** | msg, | ||
jsPubOptions * | opts | ||
) |
Publishes a message asynchronously to JetStream. User can call js_PublishAsyncComplete to be notified when all publish acknowledgments for the pending publish calls have been received.
NULL
.js | the pointer to the jsCtx object. |
msg | the memory location where the pointer to the natsMsg object is located. If the library takes ownership of the message, this location will be cleared so a following call to natsMsg_Destroy would have no effect. |
opts | the publish options, possibly NULL . |
NATS_EXTERN natsStatus js_PublishAsyncComplete | ( | jsCtx * | js, |
jsPubOptions * | opts | ||
) |
This call will block until the library has received acknowledgment for all outstanding published messages.
To limit the wait, user can pass a jsPubOptions with a MaxWait
set to the maximum number of milliseconds that the call should block.
js | the pointer to the jsCtx object. |
opts | the publish options, possibly NULL . |
NATS_EXTERN natsStatus js_PublishAsyncGetPendingList | ( | natsMsgList * | pending, |
jsCtx * | js | ||
) |
This call returns the list of all asynchronously published messages for which no acknowledgment have been received yet.
The user has now back ownership of the messages and can resend send if desired or simply destroy them.
pending | pointer to a natsMsgList object, typically defined on the stack. |
js | the pointer to the jsCtx object. |