deko

What is the maximum length for a String process variable in APS/Activiti?

Blog Post created by deko Employee on Sep 27, 2018

Hello community,

 

Today shall be the day, on which I am writing my first blog post here. Who am I actually? Well, I am Dennis Koch and am working as Expert Support Engineer for Alfresco. In support we often get questions or requests from customers and partners, where sometimes the answer should go out to a wider audience. So my idea is to share those questions and answers with you from time to time from now on, whereas I will directly start with this first post here.

 

Recently I had a customer asking the following:

 

While setting a String process variable in Alfresco Process Services (same counts for the Activiti engine), how long can the String value be?

 

So I started brainstorming:

 

I am not the designer/creator of Activiti, neither did I ever help in developing or architecting it. Still, there should be an easy way to find out the answer to this question. And while I was thinking about it, it came to my mind, that the limiting factor here can only be the database, where we store process variables and their values and a lot of other process related data.

 

Knowing, that process variables for a runtime process are stored in the database table ACT_RU_VARIABLE, I did some "reverse engineering" to find out which columns are created for this table by default and how they are defined and what they are used for. The most interesting columns to answer my customer´s question were "TYPE_" and "TEXT_".

 

When I created a String process variable with the value "Hello World", a row was created in the ACT_RU_VARIABLE table, whereas "TYPE_" was set to "string" and "TEXT_" was set to my actual String value, i.e. "Hello World". So I inspected how the "TEXT_" column is actually defined and learned, that it is limitted to 4000 characters. All I had to do next was to create some randome text with 4000 characters (there are online tools to do that, e.g. || Dummy Text Generator | Lorem ipsum for webdesigners || ) and see whether this text actually makes it into the table when I set the text as value for another String process variable. Indeed, this worked and I knew I could answer my customer´s question already.

 

But before I would answer, I wanted to find out how Alfresco Process Services actually handles the case, where someone tries to create a String process variable with more than 4000 characters. Would the system have issues, would the value be truncated or would I be able to break my instance at all? To find out, all I had to do was to extend my generated 4000 characters text by 2 more charcaters and set the new text as value for another String process variable.

 

Good news! I did not see any errors in my logs, nor did I seem to have broken my instance. Going back to the "ACT_RU_VARIABLE" table I saw, that in fact a new row was created for my new process variable, whereas this time the "TYPE_" value was set to "longString" and my "TEXT_" value was NULL.

 

Did we lose the 4002 characters text now without throwing any error?

 

No, with Alfresco systems there is no data loss of course!

 

Interestingly, the "ACT_RU_VARIABLE" table also has a column "BYTE_ARRAY_ID" and whereas this ID value was NULL for my String process variables with 4000 or less characters, it now had a value for my variable exceeding the 4000 characters limitation. The ID stored there is indeed referencing a row in the table "ACT_GE_BYTEARRAY", where my text is stored as byte array in the column "BYTES_". "BYTES_" is defined as VARBINARY(2147483647), which means we can store text with a size of 2147483647bytes. That should be long enough to store this blog post and the next one to come :-)

 

Be prepared to hear back from me soon...

 

- Dennis

Outcomes