EnableTransactionMode Method

Enables transaction mode for a channel.

Syntax

int EnableTransactionMode(const QString& qsChannelName);

Remarks

This method enables transaction mode for the channel with the given ChannelName.

While a channel is in transaction mode, all messages published and acknowledgements sent over it will be part of a transaction, and the server will wait to process them until the transaction is either committed or rolled back.

To commit the current transaction on a channel, call CommitTransaction; and to roll it back (and discard the messages and acknowledgements that were part of it), call RollbackTransaction.

Keep in mind that, according to the AMQP 0.9.1 specification:

  • A new transaction is always started immediately after committing or rolling back the current one, which means that...
  • ...a channel will stay in transaction mode, once enabled, until it is deleted.
  • Transactions are only guaranteed to be atomic if all messages published and acknowledgements sent affect a single queue.
  • Any messages published on a channel in transaction mode that have the Mandatory or Immediate flags set are not guaranteed to be included in the transaction.

An exception is thrown if no channel with the given ChannelName exists, or if EnablePublishConfirms has been called for the specified channel previously.

Error Handling

This method returns a result code; 0 indicates success, while a non-zero error code indicates that this method encountered an error during its execution. If an error occurs, the GetLastError() method can be called to retrieve the associated error message. (Note: This method's result code can also be obtained by calling the GetLastErrorCode() method after it returns.)

Copyright (c) 2022 /n software inc. - All rights reserved.
IPWorks IoT 2020 Qt Edition - Version 20.0 [Build 8265]