Chris C
Chris C

Reputation: 11

NIFI accessing Content Claim Identifier using Groovy

I need to generate a unique id each time my process runs. My process starts with GetSFTP processor.

I was thinking of using flowfile's Content Claim Identifier for this purpose.

How do access this using Groovy? Thanks in advance!

Flow File

Upvotes: 0

Views: 349

Answers (1)

Andy
Andy

Reputation: 14194

In general, you can depend on the flowfile uuid attribute being unique. Each flowfile in the system generates this on creation, so the flowfiles coming from GetSFTP will have this attribute populated and unique. To access the uuid attribute from Groovy (in a script or custom processor), use the code flowfile.uuid or flowfile.getAttribute('uuid').

The content claim identifier is definitely not unique -- it is a reference to a specific location on the file system (or other storage media if configured) referencing the content bytes of the flowfile. Many flowfiles can have the same content claim identifier.

You can also generate a unique identifier using the UUID() function in Apache NiFi Expression Language and put this in an attribute or content as needed using interpolation (i.e. ${UUID()}).

Upvotes: 2

Related Questions