Search code examples
uuidibm-integration-busextended-sql

IIB/ESQL: How to test if UUID is valid, if not generate one


I have a message flow in IBM Integration Bus.

I have some input that specifies a UUID, I want to test if that UUID is valid and if it is not I'd like to generate one.

Downstream if I call something like UUIDASCHAR I get a BIP2582 exception for (Invalid UUID).

DECLARE myUuid BLOB InputRoot.XMLNSC.someUUID
SET someUuidChar = UUIDASCHAR(myUuid); -- This throws exception if myUuid is invalid

I'm not sure how to tackle this in esql, this is the type of logic I'm looking for:

if (is_valid(uuid)) then
     set output_uuid = uuid
else
     set output_uuid = generated_uuid
end if

Thanks


Solution

  • You can put your validity check and UUID generation in 2 different ESQL files. Your first ESQL should call UUIDASCHAR normally, and Failure terminal of its compute node should be connected to compute node of second ESQL, which generates a new UUID.