Springcloud First experience: Five, Sidecar the PHP non-Java language services to the Spring Cloud

Source: Internet
Author: User

Start with a Sidecar service, a PHP service, an application, and PHP services deployed on the same machine, accessed through localhost, which solves the network overhead, equivalent to the local inter-process call

Sidecar service is relatively simple,

1. The configuration of Maven is recorded here

<?xml version="1.0" encoding="UTF-8"?>
<project xmlns="http://maven.apache.org/POM/4.0.0" xmlns:xsi="http://www.w3.org/2001/XMLSchema-instance"
    Xsi:schemaLocation="http://maven.apache.org/POM/4.0.0 http://maven.apache.org/xsd/maven-4.0.0.xsd">


    <description>Demo project for Spring Boot</description>

        <relativePath/> <!-- lookup parent from repository -->


    <!--Configure the warehouse -->

    <!-- cloud -->






2, sidecar related configuration, and the configuration of the registration center

     Name: tx-php-server-sidecar

Service registry port number
   Port: 8203

#Hostname and port of the service registry instance
#Do you register yourself with the service registry?
#Whether to retrieve the service
#Configuration of the registration center, specify the location of the service registry
   Port: 8200
     Hostname: localhost
     Register-with-eureka: true
     Fetch-registry: true
       defaultZone: http://${eureka.instance.hostname}:${eureka.port}/eureka/

   Port: 1215
     Hostname: localhost
   Health-uri: http://${sidecar.instance.hostname}:${sidecar.port}/health

3. Service startup class @EnableSidecar

4, also need in PHP service a check service interface or file, note the response header type Content-type

Take the Laravel framework as an example, the configured address is Http://

Route::get(‘health‘, function () {
    $content = ‘{ "status" : "UP" }‘;
    $status = 200;
    $value = ‘application/json; charset=utf-8‘;
    return response($content, $status)
        ->header(‘Content-Type‘, $value);

This is through the Eureka Center page, see Sidecar has been registered, note if the PHP Health page response content or response header is incorrect, the Sidecar service's up status will show down

This is the default page for PHP services

This is the PHP service page that was forwarded via Spring Cloud Gateway

Springcloud First experience: Five, Sidecar the PHP non-Java language services to the Spring Cloud

Contact Us

The content source of this page is from Internet, which doesn't represent Alibaba Cloud's opinion; products and services mentioned on that page don't have any relationship with Alibaba Cloud. If the content of the page makes you feel confusing, please write us an email, we will handle the problem within 5 days after receiving your email.

If you find any instances of plagiarism from the community, please send an email to: info-contact@alibabacloud.com and provide relevant evidence. A staff member will contact you within 5 working days.

A Free Trial That Lets You Build Big!

Start building with 50+ products and up to 12 months usage for Elastic Compute Service

  • Sales Support

    1 on 1 presale consultation

  • After-Sales Support

    24/7 Technical Support 6 Free Tickets per Quarter Faster Response

  • Alibaba Cloud offers highly flexible support services tailored to meet your exact needs.