Docker, Clojure, Microservices, Google (and Alfresco): Introducing ECM Google Services

ECM Google Services

There are Google Vision „modules“ available for Alfresco and Nuxeo and most likely a bunch of other systems as well. These modules execute Google API Java code in process. They need to ensure the API along with its tree of dependencies is right there. Dependency trees can be huge – especially as we are heading into machine learning and artificial intelligence domains. The Alfresco repository comes with almost 300 Java libraries. The Google Vision API also has a few dependencies. Some of those are already in the Alfresco repository. Care should be taken if you want to put it there.

There are various approaches how to introduce a module along with its dependencies into a server process (Alfresco or Nuxeo). Alfresco suggests to use its proprietary AMP format, Nuxeo uses an OSGI „light“ approach (without lifecycle and/or isolation if I remember correctly). I don’t like either of them. Introducing more dependencies messes things up even further. And has great potential for all sorts of nasty issues.

I wanted to try the microservice route. It surely complicates matters as it introduces another process and network communication. On the other hand, it also has great advantages:

  • It does not mess with ECM server dependencies
  • The microservice can potentially be used from all your systems
  • The process lifecycle is independant of the client (which happens to be the ECM server)
  • Development turnaround is super quick – at least it was with tesla

I grabbed code which was there and quickly bent it towards microservices. One might consider it a hack. You have been warned. :)

The Microservice

I am always looking for Clojure adventures. That’s why I picked Otto’s tesla-microservice as a basis for the microservice (The Otto folks have base implementations for Java/Spring Boot, Node.js and maybe even other stacks on github). Naturally, I decided to wrap the microservice into a docker container.

If you want to try this out, make sure you have a Google API json key. If you don’t have one already, get yourself one. Playing around is free. And 1000 API calls/month are also free – if I remember correctly.

To spin up the docker container, do the following:

Alternatively, if you want to run the jar directly, download the ECM Google Microservice archive, extract it and exeute

The properties file supports way more values (generic microservice stuff and Google things I have introduced).

Either way, the service should be up and a demo form is available at http://localhost:9090/vision-form. Submitting an image should display the data returned by Google:

google-vision-demo-page

The Alfresco „Connector“

My Alfresco pieces are derived from the work of Angel Borroy. Links to sources and binaries can be found below.

To deploy the Alfresco extension, copy the repo-/share jar file to {alfresco,share}/WEB-INF/lib or modules/{platform,share} and (re)start the server.

There is a doclib action „Google Vision“ which is available for images. Try it out. It should set tags on the image. It should also set landmark, logo and text values when received from Google. At least I hope I preserved this functionality. :)

paulchen-doclib

Putting this together was an awesome experience. I am fairly sure this will continue to evolve over time. And maybe it can also serve to bring ECM nerd communities together. ;)

Download ECM Google Microservice
Download Alfresco ECM Google Service

References

Über Andreas Steffan

Complexity is ugly. I love it straight, fast, simple and open. I believe in true Open Source, the Open Web and Linux. I freelance in the JVM- and Content-Management spaces. My preferences are Clojure, Groovy, JavaScript, Java, Alfresco and WordPress. Emacs is my religion.

Kommentar verfassen