Products Downloads


French version


 


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 asynchronous message sending. For synchronous sending, see function VaToolBxAMQPSyncPublish.


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_CLASSE 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.

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:

    • contentType
    • contentEncoding
    • headers
    • deliveryMode
    • correlationId
    • replyTo
    • expiration
    • messageId
    • timestamp
    • type
    • userId
    • appId
    • clusterId
    • priority

See https://www.rabbitmq.com/publishers.html

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.



Example 1

REF_CLASS(MYCLASS) myInstance

myExchange = 'directExchangePrinting'

myRoutingKey = 'order_form'


* Publish a message in a direct-type exchange

CALL_DLL 'VaToolBx' 'VaToolBxAMQPPublish' 'myLogicalBroker' myExchange myRoutingKey myInstance *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"}'


* Publish a message (HTML document) with a content type and content encoding as metadata

CALL_DLL 'VaToolBx' 'VaToolBxAMQPPublish' 'myLogicalBroker' myExchange myRoutingKey myMessage myMessageARguments myReturnCode



Example 3

myMessage = 'Hello world!'

myRoutingKey = 'routeOne'


* Publish a message in the default exchange (direct type)

CALL_DLL 'VaToolBx' 'VaToolBxAMQPPublish' 'myLogicalBroker' *BLANK myRoutingKey myMessage *BLANK myReturnCode



Example 4

myExchange = 'topicExchangeMonitoringSensors'

myRoutingKey = 'bathroom.temperature'

myMessage = '21'


* Publish a message in a topic-type exchange

CALL_DLL 'VaToolBx' 'VaToolBxAMQPPublish' 'myLogicalBroker' myExchange myRoutingKey myMessage *BLANK myReturnCode



Example 5

myExchange = 'fanoutExchange'

myMessage = 'For all queues!'


* Publish a message in a fanout-type exchange: the routing key is not required

CALL_DLL 'VaToolBx' 'VaToolBxAMQPPublish' 'myLogicalBroker' myExchange *BLANK myMessage *BLANK myReturnCode



Example 6

myExchange = 'headersExchangeMonitoringSensors'

myMessageArguments = '{"headers": {"location": "bathroom", "sensor": "temperature"}}'

myMessage = '21'


* Publish a message in a header-type exchange The routing key is not used by the exchange. Only the key/value attributes of the message header metadata are taken into account.

CALL_DLL 'VaToolBx' 'VaToolBxAMQPPublish' 'myLogicalBroker' myExchange *BLANK myMessage myMessageArguments myReturnCode



List of VaToolBx DLL functions by theme


↑ Top of page



  • Aucune étiquette