Activiti : Looking Back At 2014

Our general manager (aka “my boss”), Paul Holmes-Higgin has noted down his thoughts about the past year about Activiti.

You can read it here : Alfresco Activiti Shakes BPM World

Adding my own personal thoughts: 2014 was awesome! We did *a lot* of work on Activiti. Countless of hours spent brainstorming and hacking away … but it was worth it. I’m really, really proud of what we’ve done and what we’re doing. I’m really proud when I see what Activiti users and customers all around the globe are doing with the stuff we come up with. And we get to see some really awesome stuff too.

And there is no way we’re slowing down. 2015 is going to be huge. We’ve got some really cool things in the pipeline. Watch my blog for more news about some of it soon …

All the best for 2015!

Joram

Well worth reading

I hardly post link to other blogs here, but I felt that this deserved more attention than a regular tweet:

Future of Programming – Rise of the Scientific Programmer (and fall of the craftsman)

Many of the ideas written there resonate very well with me and are similar to what I’ve been pondering about and saying recently.

We’re spending our time bickering about frameworks and cool development things and we hardly spent time with what we could do with the (huge amount of) data our software produces and how it could be used to improve the day to day work of people.

Some nice quotes from the article:

 I think TDD and agile has given us a safety net that as a tightrope walker, instead of focusing on our walking technique, we improve the safety net. As long as we do the motions, we are safe. Unit tests, coverage, planning poker, retrospective, definition of done, Story, task, creating tickets, moving tickets. How many bad programmers have you seen that are masters of agile?

We got to grow up and go back to school, relearn all about Maths, statistics, and generally scientific reasoning. We need to man up and re-learn that being a good coder has nothing to do with the number of stickers you have at the back of your Mac.

Food for thought.

Activiti + Spring Boot docs and example

With the Activiti 5.17.0 release going out any minute now, one of the things we did was writing down documentation on how to use this release together with Spring Boot. If you missed it, me and my Spring friend Josh Long did a webinar a while ago about this.

spring-boot-project-logoYou can find the new docs already on github master (scroll down to ‘Spring Boot’ section): https://github.com/Activiti/Activiti/blob/master/userguide/src/en/ch05-Spring.adoc#spring-boot. You can also see we switched to Asciidoc for our docs a couple of weeks ago. And GitHub renders that natively, which is awesome.

While I was writing the documentation, I created a sample application to verify all the stuff in there actually works.  You can find that example here: https://github.com/jbarrez/spring-boot-activiti-example. It has tags for each of the steps (which match the steps in the docs). So to start, checkout tag step-1 and so forth.

This is the first ‘official’ release of the integration (it was in snapshot versions before), so do give it a spin and let us know what you think about it!

 

How to create an Activiti pull request

Once every while, the question on how to create a pull request for Activiti is asked in our Forum. It isn’t hard to do, but specially for people that don’t know git it can be daunting.

So, I created a short movie that shows you how easy it is and what you need to do to:

 

Looking forward to your awesome fixes and features in a pull request!

 

Edit: Zoltan Alfattar mentioned to me on Skype there is a better way using branches:

altfatterz
@jbarrez Nice, however creating separate branch would be the better https://t.co/nco8rRZlk3
05/11/14 15:06

With which I agree fully. However, for people who are new to Git, it might be too complex to grasp. But surely have a look at the link if you are interested in doing it in the ‘proper’ way.

Model your BPMN 2.0 processes in the Activiti Cloud

Last month, we’ve released our very first version of our cloud offering around Activiti. If you missed it, there’s a short press release here (scroll to section about Activiti). Doing it as a cloud-first release has provided us with very good feedback. Not only on the deployment and setup side, but also from partners and potential customers who can easily play around with it.

As mentioned in the press release, all of this will be available on premise in a couple of weeks from now (if all goes according to plan and we keep appeasing the software development gods, which up till now seems to be the case!).

One of the cool things you can do in the Activiti Cloud is model your BPMN 2.0 processes in our completely rewritten web modeler. There are obviously many other cool things to do, but let me get back to those in later blogposts. The only thing you need to do to create BPMN 2.0 processes, which are fully ready to run on the Activiti engine, is to create an account on https://activiti.alfresco.com. With such an account, you can model BPMN 2.0 processes without any limitation. Anyone can do it, no strings attached.

