This function is used to publish an Adelia variable as a message to a message broker supporting the AMQP v0.9.1 protocol. This API was validated with RabbitMQ open source message broker software (https://www.rabbitmq.com/).
This function is executed using a configuration file (in YAML format in Windows or Java environments, or in XML format in AS/400 environments), defining the detailed configuration of the handled Adelia logical broker.
This function is used to perform synchronous message sending. For asynchronous sending, see function VaToolBxAMQPPublish.
Note: In a Windows context, it is recommended for performance reasons to have the VaToolBx dll already loaded (LOAD_DLL instruction) before the first call to a VaToolBxAMQPxxxxxx function, and this dll must remain loaded when the subsequent VaToolBxAMQPxxxxxx functions are called.
Scope
Adelia Cloud client
Event Adelia client
Java server
Java client
Adelia Web client
- Windows client
- Windows server
- AS/400 server
Parameters
ALPHA(n) | AdeliaLogicalBroker | Adelia logical broker name. Its parameters (broker, port, etc.) are defined in the AdeliaLogicalBrokersConfig.yaml configuration file. |
ALPHA(n) | ExchangeName | Name of the exchange (message router) to send the message to. |
ALPHA(n) | RoutingKey | Routing key enabling the exchange to determine the queue(s) in which to put the message. |
IMAGE or ALPHA(n) or REF_CLASS (REF_CLASS only with Java runtime) |
Message | Message value to send to the broker. The sent value is a byte array. For ALPHA type, the string is encoded in UTF-8 if no encoding is defined in the MessageArguments parameter. For IMAGE type, the message value is the content without IMAGE variable conversion. In the case of REF_CLASS type, the message value is an alphanumeric string in JSON format (encoded in UTF-8) produced by the serialization of the REF_CLASS variable. |
BOOL | Mandatory | If this parameter is *TRUE, the message broker returns an error if the message has not been put in a queue (as no queue was associated with the routingKey). |
IMAGE or ALPHA | MessageArguments | Metadata used to specify the message to send. This parameter must be in JSON format in the form of an object. Its attributes can be:
|
NUM_BIN_2 | ReturnCode | Return code: 0: Successful execution. -1: The Message parameter is the wrong Adelia type. -2: The MessageArguments parameter is the wrong Adelia type. -3: The AdeliaLogicalBroker parameter must not be empty. -4: Error during syntax analysis of the MessageArguments parameter. -5: Error during the JSON transformation of the MessageArguments parameter. -6: Error when reading the MessageArguments parameter. -7: Error when encoding the Message parameter. -8: Error during the JSON serialization of the Message parameter. -9: Configuration not loaded. No logical broker defined (.YAML file not defined, found or loaded). -10: No configuration defined in the .YAML file for the specified Adelia logical broker. -11: Error when creating the message broker client. -12: Error when creating the entities (exchanges, queues, bindings) defined in the AdeliaLogicalBroker logical broker configuration. 1: Error while publishing the message. 2: Error while awaiting confirmation of receipt from the broker. 3: Error while routing a mandatory message (no connected destination queue). 4: Error when receiving a message (no confirmation from the broker). |
Example 1
REF_CLASS(MYCLASS) myInstance
myExchange = 'directExchangePrinting'
myRoutingKey = 'order_form'
CALL_DLL 'VaToolBx' 'VaToolBxAMQPSyncPublish' 'myLogicalBroker' myExchange myRoutingKey myInstance *TRUE *BLANK myReturnCode
Example 2
ALPHA(132) myMessage
myExchange = 'directExchangePrinting'
myRoutingKey = 'order_form'
myMessage = '<!DOCTYPE html><html><head><meta charset="ISO-8859-1"><title>Title of the document</title></head><body>Hello world!</body></html>'
myMessageARguments = '{"contentType":"text/html", "contentEncoding": "ISO-8859-1"}'
CALL_DLL 'VaToolBx' 'VaToolBxAMQPSyncPublish' 'myLogicalBroker' myExchange myRoutingKey myMessage *FALSE myMessageARguments myReturnCode
List of VaToolBx DLL functions by theme