Java / .Net Gateways in InterSystems IRIS Integration Products

Gateways in InterSystems IRIS are the communication mechanism between the InterSystems IRIS core and the Java / .Net application code. With the help of gateways, you can work with both Java / .NET objects from ObjectScript and ObjectScript objects and globals from Java / .NET. Gateways can be run anywhere - locally, on a remote server, in docker.

In this article, I'll show you how you can easily develop and containerize integration products with .Net / Java code. And to interact with code in Java / .Net languages, we will use PEX , which provides an opportunity to implement any element of integration products in Java / .Net languages.

For our example, we will develop an integration with Apache Kafka .

Architecture

Apache Kafka is a popular message broker. In Kafka has a theme (topic) messages in which publishers (publisher) write messages and have subscribers (consumer) on the threads that read these messages.

First, we will write a Java business operation that will post messages to Apache Kafka. Then we add a business service in C # that will read, save and transmit messages for further processing in InterSystems IRIS.

Our solution will work in docker and looks like this:

Java Gateway

First of all, we will develop a Business Operation in Java for sending messages to Apache Kafka. The code can be written in any Java IDE and look like this :

  • PEX - com.intersystems.enslib.pex.BusinessOperation.

  • โ€” -

  • OnInit Apache Kafka InterSystems IRIS

  • OnTearDown Apache Kafka ( ).

  • OnMessage dc.KafkaRequest Apache Kafka.

- Docker .

-:

FROM openjdk:8 AS builder

ARG APP_HOME=/tmp/app

COPY src $APP_HOME/src

COPY --from=intersystemscommunity/jgw:latest /jgw/*.jar $APP_HOME/jgw/

WORKDIR $APP_HOME/jar/
ADD https://repo1.maven.org/maven2/org/apache/kafka/kafka-clients/2.5.0/kafka-clients-2.5.0.jar .
ADD https://repo1.maven.org/maven2/ch/qos/logback/logback-classic/1.2.3/logback-classic-1.2.3.jar .
ADD https://repo1.maven.org/maven2/ch/qos/logback/logback-core/1.2.3/logback-core-1.2.3.jar .
ADD https://repo1.maven.org/maven2/org/slf4j/slf4j-api/1.7.30/slf4j-api-1.7.30.jar .

WORKDIR $APP_HOME/src

RUN javac -classpath $APP_HOME/jar/*:$APP_HOME/jgw/* dc/rmq/KafkaOperation.java && \
    jar -cvf $APP_HOME/jar/KafkaOperation.jar dc/rmq/KafkaOperation.class

FROM intersystemscommunity/jgw:latest

COPY --from=builder /tmp/app/jar/*.jar $GWDIR/

, ( , ):

FROM openjdk:8 AS builder

JDK8 , .

ARG APP_HOME=/tmp/app
COPY src $APP_HOME/src

/src /tmp/app.

COPY --from=intersystemscommunity/jgw:latest /jgw/*.jar $APP_HOME/jgw/

Java Gateway /tmp/app/jgw.

WORKDIR $APP_HOME/jar/
ADD https://repo1.maven.org/maven2/org/apache/kafka/kafka-clients/2.5.0/kafka-clients-2.5.0.jar .
ADD https://repo1.maven.org/maven2/ch/qos/logback/logback-classic/1.2.3/logback-classic-1.2.3.jar .
ADD https://repo1.maven.org/maven2/ch/qos/logback/logback-core/1.2.3/logback-core-1.2.3.jar .
ADD https://repo1.maven.org/maven2/org/slf4j/slf4j-api/1.7.30/slf4j-api-1.7.30.jar .

WORKDIR $APP_HOME/src

RUN javac -classpath $APP_HOME/jar/*:$APP_HOME/jgw/* dc/rmq/KafkaOperation.java && \
    jar -cvf $APP_HOME/jar/KafkaOperation.jar dc/rmq/KafkaOperation.class

- javac/jar jar . maven gradle.

FROM intersystemscommunity/jgw:latest

COPY --from=builder /tmp/app/jar/*.jar $GWDIR/

, , jar Java , Java .

.Net Gateway

.Net, Apache Kafka. .Net IDE .

:

  • PEX - InterSystems.EnsLib.PEX.BusinessService.

  • โ€” -

  • OnInit Apache Kafka, Apache Kafka InterSystems IRIS

  • OnTearDown Apache Kafka ( )

  • OnMessage Apache Kafka Ens.StringContainer -

- Docker .

-:

FROM mcr.microsoft.com/dotnet/core/sdk:2.1 AS build

ENV ISC_PACKAGE_INSTALLDIR /usr/irissys
ENV GWLIBDIR lib
ENV ISC_LIBDIR ${ISC_PACKAGE_INSTALLDIR}/dev/dotnet/bin/Core21

WORKDIR /source
COPY --from=store/intersystems/iris-community:2020.2.0.211.0 $ISC_LIBDIR/*.nupkg $GWLIBDIR/

# copy csproj and restore as distinct layers
COPY *.csproj ./
RUN dotnet restore

# copy and publish app and libraries
COPY . .
RUN dotnet publish -c release -o /app

# final stage/image
FROM mcr.microsoft.com/dotnet/core/runtime:2.1
WORKDIR /app
COPY --from=build /app ./

# Configs to start the Gateway Server
RUN cp KafkaConsumer.runtimeconfig.json IRISGatewayCore21.runtimeconfig.json && \
    cp KafkaConsumer.deps.json IRISGatewayCore21.deps.json

ENV PORT 55556

CMD dotnet IRISGatewayCore21.dll $PORT 0.0.0.0

, :

FROM mcr.microsoft.com/dotnet/core/sdk:2.1 AS build

.Net Core 2.1 SDK .

ENV ISC_PACKAGE_INSTALLDIR /usr/irissys
ENV GWLIBDIR lib
ENV ISC_LIBDIR ${ISC_PACKAGE_INSTALLDIR}/dev/dotnet/bin/Core21

WORKDIR /source
COPY --from=store/intersystems/iris-community:2020.2.0.211.0 $ISC_LIBDIR/*.nupkg $GWLIBDIR/

.Net Gateway InterSystems IRIS:

# copy csproj and restore as distinct layers
COPY *.csproj ./
RUN dotnet restore

# copy and publish app and libraries
COPY . .
RUN dotnet publish -c release -o /app

-.

FROM mcr.microsoft.com/dotnet/core/runtime:2.1
WORKDIR /app
COPY --from=build /app ./

.

RUN cp KafkaConsumer.runtimeconfig.json IRISGatewayCore21.runtimeconfig.json && \
    cp KafkaConsumer.deps.json IRISGatewayCore21.deps.json

.Net , .

ENV PORT 55556

CMD dotnet IRISGatewayCore21.dll $PORT 0.0.0.0

55556, .

!

docker-compose, ( UI Apache Kafka, ).

:

:

:

git clone https://github.com/intersystems-community/pex-demo.git
cd pex-demo
docker-compose pull
docker-compose up -d

  • InterSystems IRIS Java/.Net

  • Java/.Net InterSystems ObjectScript , InterSystems ObjectScript Java/.Net

  • , Docker




All Articles