I uploaded a movie to Youtube showing how easy it is:

Of course, as one needs bread on the table, there are also options if you want that something more (eg. the analytics,  options for apps, etc), you want this on-premise (with cool stuff such as LDAP integration and all that stuff you want on premise) or you are looking for support on the Activiti Engine only. Anyway, contact Alfresco Sales if you think this is something you want!

 

My Five Rules for Remote Working

A couple of weeks ago, there was a stir (again) about remote working and its succes and/or failure: it was reported that Reddit, the website where many people lose countless of hours, were forcing all their employees to move to SF. After a similar thing happened at Yahoo last year it made me think about why remote work is such a huge success for us at Activiti and Alfresco.

You see, I’m a remote worker for more than five years now. First at Red Hat and then at Alfresco. I worked a couple of years as Java consultant before that, so I’ve seen my share of office environments (checking my Linkedin, it comes down to about 10 different office environments). I had to go to these offices each day.

Comparing those experiences, I can – without exaggeration – say that I’m way more productive nowadays, working from home. Many people (both in and outside IT) ask me how I do it. They say “they couldn’t do it”. Maybe that’s true. Maybe some people need a lot of people around them. But for the kind of job I am into – developing software – I believe having a lot of people around me doesn’t aid me in writing higher quality software faster.

Anyway, like I said, I did some thinking around it and I came to the following “rules” which I have been following all these years which I believe are crucial (at least for me!) to making remote working a success.

dilbert_remote

(comic from http://www.dilbert.com/ )

Rule 1: The Door

Having a separate space to work is crucial when wanting do serious remote working. Mentally it is important that you can close “The Door” of your office space when you finished working. It brings some kind of closure to the working day.

Many people, when they work from home, put their laptop on let’s say the kitchen table. That doesn’t work. It is not a space that encourages work. There are distractions everywhere (kids that come home, food very close by, …). But most importantly, there is no distinction between when you are working and when you are not.

My wife and kids they know and understand that when The Door is closed, I’m at work. I can’t be disturbed until that Door opens. But when I close The Door in the evening and come downstairs, they also know that I’m fully available for them.

My door!

My door!

Rule 2: The Gear

The second rule is related to the first one: what to put in that room. The answer is simple: only the best. A huge desk, a big-ass 27″ monitor (or bigger), a comfortable chair (your ass spends a lot of time on it), the fastest internet you can buy, some quality speakers, a couple of cool posters and family pictures on the wall, ….

This is the room where you spend most of your time in the week, so you need to make it a place where you love to go to.

My setup

My setup

Often, I hear from people which company allows for remote work that their company should pay for all of this. I think that’s wrong. It’s a two-way street: your company gives you the choice, privilege and trust to work from home, so you from your side must take care that your home office isn’t decreasing anything compared to the office gear you have. Internet connection, chair and computer monitor are probably the most important bits here. If you try to be cheap on any of those, you’ll repay it in decreased productivity.

Rule 3: The Partner

Your partner is of utmost importance to make remote work a success. Don’t be fooled by the third place here, when your partner is not into it, all the other points are useless.

It’s pretty simple and comes down to one core agreement you need to make when working from home: when you are working from home you are not “at home”. When you work, there is no time for cleaning the house, doing the dishes, mowing the grass, etc … You are at work, and that needs to be seen as a full-time, serious thing. Your partner needs to understand that when you would do any of these things, it would be bad for your career.

Many people think this is easy, but I’ve seen many fail. A lot of people still see working from home as something that is not the same as “regular work”. They think you’ve got all the time in the world now. Wrong. Talk it through with your partner. If he/she doesn’t see it (or is jealous), don’t do it.

Rule 4: Communicate, communicate, communicate

More than a team in an office, you need to communicate. If you don’t communicate, you simply don’t exist.

At Activiti, we are skyping a lot during the day. We all know exactly what the other team members are currently doing. We have an informal agreement that we don’t announce a call typically. You just press the ‘call’ button and the other side has to pick it up and respond. It’s the only way remote work can work. Communicate often.

Also important: when you are away from your laptop, say it in a common chat window. There is nothing as damaging for remote workers as not picking up Skype/Phone for no reason.

Rule 5: Trust People

The last rule is crucial. Working remote is based on trust. Unlike in the office, there is no physical proof that you are actually working (although being physically in an office is not correlated with being productive!). You need to trust people that they do their job. But at the same time, don’t be afraid to check up on people’s work (for us, those are the commits) and ask the questions why something is taking longer than expected. Trust grows both ways.

The second part of this trust-story is that there needs to be trust from the company to the team. If that trust is missing, your team won’t be working remote for long. At Activiti, we are very lucky to have Paul Holmes Higgin as our manager. He is often in the office of Alfresco and makes sure that whatever we are doing is known to the company and vice versa. He attends many of the (online) meetings that happen company wide all the time so that we are free to code. There is nothing as bad for a remote team as working in isolation.

trust_fall

Conclusion

So those are my five (personal!) rules I follow when working from home. With all these bad press from the likes of Reddit and Yahoo, I thought it was time for some positive feedback. Remote work is perfect for me: it allows me to be very productive, while still being able to see my family a lot. Even though I put in a lot of hours every week, I’m still seeing my kids grow up every single day and I am there for them when they need me. And that is something priceless.

Does this sound cool to you? Well, at Alfresco we are still hiring people to work on Activiti!

Webinar ‘Process Driven Spring Applications with Activiti’ now on Youtube

As I mentioned, I did a webinar on Spring Boot + Activiti last week (at 6 am …. yes, it hurt) with my good pal Josh Long.

If you missed it, or want to see the awesomeness again, here’s the recording:

 

On a similar note, the webinar that Josh did before this one, on Spring Boot / Spring Cloud is *really* awesome. All this micro-service architecture stuff suddenly made a lot of sense and all the pieces of the puzzle fell together by watching this webinar. Go check it out (after the Activiti webinar, obviously ;-)), it’s well worth your time.

