<trclass="memdesc:ga7b039908ec45cfc2c16ec61ba8daca9d"><tdclass="mdescLeft"> </td><tdclass="mdescRight">Sets a completion callback. <br/></td></tr>
<trclass="memdesc:gafa428a7e0f6800216cb06fd738bd235e"><tdclass="mdescLeft"> </td><tdclass="mdescRight">Permanently remove a subscription. <br/></td></tr>
<p>In order to make sure that an asynchronous subscription's message handler is no longer invoked once the subscription is closed (or unsubscribed) (<aclass="el"href="group__stan_sub_group.html#gacfa3a7b4fa333c84acfa7521fbbb5bcc"title="Closes the subscription.">stanSubscription_Close</a>, <aclass="el"href="group__stan_sub_group.html#gafa428a7e0f6800216cb06fd738bd235e"title="Permanently remove a subscription.">stanSubscription_Unsubscribe</a>), the subscription should be closed from the message handler itslef.</p>
<p>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.</p>
<p>To address this, the user can set a callback that will be invoked after the subscription is closed and the message handler has returned.</p>
<dlclass="section note"><dt>Note</dt><dd>You don't need to call this function if you are not freeing resources needed in the message handler or if you always close the subscription from the message handler itself.</dd></dl>
<dlclass="section see"><dt>See also</dt><dd><aclass="el"href="group__callbacks_group.html#ga245131e64f1d0dff7edc8ed874a07e9a"title="Callback used to notify that an object lifecycle is complete.">natsOnCompleteCB</a></dd></dl>
<dlclass="params"><dt>Parameters</dt><dd>
<tableclass="params">
<tr><tdclass="paramname">sub</td><td>the pointer to the <aclass="el"href="group__types_group.html#gae4dae869fb614536f0f027c2e2660cc5"title="Interest on a given channel.">stanSubscription</a> object </td></tr>
<tr><tdclass="paramname">cb</td><td>the callback to invoke when the last message of a closed subscription has been dispatched </td></tr>
<tr><tdclass="paramname">closure</td><td>the pointer to a user defined object (possibly <code>NULL</code>) that will be passed to the callback </td></tr>
<p>If the subscription is created with manual acknowledgment mode (see <aclass="el"href="group__stan_sub_opts_group.html#ga6f49ae2629e49d2bfa35990cf030bf83"title="Sets the subscription's acknowledgment mode.">stanSubOptions_SetManualAckMode</a>) then it is the user responsibility to acknowledge received messages when appropriate.</p>
<dlclass="params"><dt>Parameters</dt><dd>
<tableclass="params">
<tr><tdclass="paramname">sub</td><td>the pointer to the <aclass="el"href="group__types_group.html#gae4dae869fb614536f0f027c2e2660cc5"title="Interest on a given channel.">stanSubscription</a> object. </td></tr>
<tr><tdclass="paramname">msg</td><td>the message to acknowledge. </td></tr>
<p>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.</p>
<p>For non-durable subscriptions, <aclass="el"href="group__stan_sub_group.html#gafa428a7e0f6800216cb06fd738bd235e"title="Permanently remove a subscription.">stanSubscription_Unsubscribe</a> and <aclass="el"href="group__stan_sub_group.html#gacfa3a7b4fa333c84acfa7521fbbb5bcc"title="Closes the subscription.">stanSubscription_Close</a> have the same effect.</p>
<p>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 <aclass="el"href="group__stan_conn_sub_group.html#gae545358fdc493baf6d29429a8156781f"title="Creates a subscription.">stanConnection_Subscribe()</a> with the same durable name creates a brand new durable subscription, instead of simply resuming delivery.</p>
<dlclass="section warning"><dt>Warning</dt><dd>See warning about connecting to a NATS Server v2.2.0+ in <aclass="el"href="group__stan_conn_mgt_group.html#ga35e0e6e5e3b7f3818a3ac3600efb8f8f"title="Connects to a NATS Streaming Server using the provided options.">stanConnection_Connect()</a>.</dd></dl>
<dlclass="params"><dt>Parameters</dt><dd>
<tableclass="params">
<tr><tdclass="paramname">sub</td><td>the pointer to the <aclass="el"href="group__types_group.html#gae4dae869fb614536f0f027c2e2660cc5"title="Interest on a given channel.">stanSubscription</a> object. </td></tr>
<p>Similar to <aclass="el"href="group__stan_sub_group.html#gafa428a7e0f6800216cb06fd738bd235e"title="Permanently remove a subscription.">stanSubscription_Unsubscribe()</a> except that durable interest is not removed in the server. The durable subscription can therefore be resumed.</p>
<dlclass="section warning"><dt>Warning</dt><dd>See warning about connecting to a NATS Server v2.2.0+ in <aclass="el"href="group__stan_conn_mgt_group.html#ga35e0e6e5e3b7f3818a3ac3600efb8f8f"title="Connects to a NATS Streaming Server using the provided options.">stanConnection_Connect()</a>.</dd></dl>
<dlclass="params"><dt>Parameters</dt><dd>
<tableclass="params">
<tr><tdclass="paramname">sub</td><td>the pointer to the <aclass="el"href="group__types_group.html#gae4dae869fb614536f0f027c2e2660cc5"title="Interest on a given channel.">stanSubscription</a> object. </td></tr>
<p>Destroys the subscription object, freeing up memory. If not already done, this call will removes interest on the subject.</p>
<dlclass="params"><dt>Parameters</dt><dd>
<tableclass="params">
<tr><tdclass="paramname">sub</td><td>the pointer to the <aclass="el"href="group__types_group.html#gae4dae869fb614536f0f027c2e2660cc5"title="Interest on a given channel.">stanSubscription</a> object to destroy. </td></tr>
</table>
</dd>
</dl>
</div>
</div>
</div><!-- contents -->
</div><!-- doc-content -->
<!-- HTML footer for doxygen 1.8.10-->
<!-- start footer part -->
<divid="nav-path"class="navpath"><!-- id is needed for treeview function! -->
<ul>
<liclass="footer">NATS.IO Supported By Synadia Communications Inc.