This function is used to create an exchange (a message routing entity) in 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.
An exchange is defined by a unique name. Therefore, two exchanges with the same name but different characteristics cannot be created.
Scope
Cloud client
Java server
Java client
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) |
ExchangeType |
Exchange type. Value from "direct", "fanout", "topic" or "headers". |
BOOL | Durable | A durable exchange is automatically recreated when the message broker restarts. |
BOOL | AutoDelete | An auto-delete exchange is deleted when the last queue is no longer connected to it. |
BOOL | Internal | An internal exchange cannot be directly addressed by a message broker client but can be addressed by another exchange when it is connected to it. |
IMAGE or ALPHA | ExchangeArguments | Additional parameters used to specify the exchange to be created. This parameter must be in JSON format in the form of an object. Its attributes can be:
|
IMAGE or ALPHA | ExchangeBinding | Information about the binding between this exchange and other exchanges. This parameter must be in JSON format in the form of an object list. Each object represents a configuration for the binding between this exchange (source exchange) and another exchange (destination exchange). Its attributes can be:
See https://www.rabbitmq.com/e2e.html, https://www.rabbitmq.com/blog/2010/10/19/exchange-to-exchange-bindings/ |
NUM_BIN_2 | ReturnCode | Return code: 0: Successful execution. -1: The ExchangeArguments parameter is the wrong Adelia type. -2: The ExchangeBinding parameter is the wrong Adelia type. -3: The AdeliaLogicalBroker parameter must not be empty. -4: The ExchangeName parameter must not be empty. -5: ExchangeType value not supported. -6: Error during syntax analysis of the ExchangeArguments parameter. -7: Error during the JSON transformation of the ExchangeArguments parameter. -8: Error when reading the ExchangeArguments parameter. -9: Error during syntax analysis of the ExchangeBinding parameter. -10: Error during the JSON transformation of the ExchangeBinding parameter. -11: Error when reading the ExchangeBinding parameter. -12: Configuration not loaded. No logical broker defined (.YAML file not defined, found or loaded). -13: No configuration defined in the .YAML file for the specified Adelia logical broker. -14: Error when creating the message broker client. -15: Error when creating the entities (exchanges, queues, bindings) defined in the AdeliaLogicalBroker logical broker configuration. 30: Error when declaring the exchange in the message broker. 60: Error when declaring bindings between this exchange and other exchanges. |
Example 1
myExchange = 'directExchange'
myExchangeType = 'direct'
* Creation of a direct, non-durable, non-internal exchange with automatic deletion
CALL_DLL 'VaToolBx' 'VaToolBxAMQCreateExchange' 'myLogicalBroker' myExchange myExchangeType *FALSE *TRUE *FALSE *BLANK *BLANK myReturnCode
Example 2
myExchange = 'headersExchange1'
myExchangeType = 'headers'
myExchangeBinding = '[{"exchangeDest": "headersExchange2", "arguments": {"x-match": "all", "propHeader1": "value1", "propHeader2": "value2"}}]'
* Creation of a headers-type exchange connected to the headersExchange2 exchange using all the propHeader1 and propHeader2 attributes as a routing key
CALL_DLL 'VaToolBx' 'VaToolBxAMQPCreateExchange' 'myLogicalBroker' myExchange myExchangeType *FALSE *TRUE *FALSE *BLANK myExchangeBinding myReturnCode
List of VaToolBx DLL functions by theme ↑ Top of page