Upcoming Webinar: Process Driven Spring Applications with Activiti – Sept 23rd

oss-logo-spring

Next week, I’ll be doing a webinar together with my friend Josh Long (he’s a Spring Developer Advocate, committer to many open source projects and of course Activiti). I will show some of the new Activiti tooling we’ve been working on recently, while Josh will demonstrate with live coding how easy it is to use Activiti in Spring Boot (spoiler: really easy).

You can register for the webinar for free here: https://spring.io/blog/2014/07/29/webinar-process-driven-spring-applications-with-activiti-sept-23rd

One day later, the Alfresco Summit will be kicked off in San Francisco. I’m joining two talks there:

For those who can’t make it to San Francisco: don’t worry, we’ll be landing in London two weeks later, Oct 7-9!

Seriously reducing memory consumption when running multiple Activiti Engines on the same JVM

The Activiti Forum is a place where I typically try to spend every day a bit of time. Surely, it is hard work to keep up with the influx of posts (but then again it means that Activiti is popular, so I’m not complaining!) but sometimes you find a true gem amongst the posts.

On the Forum, user jkronegg (or Julien, as he signs his posts) has posted an interesting finding which I’d like to give some more attention here. His use case is running multiple Activiti Process Engines on the same JVM. Maybe for multi-tenancy (one engine for each customer?), but that’s not the point here.

As you can read in his post, he has a setup of 50 Activiti Process Engines in the same JVM. And, while Activiti uses very little memory, he was interested if it could be brought down. More specifically, after profiling, he found that for every Activiti Process Engine most of the memory was consumed by the Mybatis internal Configuration object (Activiti uses Mybatis as database access framework). Conceptually, this configuration objects holds a parsed version of the Mybatis mapping files. As jkronegg correctly analyses, this data is actually static: two process engines configured the same will basically duplicate this Mybatis sql mapping information.

So, to verify this claim, I wrote a simple console application that you can find on Github. This little application gives you 3 options: start a number of ‘regular’ Activiti process engines, start a number of engines with a ‘shared mybatis config’ (I’ll come back to this) and a last option to check if you can actually use the engines (ie. a process deploys and runs).

01

