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

Showing results for 
Search instead for 
Did you mean: 

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

Established Member
5 2 6,262

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

Established Member II


Member II

Thanks for this information.

Unfortunately we have a case where this does not work. We have some texts which are form a richtextitem and therefore in HTML. So it can exeed in some cases the 4000 char limit.

When the user wants to go ahead in the process all the variables from the form are saved in the execution to be used later. 

Now if the field is more than 4000 chars the user gets the error, that the entry in ACT_HI_VARINST can't be createt because data would be truncated.

Is this a known issue with HTML? Or do we have to alter a setting? Or do we have to set the variable in a special way so it can go to the Byte Array if its to big?

We use activiti and MSSQL 2016 and above