This topic describes how to use Enterprise Distributed Application Service (EDAS)
to implement interoperability between multi-language applications and Java Spring
Cloud applications.
Background information
As non-Java applications are widely used, the interoperability between Java applications
and non-Java applications becomes an urgent need. To meet this need, EDAS provides
an architecture that allows you to implement interoperability between multi-language
applications and Java Spring Cloud applications. The following figure shows the architecture:
Java applications use an agent to retrieve the data of multi-language applications
that are deployed in an Alibaba Cloud Service Mesh (ASM) instance.
Java applications use the service names of multi-language applications to call the
multi-language applications.
Prerequisites
The following conditions must be met:
A multi-language application is deployed in EDAS.
A Java Spring Cloud application is deployed in EDAS.
The required environment variables are configured for the interoperability between
multi-language applications and Java Spring Cloud applications.
Scenario 1: use a Java Spring Cloud application to call a multi-language application
The method for a Java Spring Cloud application to call a multi-language application
is the same as that for the Java Spring Cloud application to call another Java application.
For example, you can run the following command to use the restTemplate class to call the A API operation of the Java Spring Cloud application named go-sc-a.
You can also use other methods to call the API operation. You can access the application
without specifying the port number.
Scenario 2: use a multi-language application to call a Java Spring Cloud application
You can use a multi-language application to call the Kubernetes service provided by
a Java Spring Cloud application to access the Java Spring Cloud application.
Deploy a Java Spring Cloud application and a multi-language application
On the Clusters page, find the cluster that you want to manage and click Applications in the Actions column.
In the left-side navigation pane, choose Workloads > Deployments, select a namespace from the Namespace drop-down list, and then click Create from YAML.
On the Create page, select a template from the Sample Template drop-down list, modify the content of the YAML file in the Template section, and then click Create.
You can use the following YAML template to deploy a Java Spring Cloud application:
You can view the created Java Spring Cloud application on the Deployments page.
Deploy a multi-language application
In the left-side navigation pane, choose Workloads > Deployments, select a namespace from the Namespace drop-down list, and then click Create from YAML.
On the Create page, select a template from the Sample Template drop-down list, modify the content of the YAML file in the Template section, and then click Create.
You can use the following YAML template to deploy a multi-language application:
On the Clusters page, find the cluster that you want to manage and click Applications in the Actions column.
In the left-side navigation pane, choose Workloads > Deployments. On the Deployments page, select ARMS-pilot from the Namespace drop-down list, find the created multi-language application, and then click Edit in the Actions column.
In the Environment Variable section, click Add. Create the following environment variable, and click Update.
Environment variable:
profile.micro.service.envoy.xds.enable: true
On the Deployments page, select the namespace of the created Java Spring Cloud application from the
Namespace drop-down list, find the application, and then click Edit in the Actions column.
In the Environment Variable section, click Add. Create the following environment variable and startup parameter, and click Update.
Implement interoperability between the Java Spring Cloud application and multi-language
application
Java Spring Cloud applications can interoperate with multi-language applications that
are deployed in an ASM instance. The method for a Java Spring Cloud application to
call a multi-language application is the same as that for the Java Spring Cloud application
to call another Java application. You do not need to modify the code.
Use the Java Spring Cloud application to call the multi-language application
Run the following command to use the created Java Spring Cloud application to call
the created multi-language application:
curl localhost:20003/go
Note The Java application can use its internal API to access the multi-language application.
The following result is returned:
[Java Spring Cloud ] -> [Service Mesh APP10.191.XX.XX ]
Use the multi-language application to call the Java Spring Cloud application
Run the following command to use the created multi-language application to call the
created Java Spring Cloud application:
curl localhost:8085/java
The following result is returned:
[ Service Mesh APP ] -> [Java Spring Cloud10.191.XX.XX]