So, time to boot up some ‘regular’ Activiti Engines, let’s say we boot up 250 regular Activiti Engines. I also have a profiler running (simply VisualVM, shipped with every JDK) to see the memory consumption:

02

You can clearly see that the memory nicely gets filled to about 1.5-1.6 GB (still only about 6MB for each engine).

When we calculate the objects with the biggest retained sizes, we can see that jkronegg is correct: the Configuration instances of Mybatis do take up 98.9% of all used memory!

03

Now, let’s see what happens if we apply the changes described in the forum post. More specifically, there are two main culprits that account for most of the memory usage (see the post for more details). This is proven when we inspect one of the instances: two objects (sqlFragments and mappedStatements) take up most of the memory of a Configuration instance:

04

By setting the reference on a new Mybatis Configuration object using reflection, the static data effectively gets shared between all next engines that get booted up. I did make a small change to the Activiti engine to make this easier in the future (with the current version you need to copy and paste the whole block of initSqlSessionFactory).

See SharedMyBatisProcessEngineConfiguration on Github for the implementation of the idea of copying the reference of those heavy objects (pretty much the same as described in the forum post).

If we now do choose option 2 in the console application, and boot up again 250 Activiti Engines, the memory  consumption looks as follows:

05

We’re not even touching the 250MB line (which would be 1MB / engine!) Only a fraction of the memory is being used, while still having exactly the same functionality!

and if we look at the number of instances and its retained size, we do indeed see there are 250 instances of the org.apache.ibatis.session.Configuration class, but now only account for 15,1% (was 98.9% before!)

06

Conclusion

So what can we learn about all of the above? Well, first of all, the reason why I posted this on my blog is because I simply love deep technical stuff like this. I’m not saying you should use this in production. You can be the judge of that yourself, it’s fiddling with reflection, depending on Mybatis internals and not tested beyond this simple example :-). But it is damn cool that you can quickly boot up so many Activiti engines with so little memory!

But what this really shows is the power of open source software. Both Activiti and Mybatis are open source and combine that with intelligent and creative developers you can get a whole lot further than with anything closed. Secondly this also demonstrates the awesomeness of the Activiti open source Community. There are a lot of people in our community, and by exchanging ideas and findings like above, Activiti gets better every day.

Thank you for that.

Running Activiti on JDK8

… just works!

All the Activiti code is written with JDK6 compatibility in mind, so it’s no surprise it just works out of the box.

Scripting

There are however some subtle changes when you use Script Task with javascript. In JDK 8, the Rhino engine has been replaced with Nashorn (which is a very good thing!).

nashorn

 

Our QA did show us that some of our unit tests with javascript script task did not pass on JDK 8. But don’t worry, the changes are minimal. More precise, we found two things

1. importing packages

In JDK 6/7 you can import a java package and then use classes from that package in your javascript (eg to use an arraylist):

importPackage (java.util);
var myVar = new ArrayList();

This doesn’t work on Nashorn and thus JDK 8. However, the nice developers of Nashorn have provided a way to support this in a backwards compatible way by loading a certain file:

load("nashorn:mozilla_compat.js");
importPackage (java.util);
var myVar = new ArrayList();

And everything will work again nicely.

2. Implicit variable fetching

This one is more subtle. On JDK 6/7 you could do this

var outcome = task.getVariableLocal('outcome');
if (outcome == 'approve') {
  task.setCategory('approved');
} else {
  task.setCategory('rejected');
}

However, due to an error in our unit test, we didn’t actually set the variable on local scope but on process instance scope. Still, the test worked on JDK 6/7 and failed on JDK8!

It took me some deep debugging, but finally I found the error. In JDK6/7, the getVariableLocal(‘outcome’) does resolve to null too. However, it does a fetch of getVariable(‘outcome’) immediately afterwards. This does not happen on JDK8.

There is a subtle thing going on here: on JDK6/7 something like

var outcome;

or

var outcome = null;

triggers a lookup in the ScriptingBindings, which defaults to a getVariable() call in Activiti. The script bindings call does not happen on JDK 8, which is actually more correct! So this is actually something to be aware of when using JDK6/7.

TL;DR

Activiti just works on JDK 8. If you are using javascript in your script task, be aware of subtle changes.