Section for use
onError / onMessage
Syntax
In an onMessage section
BRK_GET_MSG <result variable> encoding
encoding | → | Null | *ENCODING(EncodingValue) |
EncodingValue | → | <AlphaConstant> | <AlphaVarId> |
BRK_GET_MSG AlphaPropertyName <result variable>
In an onError section
BRK_GET_MSG ErrorInfoType <result variable>
ErrorInfoType | → | *ERROR_CODE | *IMMED_STOP | * ERROR_MSG |
Description
In an onMessage section
This instruction retrieves information contained in the received message.
Retrieving a message's payload.
BRK_GET_MSG <result variable> <encoding>
When this instruction is called, the result variable receives the payload contained in the message. The variable type depends on the type of payload supported by the message broker.
Message broker | Native payload type | Compatible Adelia types |
---|
Kafka | Avro / Double / Integer / Long / Short / String / Byte array | ALPHA / IMAGE / REF_CLASS / NUM_E / NUM_P / NUM_BIN_2 / NUM_BIN_4 / NUM_BIN_8 |
Nats Jetstream | Byte array | ALPHA / IMAGE / REF_CLASS |
MQTT v3 | Byte array | ALPHA / IMAGE / REF_CLASS |
MQTT v5 | Byte array | ALPHA / IMAGE / REF_CLASS |
RabbitMQ AMQP | Byte array | ALPHA / IMAGE / REF_CLASS |
Redis Pub/Sub | Byte array/Alphanumeric | ALPHA / IMAGE / REF_CLASS |
REF_CLASS result variable:
If the result variable is REF_CLASS, we assume that the payload is JSON data (alphanumeric or byte array) encoded in UTF-8. JSON deserialization is applied to this data to populate the REF_CLASS variable.
Deserialization is based on the third-party Jackson converter: the converter's default properties can be modified by entering the customObjectMapper property of the Adelia subscriber.
ALPHA result variable and encoding:
If the result variable is ALPHA and the payload is a byte array, character encoding to be used when converting the byte array to an alphanumeric string can be specified. This encoding value must be included in the character set registry defined by the IANA. It must also be included in the character sets supported by the JVM.
When encoding is specified, the conversion is carried out according to the encoding value.
When no encoding is specified, the conversion rules vary according to the target broker and the properties of the message to process.
Message broker |
Conversion rule. |
Kafka |
The encoding used is the default encoding of the JVM executing the AMBSS. |
Nats Jetstream |
The encoding used is the default encoding of the JVM executing the AMBSS. |
MQTT v3 |
The encoding used is the default encoding of the JVM executing the AMBSS. |
MQTT v5 |
If the message's properties/payloadFormat property is true, UTF-8 encoding is used. If not, the encoding used is the default encoding of the JVM executing the AMBSS. |
RabbitMQ AMQP |
If the message has the basicProperties/contentEncoding property and it defines valid character encoding, this encoding is used. If not, the encoding used is the default encoding of the JVM executing the AMBSS. |
Redis Pub/Sub |
The encoding used is the default encoding of the JVM executing the AMBSS. |
Retrieving a property from a message
BRK_GET_MSG AlphaPropertyName <result variable>
This instruction is used to retrieve information about the message (apart from payload). Each item of information is defined by a key (AlphaPropertyName parameter) and has an associated typed value (result variable parameter).
The key can be defined either by an alphanumeric variable or by an alphanumeric literal. Its value represents an XPath expression and designates a native property of the message, so dependent upon the message broker associated with the Adelia subscriber.
Message from Kafka
|
Key value | Property description | Property type |
---|
offset | Position of the message in the associated Kafka partition. | NUM_BIN_8 |
topic | Name of the topic the message is from. | ALPHA(n) |
partition | Partition the message is received from. | ALPHA(n) |
key | Key associated with the message (this key may not exist if the issuer has not associated a key with the message). | ALPHA / IMAGE / REF_CLASS / NUM_E / NUM_P / NUM_BIN_2 / NUM_BIN_4 / NUM_BIN_8 |
timestamp | Message timestamp. | NUM_BIN_8 / TIMESTAMP |
firstPolled | When the ackMode property is "MANUAL" or "MANUAL_IMMEDIATE" and the typeMsgHandling property is "BATCH", this key indicates if the message is the first message in the batch to handle. | BOOL |
lastPolled | When the ackMode property is "MANUAL" or "MANUAL_IMMEDIATE" and the typeMsgHandling property is "BATCH", this key indicates if the message is the last message in the batch to handle. | BOOL |
headers/keys | List of <key, value> pair keys included in the message header. | ALPHA(n) array |
headers/values | List of <key, value> pair keys included in the message header. The native value type is a byte array. | ALPHA / IMAGE / REF_CLASS |
Message from MQTT v3
Message from MQTT v3
|
Key value | Property description | Property type |
---|
topic | Name of the topic the message is from. | ALPHA(n) |
id | Message ID. | NUM_BIN_4 |
duplicate | Specifies whether or not this message can be a duplicate of a message already received. | BOOL |
retained | Returns whether or not this message has been retained by the broker. Specifies whether or not the message came from a running issuer or if it was "retained" by the broker as the last message published on the topic. | BOOL |
qos | Returns the quality of service associated with the message (value 0, 1 or 2). | NUM_BIN_4 |
Message from MQTT v5
Message from MQTT v5
|
Key value | Property description | Property type |
---|
topic | Name of the topic the message is from. | ALPHA(n) |
id | Message ID. | NUM_BIN_4 |
duplicate | Specifies whether or not this message can be a duplicate of a message already received. | BOOL |
retained | Returns whether or not this message has been retained by the broker. Specifies whether or not the message came from a running issuer or if it was "retained" by the broker as the last message published on the topic. | BOOL |
qos | Returns the quality of service associated with the message (value 0, 1 or 2). | NUM_BIN_4 |
properties |
properties | Message properties. | N / A |
properties/validProperties | List of the numbers of message properties defined for this message (see MqttProperties Java class). | NUM_BIN_2 array |
properties/assignedClientIdentifier | Assigned client identifier (property number 18). | ALPHA(n) |
properties/contentType | Message content type (property number 3). | ALPHA(n) |
properties/correlationData | Correlation data (property number 9). | IMAGE |
properties/payloadFormat | Message payload format (property number 1). If the value is true, the payload represents a character string encoded in UTF-8. If the value is false, the payload is raw data without a format (byte array). | BOOL |
properties/messageExpiryInterval | Message expiry interval (property number 2). This value corresponds to the message lifespan in seconds. If the message expiry interval has passed and the broker has not managed to start delivery to a corresponding subscriber, it must delete the copy of the message for this subscriber. | NUM_BIN_8 |
properties/responseTopic | Name of topic for a response message (property number 8). | ALPHA(n) |
properties/subscriptionIdentifier | Subscriber identifier (property number 11). | NUM_BIN_4 |
properties/topicAlias | Message topic alias (property number 35). | NUM_BIN_4 |
properties/userProperties | User properties (property number 38). List of <key, value> alphanumeric pairs. These properties can be used to provide additional information to the broker or client, including diagnostic information. | N / A |
adelUtils:collectionSize(properties/userProperties) | Size of user properties list. | NUM_BIN_4 |
properties/userProperties[<index starting at 1>]/key | <index> index pair key field value in the user properties list. | ALPHA(n) |
properties/userProperties[<index starting at 1>]/value | <index> index pair value field value in the user properties list. | ALPHA(n) |
Message from Nats Jetstream
Message from Nats Jetstream
|
Key value | Property description | Property type |
---|
jetStream | Check if the message is from Jetstream or if it is a standard message (returns yes if the message is from Jetstream).
| BOOL |
sid | ID associated with the subscription, used by the connection when handling an incoming message from the broker. | ALPHA(n) |
utf8mode | Specifies if the message subject is encoded in UTF-8. | BOOL |
hasHeaders | Checks if the message contains header properties (returns true if the message contains them). | BOOL |
subject | Subject to which the message was sent. | ALPHA(n) |
replyTo | Subject to which the application is supposed to send a reply message. | ALPHA(n) |
headers |
headers | Key/values cross-reference table associated with the message. A key is alphanumeric type and the value is an alphanumeric list. | N / A |
headers/size | Size of the key/values cross-reference table associated with the message (corresponds to the number of table entries). | NUM_BIN_4 |
headers/empty | Specifies if the key/values cross-reference table associated with the message is empty (size 0). | BOOL |
headers/keySet | Returns the list of keys (corresponding to the entries in the key/values cross-reference table associated with the message). | ALPHA(n) array |
headers/keySet[<index starting at 1>] | Returns the <index> index key value in the key list. | ALPHA(n) |
headers/entrySet | Returns the list of <key, value> pairs included in the key/values cross-reference table associated with the message. | N / A |
headers/entrySet[<index starting at 1]/key | Returns the value of the key associated with the <index> index pair in the list of <key, value> pairs. | ALPHA(n) |
headers/entrySet[<index starting at 1]/value | Returns the value of the value field associated with the <index> index pair in the list of <key, value> pairs. | ALPHA(n) array |
Message from RabbitMQ AMQP
Message from RabbitMQ AMQP
|
Key value | Property description | Property type |
---|
envelope |
envelope | Message envelope. | N / A |
envelope/exchange | Name of exchange associated with the message. | ALPHA(n) |
envelope/redeliver | Specifies if the message is redelivered. | BOOL |
envelope/routingKey | Routing key associated with the message. | ALPHA(n) |
basicProperties |
basicProperties | Message properties. | N / A |
basicProperties/contentType | Message payload content type. | ALPHA(n) |
basicProperties/contentEncoding | Message payload content encoding. | ALPHA(n) |
basicProperties/deliveryMode | Message delivery mode (persistent message or not). Value 1 indicates that this message is only stored in memory; value 2 indicates that it is stored on a disk. | NUM_BIN_4 |
basicProperties/priority | Message priority in the associated queue. | NUM_BIN_4 |
basicProperties/correlationId | Message correlation ID. | ALPHA(n) |
basicProperties/replyTo | Name of the queue to use to reply to the message. | ALPHA(n) |
basicProperties/expiration | Message lifespan in milliseconds. | ALPHA(n) |
basicProperties/messageId | Message application ID. | ALPHA(n) |
basicProperties/timestamp | Message application timestamp. | TIMESTAMP / TIME / DATE |
basicProperties/type | Message application type. | ALPHA(n) |
basicProperties/userId | ID of user who published the message. | ALPHA(n) |
basicProperties/appId | ID of application that published the message. | ALPHA(n) |
Message from Redis Pub/Sub
In an onError section
This instruction retrieves information relating to the error during processing.
ErrorInfoType | Property description | Property type |
---|
*ERROR_CODE | Error number | NUM_BIN_4 |
*IMMED_STOP | Specifies if the error will stop the subscriber (and trigger the execution of the onStop section). | BOOL |
*ERROR_MSG | Error message | ALPHA(n) |
The error depends on the execution context and therefore the broker (and the associated factory).
Specific Kafka errors
Specific Kafka errors |
Error number | Error message | Immediate stop |
---|
-401 | Error when creating the topic pattern. | Yes |
-403 | Error when handling the ON_START event: negative acknowledgment sent. | Yes |
-501 | Error when converting an Avro pojo to an Adelia pojo. | No |
Specific MQTT v3 errors
Specific MQTT v3 errors
|
Error number | Error message | Immediate stop |
---|
-401 | Error when creating Paho MQTTv3 connection options based on the broker connection configuration. | Yes |
-402 | Error when creating the Paho MQTTv3 client using the options. | Yes |
-403 | Error when connecting the Paho MQTTv3 client to the broker. | Yes |
-404 | Error when subscribing the Paho MQTTv3 client to the topics. | Yes |
-406 | Error when handling the ON_START event: negative acknowledgment sent. | Yes |
-501 | Broker connection lost. | Yes |
-502 | Error when force disconnecting the Paho MQTTv3 client. | Yes |
-503 | Error when closing the Paho MQTTv3 client. | Yes |
Specific MQTT v5 errors
Specific MQTT v5 errors
|
Error number | Error message | Immediate stop |
---|
-401 | Error when creating Paho MQTTv5 connection options based on the broker connection configuration. | Yes |
-402 | Error when creating the Paho MQTTv5 client using the options. | Yes |
-403 | Error when connecting the Paho MQTTv5 client to the broker. | Yes |
-404 | Error when subscribing the Paho MQTTv5 client to the topics. | Yes |
-406 | Error when handling the ON_START event: negative acknowledgment sent. | Yes |
-501 | Broker connection lost. | Yes |
-502 | Error when force disconnecting the Paho MQTTv5 client. | Yes |
-503 | Error when closing the Paho MQTTv5 client. | Yes |
Specific NATS JetStream errors
Specific NATS JetStream errors
|
Error number | Error message | Immediate stop |
---|
-401 | Error when creating NATS connection options based on the broker connection configuration. | Yes |
-402 | Error when creating the NATS connection using the connection options. | Yes |
-403 | Error when creating JetStream subscription options based on the topic subscription configuration. | Yes |
-404 | Error when creating the JetStream context. | Yes |
-405 | Error when creating JetStream context options based on the broker connection configuration. | Yes |
-406 | Error when subscribing to JetStream broker topics. | Yes |
-408 | Error when handling the ON_START event: negative acknowledgment sent. | Yes |
-501 | Error when unsubscribing from JetStream broker topics. | Yes |
-502 | Error when closing the NATS connection to the broker. | Yes |
Specific RabbitMQ AMQP errors
Specific RabbitMQ AMQP errors
|
Error number | Error message | Immediate stop |
---|
-401 | Error when configuring the SSL connection: key management exception for all operations concerning key management. | Yes |
-402 | Error when creating the AMQP connection. | Yes |
-403 | Error when creating the AMQP channel. | Yes |
-404 | Error when passively declaring the queue. | Yes |
-405 | Error when declaring the queue. | Yes |
-406 | Error during basic consumption in the queue. | Yes |
-407 | Error when calling channel.basicQos. | Yes |
-408 | Error when passively declaring the exchanger. | Yes |
-409 | Error when declaring the exchanger. | Yes |
-410 | Error when binding the queue. | Yes |
-412 | Error when handling the ON_START event: negative acknowledgment sent. | Yes |
-501 | Error when closing the channel. | Yes |
-502 | Error when closing the connection. | Yes |
-503 | Connection closure not initiated by the application. | Yes/No (after enabling automatic reconnection) |
-504 | The subscriber was cancelled by the broker. | Yes |
Specific Redis Pub/Sub errors
Specific Redis Pub/Sub errors
|
Error number | Error message | Immediate stop |
---|
-401 | Error when creating the Redis URI based on the broker connection configuration. | Yes |
-402 | Error when creating the ClientOptions/ClusterClientOptions options object based on the broker connection configuration. | Yes |
-403 | Error when creating the Pub/Sub connection to the Redis broker. | Yes |
-404 | Error when subscribing to broker channels and models. | Yes |
-406 | Error when handling the ON_START event: negative acknowledgment sent. | Yes |
-501 | Error when closing the connection to the Redis broker. | Yes |
-502 | Error when closing the Redis client. | Yes |
-503 | Lettuce Redis client closed due to loss of connection to the broker. | Yes |
-504 | Lettuce Redis client closed due to a communication error with the broker. | Yes |
After this instruction has been executed, the *RETURN_CODE reserved word can take the following values:
0 (*NORMAL) |
Operation completed successfully. |
-1 |
Internal error (no message or configuration). |
-2 |
Internal error (no error). |
-3 |
XPath syntax error when evaluating the Alpha PropertyName parameter. |
-4 |
The reserved word parameter is not known. |
-5 |
The key corresponds to information that does not exist or has no value. |
-11 |
The value associated with the key cannot be converted to Adelia type. |
-32 |
The result variable must be an ALPHA or REF_CLASS type variable. |
-33 |
The ALPHA result variable is too short. |
-53 |
The result variable must be a numeric variable. |
-54 |
The NUM_E/NUM_P result variable is too small. |
-55 |
The integer part of the NUM_E/NUM_P result variable is too small. |
-56 |
The decimal part of the NUM_E/NUM_P result variable is too small. |
-57 |
The result variable has a type which is incompatible with a numeric value. |
-58 |
The NUM_BIN_2 result variable is too small. |
-59 |
The NUM_BIN_4 result variable is too small. |
-60 |
The NUM_BIN_8 result variable is too small. |
-61 |
The value associated with the key cannot be converted to TIMESTAMP type. |
-74 |
The result variable must be a Boolean variable. |
-95 |
The result variable must be a DATE, TIME or TIMESTAMP variable. |
-116 |
The result variable must be an IMAGE variable. |
-117 |
The value associated with the key cannot be converted to a byte array. |
-137 |
The resulting variable must be a REF_CLASS variable. |
-138 |
The value associated with the key cannot be converted to an Adelia class. |
-300 |
The result variable must be an array variable. |
-301 |
The result variable must be a one-dimensional array variable. |
-302 |
The array result variable is too small. |
-303 |
The combo box items have a type that cannot be converted to a numerical value. |
-304 |
The combo box items have a type that cannot be converted to an alphanumeric value. |
-305 |
The combo box items have a type that cannot be converted to a Boolean value. |
-306 |
The combo box items have a type that cannot be converted to an image value. |
-307 |
The combo box items have a type that cannot be converted to an Adelia class value. |
-308 |
The result variable type is not supported. |
-309 |
The key's combo box items have a type that cannot be converted to a date/time/timestamp value. |
-332 |
The result array variable must be ALPHA or REF_CLASS type. |
-333 |
The alphanumeric length of the ALPHA result array variable is too short. |
-353 |
The result array variable must be numeric. |
-354 |
The NUM_E/NUM_P result array variable defines numerics that are too small. |
-355 |
The NUM_E/NUM_P result array variable defines numerics with an integer part that is too small. |
-356 |
The NUM_E/NUM_P result array variable defines numerics with a decimal part that is too small. |
-357 |
The combo box items have a type that cannot be converted to a numerical value. |
-358 |
The NUM_BIN_2 result array variable defines integers that are too small. |
-359 |
The NUM_BIN_4 result array variable defines integers that are too small. |
-360 |
The NUM_BIN_8 result array variable defines integers that are too small. |
-361 |
The key's combo box items have a value that cannot be converted to TIMESTAMP type. |
-374 |
The result array variable must be Boolean type. |
-395 |
The result array variable must be date, time or timestamp type. |
-416 |
The result array variable must be image type. |
-417 |
The key's combo box items have a type that cannot be converted to a byte array. |
-437 |
The result array variable must be REF_CLASS type. |
-438 |
The key's combo box items have a type that cannot be converted to an Adelia class. |
-600 |
The value associated with the key cannot be converted to Adelia type. |
-621 |
The alphanumeric value associated with the key cannot be deserialized to an Adelia class. |
-642 |
The numeric value associated with the key cannot be converted to Adelia numeric type. |
-705 |
Error when retrieving the byte array from a ByteBuffer instance. |
-706 |
The ByteBuffer instance has no accessible byte array. |
-707 |
The byte array value associated with the key cannot be deserialized to an Adelia class. |
-708 |
Invalid character encoding. |
-709 |
Error when converting the payload to an alphanumeric string. |
-900 |
The value associated with the key cannot be converted to Adelia type. |
-1521 |
The alphanumeric value associated with the key cannot be deserialized to an Adelia class. |
-1542 |
The numeric value associated with the key cannot be converted to Adelia numeric type. |
-1605 |
Error when retrieving the byte array from a ByteBuffer instance. |
-1606 |
The ByteBuffer instance has no accessible byte array. |
-1607 |
The byte array value associated with the key cannot be deserialized to an Adelia class. |
-1608 |
Character encoding is invalid for converting the byte array. |
-1609 |
Error when converting a byte array value to an alphanumeric string. |
For example
* Payload retrieved in the form of an Adelia class (onMessage)
REF_CLASS(COMMAND_ORDER) myCommand
BRK_GET_MSG myCommand
* Topic retrieved from a Kafka message (onMessage)
ALPHA(10) msgTopic
BRK_GET_MSG 'topic' msgTopic
* Error code retrieved (onError)
NUM_BIN_4 ambssError
BRK_GET_MSG ERROR_CODE ambssError
↑ Top of page