📜 ⬆️ ⬇️

The story of one integration, or how we stopped worrying and fell in love with InterSystems Ensemble

image

Background: our small but very ambitious company Black Mushroom Studio had the idea of ​​creating an e-commerce project and implementing a mobile application to pay for certain goods / services through a payment aggregator.

What was at the entrance: the framework of the application on Android, which, of course, is convenient to communicate via HTTP and JSON, and the payment system, which provided its API - web-services with SOAP-content.

Task: make friends with one another.
')
The choice of technology was influenced by the following points: the speed of development and the ability to react quickly to changes. The project was supposed to shoot. While competitors are evaluating deadlines, we already wanted to launch a product. While competitors are looking for developers, we should have already made a profit. With this restrictive factor, a serious approach was nevertheless necessary, since the issue is connected with investors' money, and this requires increased attention.

You can talk for a long time about the advantages and disadvantages of specific technologies of specific vendors and the advantages of open source, but everywhere there are disadvantages and advantages. After analyzing several products (material for a separate article), we came to the conclusion that InterSystems Ensemble is more suitable for solving our problems.

Only one of our developers had a development practice in Caché ObjectScript, no one had any experience with Ensemble. But we implemented quite a complicated logic of our product operation on Ensemble within a couple of weeks.

What helped us:

1. Ensemble is a complex product combining a DBMS, an application server, an enterprise integration bus (ESB), a BPM system, and a technology for developing analytical applications (BI). There is no need to study several different solutions and link them together.
2. Object storage model. If we want to save an object in the database, we simply store it in the database.
3. A very simple way to integrate with external / internal systems using various protocols due to the extensible library of adapters.

Solution at the top level


The HTTP client sends a request with JSON content to the server port. This port is listened to by the Ensemble black box. The client receives a response after the end of processing synchronously.

What's inside


In Ensemble we have implemented products (Production - an integration solution in Ensemble), consisting of 3 parts: business services, business processes, business operations (hereinafter, these terms will be used without a business prefix, to facilitate reading).

A service in Ensemble is a component that allows you to receive requests using various protocols, a process is the logic of an application, an operation is a component that allows you to send outgoing requests to external systems.

All interactions within Ensemble are based on message queues. A message - an object of a class inherited from Ens.Message , allows you to use and transfer data from one part of the product to another.

In our case, the service uses the HTTP adapter inherited from EnsLib.HTTP.InboundAdapter, it receives the request sent by the client, converts it into a “message”, and sends it to the process. In response to a business process, the service receives a "message" with the results of processing, converts it into a response for the client.

Here it looks like this:

Method OnProcessInput(pInput As %Library.AbstractStream, Output pOutput As %Stream.Object) As %Status { Set jsonstr = pInput.Read() //    Set st = ##class(%ZEN.Auxiliary.jsonProvider).%ConvertJSONToObject(jsonstr,"invoices.Msg.Message",.tApplication) Throw:$$$ISERR(st) ##class(%Exception.StatusException).CreateFromStatus(st) //    , //     //  - Set outApp=##class(invoices.Msg.Resp).%New() Set st =..SendRequestSync("Processing",tApplication,.outApp) Quit:$$$ISERR(st) st //     json Set json="" Do ##class(invoices.Utils).ObjectToJSON(outApp,,,"aeloqu",.json) //  json    Set pOutput=##class(%GlobalBinaryStream).%New() Do pOutput.SetAttribute("Content-Type","application/json") Do pOutput.Write(json) Quit st } 

The business process is the implementation of the business logic of our application. It contains a sequence of actions that must be performed in order to return the answer to the client. For example: save / update customer data, add a new monitored service, request service status / pay for a service. Without an integration platform, we would have to write quite a lot of code.
What we have in Ensemble: we assemble a business process in a visual editor from individual elements. Business processes are described in the Business Process Language (BPL). Elements can be simple (and not so) assignments, data transformations, a call to a specific code, a synchronous and asynchronous call to other processes and operations (more on this below).

Converting data, in turn, is an extremely handy thing that allows you to perform data mapping, again without writing code:


As a result, for yourself at some stage, instead of a heap of code, we got this:


Now about the operation. This entity allows us to implement a request on some protocol to some external system.
As we did it: with the extension embedded in the studio we import from Caché Studio WSDL, provided by the payment system:


Specify the location of the WSDL:


We put down the “Create operation” checkbox when importing:


As a result, we get a ready-made code for requests-responses to our payment system. Configure the operation in the portal: specify the class of the created operation:


We fix the SSL configuration (it must first be created through the "System Management Portal" - System Administration - Security - SSL / TLS Configurations):


Done, it remains only to call the operation from the business process. In our case, there are two such operations: for the information component and for the payment component. As a result, to appeal to the payment system did not have to write a single line of code.

Everything, integration is ready.

There is also a separate process implementing PUSH notifications using Ensemble's built-in tools, a separate process for receiving SFTP registries from the payment system for generating checks, the actual delivery of checks in PDF format, but these are topics for individual articles.

As a result, a couple of weeks were spent on implementation (taking into account the "understanding" of the new technology).

Naturally, the product of InterSystems is not perfect (there are none). When implemented, they were like a rake, especially since the documentation for Ensemble is not the most complete. But in our case the technology got accustomed, and got accustomed well. A separate plus of the company itself for the support of young and ambitious developers and constant willingness to consult. In the future, we plan to develop new projects on this technology.

Based on this technology, we have already launched the application , are also preparing for the release version of the application for iOS and Web.

Source: https://habr.com/ru/post/275271/


All Articles