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” came up with the idea of ​​creating an e-commerce project and implementing a mobile application to pay for some goods / services through a payment aggregator.

    What was at the entrance: the Android application framework, which, of course, is convenient for communicating via HTTP and JSON, and the payment system that provided its API — web services with SOAP content.

    Objective: make friends with one another.

    The following points influenced the choice of technology: the speed of development and the ability to quickly respond to changes. The project was supposed to shoot. While competitors are evaluating deadlines, we wanted to launch the product already. While competitors are looking for developers, we should have already made a profit. With this limiting factor, a serious approach was nevertheless necessary, since the issue is related to investor 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 minuses and pluses. After analyzing several products (material for a separate article), we came to the conclusion that InterSystems Ensemble is more suitable than others for solving our problems .

    Only one of our developers had development experience on Caché ObjectScript, no one had experience with Ensemble. But we implemented a rather complex logic of our product on Ensemble for a couple of weeks.

    What helped us:

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

    Top Level Solution


    By HTTP client sends a request with JSON content to the server port. This port is heard by Ensemble's black box. The client receives a response after the processing is completed synchronously.

    What's inside


    In Ensemble, we sold products (Production - an integration solution in Ensemble), which consists of 3 parts: business services, business processes, business operations (hereinafter, these terms will go without the prefix business, 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 communication within Ensemble is based on message queues. Message - an object of the class inherited from Ens.Message , allows you to use and transfer data from one part of the product to another.

    The service in our case 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 from the business process, the service receives a “message” with the processing results, converts it into a response for the client.

    It looks like this for us:

    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
    }

    A business process is an implementation of the business logic of our application. It contains a sequence of actions that must be performed in order to return a response to the client. For example: save / update customer data, add a new monitored service, request the status of the service / pay for the 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 separate elements. Business processes are described in the Business Process Language (BPL). Elements can be simple (and not so) assignment, data conversion, calling a certain code, synchronous and asynchronous calling of other processes and operations (more about this below).

    Data conversion, in turn, is an extremely convenient thing, it allows data mapping, again without writing code:


    As a result, for ourselves at some stage, instead of a bunch of code, we got this:


    Now about the operation. This entity allows us to implement a request using some protocol to some external system.
    How we did it: we import from the Caché Studio WSDL built-in extension into the studio, provided by the payment system:


    Specify the location of the WSDL:


    When importing, check the box "Create operation":


    As a result, we get a ready-made code for request-response 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 were two such operations: for the information component and for the payment component. As a result, I did not have to write a single line of code to contact the payment system.

    Everything, integration is ready.

    There is still a separate process that implements PUSH notifications using Ensemble built-in tools, a separate process for receiving SFTP registries from a payment system for generating checks, the actual provision of checks in PDF format, but these are topics for individual articles.

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

    Naturally, the InterSystems product is not perfect (there are none). When implemented, they looked like a rake, especially since the documentation for Ensemblenot the most complete. But in our case, the technology took root, and took root well. A separate plus of the company for supporting young and ambitious developers and constant willingness to advise. In the future we plan the development of new projects on this technology.

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

    Also popular now: