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 | stanSubscription_SetOnCompleteCB (stanSubscription *sub, natsOnCompleteCB cb, void *closure) |
Sets a completion callback. More... | |
NATS_EXTERN natsStatus | stanSubscription_AckMsg (stanSubscription *sub, stanMsg *msg) |
Acknowledge a message. More... | |
NATS_EXTERN natsStatus | stanSubscription_Unsubscribe (stanSubscription *sub) |
Permanently remove a subscription. More... | |
NATS_EXTERN natsStatus | stanSubscription_Close (stanSubscription *sub) |
Closes the subscription. More... | |
NATS_EXTERN void | stanSubscription_Destroy (stanSubscription *sub) |
Destroys the subscription. More... | |
NATS Streaming Subscriptions.
NATS_EXTERN natsStatus stanSubscription_SetOnCompleteCB | ( | stanSubscription * | sub, |
natsOnCompleteCB | cb, | ||
void * | closure | ||
) |
In order to make sure that an asynchronous subscription's message handler is no longer invoked once the subscription is closed (or unsubscribed) (stanSubscription_Close, stanSubscription_Unsubscribe), the subscription should be closed from the message handler itslef.
If the application closes the subscription from a different thread and immediately frees resources needed in the message handler, there is a risk of a crash since the subscription's message handler may still be invoked one last time or already in the process of executing.
To address this, the user can set a callback that will be invoked after the subscription is closed and the message handler has returned.
sub | the pointer to the stanSubscription object |
cb | the callback to invoke when the last message of a closed subscription has been dispatched |
closure | the pointer to a user defined object (possibly NULL ) that will be passed to the callback |
NATS_EXTERN natsStatus stanSubscription_AckMsg | ( | stanSubscription * | sub, |
stanMsg * | msg | ||
) |
If the subscription is created with manual acknowledgment mode (see stanSubOptions_SetManualAckMode) then it is the user responsibility to acknowledge received messages when appropriate.
sub | the pointer to the stanSubscription object. |
msg | the message to acknowledge. |
NATS_EXTERN natsStatus stanSubscription_Unsubscribe | ( | stanSubscription * | sub | ) |
Removes interest on the channel. The subscription may still have a callback in progress, in that case, the subscription will still be valid until the callback returns.
For non-durable subscriptions, stanSubscription_Unsubscribe and stanSubscription_Close have the same effect.
For durable subscriptions, calling this function causes the server to remove the durable subscription (instead of simply suspending it). It means that once this call is made, calling stanConnection_Subscribe() with the same durable name creates a brand new durable subscription, instead of simply resuming delivery.
sub | the pointer to the stanSubscription object. |
NATS_EXTERN natsStatus stanSubscription_Close | ( | stanSubscription * | sub | ) |
Similar to stanSubscription_Unsubscribe() except that durable interest is not removed in the server. The durable subscription can therefore be resumed.
sub | the pointer to the stanSubscription object. |
NATS_EXTERN void stanSubscription_Destroy | ( | stanSubscription * | sub | ) |
Destroys the subscription object, freeing up memory. If not already done, this call will removes interest on the subject.
sub | the pointer to the stanSubscription object to destroy. |