I’d like to build a simple Java service which just generating UUID.
The service will be used by “Invoke IS service” policy in API Gateway, the response generated from the JavaService will be pass as one of request parameter to the target native API
I’d like to know how to start and where can i find the sample projects/code ?
Is there any way to build a 'IS service" without using “Designer”?
There is a built-in service available (link) for this, which you can wrap and use.
However, I had learnt that there is a chance of a duplicate in certain scenarios - I will let @Kalpesh_Shah1@John_Carter4 reaffirm this.
You can use pub.utils:generateUUID to generate the UDDI key. After generating the UDDI key you can set it to the headers/query etc before sending to native service by using the Invoke IS Service policy of API Gateway. You can refer Invoke webMethods IS policy in API Gateway 10.2 for how to achieve this.
@Venkata_Kasi_Viswanath_Mugada1 , pub.utils.utils:generateUUID services uses Java’s API UUID.randomUUID() under the cover and which would generate unique IDs and there is no known indications of duplicate generation of IDs.
Hi Kasi,
By cluster aware if you mean whether they are unique across a cluster , I don’t believe they wouldn’t be guaranteed to be unique although the probability of collision is extremely low.
Although an old thread , I believe it is still accurate - java.util.UUID.randomUUID unique across JVM — oracle-tech
@ivachung - I would recommend to use correlation id for this purpose instead of generating a UUID. its generated OOB by API Gateway and can be passed on to the backend native API.
@ivachung Yes as I already said you need Designer. Directly calling the “pub.utils.generateUUID” from API Gateway Invoke IS service policy will only set it in response but if you need to set it in headers you need to write a new IS Service as shown n below image and call that IS Service from your “Invoke IS Service” policy.
Another option is to use Request transformation policy to get the json path from your request body and set it in headers after you used Invoke IS Service to generate UUID and set it in body as you did. For details refer, Request and Response Transformation policies in API Gateway.
As Srikanth suggested, if your requirement is to not generate a new UUID key you can very well use correlation ID which is already unique for each request. You could use syntax ${correlationID} in Request Transformation policy to set it to your headers/query params etc. Same link given above contains the details of this.