IPWorks MQ 2020 Node.js Edition

Questions / Feedback?

ReceiveMode Property

Controls what mode new receiver links are created with.

Syntax

 amqp.getReceiveMode([callback])
 amqp.setReceiveMode( receiveMode, [callback])

Possible Values

  0 (rmAutomatic), 
  1 (rmFetch)

Default Value

0

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 the getReceiveMode([callback]) method is defined as:

function(err, data){ }

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

'data' is the value returned by the method.

The callback for the setReceiveMode([callback]) 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 property controls which receive mode newly created receiver links should use to receive messages from the sender. Valid values are:

  • rmAutomatic (0 - default)
  • rmFetch (1)

Receiving Messages Automatically

A receiver link operating in rmAutomatic (0) mode strives to ensure that the sender always has sufficient credit so that messages are received as soon as they are available, thus simulating a "subscription-based"/"push-based" messaging model.

In this mode, receiver links will be created with the amount of credit, and the credit threshold, specified by the DefaultCredit and DefaultCreditThreshold configuration settings. Anytime the link's credit reaches the credit threshold, the class will automatically set it back to its initial value.

Fetching Messages On-Demand

A receiver link operating in rmFetch (1) mode requires the FetchMessage method to be called in order for a message to be received, thus simulating a "polling"/"pull-based" messaging model.

In this mode, receiver links will be created with no credit (regardless of what DefaultCredit is set to). When FetchMessage is called, the class will supply the sender with a single credit and then block until a message is received (if the FetchTimeout property is set to zero).

If FetchTimeout is non-zero, the class will only block for the specified number of seconds; once that time expires, it will instruct the sender to consume the credit. If the sender chooses to consume the credit by incrementing the value of the LinkDeliveryCount property rather than by sending a message, then the class will throw an error indicating a timeout.

Refer to FetchMessage and FetchTimeout for more information.

amqp.ReceiveMode = AmqpReceiveModes.rmFetch;
amqp.CreateReceiverLink("SessionID", "ReceiverLinkName", "SomeTarget");

This property is not available at design time.

Data Type

Integer

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