IPWorks MQ 2020 Node.js Edition

Questions / Feedback?

EnableTransactionMode Method

Enables transaction mode for a channel.

Syntax

amqpclassic.enableTransactionMode(channelName, [callback])

Callback

The 'callback' parameter specifies a function which will be called when the operation completes (or an error is encountered). If the 'callback' parameter is not specified, then the method will block and will not return until the operation completes (or an error is encountered).

The callback for this method is defined as:

function(err){ }

'err' is the error that occurred. If there was no error, then 'err' is 'null'.

'err' has 2 properties which hold detailed information:

err.code
err.message

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.

Copyright (c) 2022 /n software inc. - All rights reserved.
IPWorks MQ 2020 Node.js Edition - Version 20.0 [Build 8155]