How to build Microservices with Intershop

Intershop’s Microservices

Everybody talks about microservices. Since e-Commerce systems are complex and consist of many components, microservices as self-contained, largely decoupled units integrate perfectly into Intershop’s e-Commerce systems. Intershop products, like Intershop Commerce Management, are build using strictly service oriented and modular approaches. The latest release also comes with several microservices, namely a service that handles recurring orders and a service that schedules tasks. These microservices are build on top of a very lightweight technology stack. Other microservices might be build using this stack as well or could easily use their completely independent technologies. This blog-entry shows how a simple microservice can be created and run in a couple of minutes. The created example might be a starting point for your own services or can serve as documentation and quick tutorial.

Create Your Simple Microservice

In this blog entry a new Intershop Studio release is (version 4.6.2) used as well as templates that will ship along with ICM 7.9.
In order to create you a new microservice project you can launch the wizard ‘Create Intershop Development Artifact’:

and select ‘Microservice with a simple application that computes welcome messages’:

Enter some data on the next page, namely the location of the new project, a name as well as some information about the service discovery and artifact-repository location:

Hit ‘Finish’. That’s all. You just created a fully functional Microservice.

Discover and Run Your Simple Microservice

It can be build, run and deployed using gradle or directly from within Intershop Studio. The created microservice also comes with a small Cheat Sheet that can help you to discover its features and components. If you follow the steps in it you can e.g. open and inspect the created Java-class HelloServiceApplication.java which functions as the main entrance point of you service.

com.helloservice.internal.remote.service.HelloServiceApplication
com.helloservice.internal.remote.service.HelloServiceApplication

Probably of more interest is the class  since it declares and implements the actual REST-API of your service. This simple service has just two simple operations that create welcome messages.

com.helloservice.internal.remote.service.HelloServiceServiceImpl
com.helloservice.internal.remote.service.HelloServiceServiceImpl

It’s time to start you service. Just select ApplicationServer[HelloService].launch and invoke ‘Run as’ ApplicationServer[HelloService]. A console should open. Verify that the service starts and states

11:06:30.813 [main] INFO  c.i.c.w.c.server.ApplicationServer - Server listens on 'http://10.0.75.1:54887/'. Of course, the actual URL will be different. You also see that an API documentation is

available with the service. It says on the console:

11:06:30.813 [main] INFO  c.i.c.w.c.server.ApplicationServer - View documentation about this service here: 'http://10.0.75.1:54887/api/'

Note that the service uses Swagger annotations (Swagger.IO) and comes with an integrated Swagger-UI which can be used to test and analyze the service:

Swagger-UI
Swagger-UI

Because the service just uses simple REST you can also use the browser and let it compute welcome messages, either as simple text or simple html:

Next Steps

Feel free to adapt and try the created microservice. For example add new API-methods, use JSON or XML to put or post and get data. Stay tuned for additional blog-entries that will cover aspects like persistence, service discovery and much more.

How to build Microservices with Intershop
Tagged on:                 

2 thoughts on “How to build Microservices with Intershop

    • 2017-07-11 at 5:59 pm
      Permalink

      This article is about writing Microservices to be used from Intershop’s Application Server. Write them with whatever you like with PHP or Spring even. We like it light-weight the reason why we avoided Spring. Welcome to 2017!

      Reply

Leave a Reply

Your email address will not be published. Required fields are marked *