How to generate a globally or universally unique id (UUID or GUID) in StreamBase

How to generate a globally or universally unique id (UUID or GUID) in StreamBase

book

Article ID: KB0076346

calendar_today

Updated On:

Products Versions
TIBCO Streaming -

Description

package com.sb.support; // change this to whatever you want import java.util.UUID;

public class UtilsUUID { // change this to whatever you want

public static String GenUUID() { // change this to whatever you want
return UUID.randomUUID().toString();
}
}

How to generate a globally unique id (GUID) or universally unique id (UUID) in StreamBase.

Issue/Introduction

How to generate a globally or universally unique id (UUID or GUID) in StreamBase

Resolution

As of StreamBase 7.5.1, there is a uuid() built-in StreamBase Expression Language function.

Prior to 7.5.1, there was no built-in StreamBase Expression Language function available, and you might implement your own Custom Java Function to generate a GUID using the process described below.

Implement a Custom Java Function that uses the Java UUID class:

As defined, the .java source lives in the project under..

<project>/java-src/com/sb/support/UtilsUUID.java

To use this function expression, for example, in a Map expression..
calljava("com.sb.support.UtilsUUID","GenUUID")

If you change the implementation package, class, or function name, you will need to update the calljava() arguments in the above expression.

For more details on creating Custom Java Functions, refer to the Help under StreamBase Documentation > API Guide > Developing StreamBase Custom Functions > Creating Custom Java Functions

When deploying, export the custom functions to a .jar and reference the .jar in your project's Build Path or the Server Configuration File (sbd.sbconf).