You are viewing a plain text version of this content. The canonical link for it is here.
Posted to commits@servicecomb.apache.org by GitBox <gi...@apache.org> on 2020/02/29 06:58:40 UTC

[GitHub] [servicecomb-java-chassis] YYKI opened a new issue #1602: 请教,highway通信模式下是否可以指定ip访问特定实例的接口

YYKI opened a new issue #1602: 请教,highway通信模式下是否可以指定ip访问特定实例的接口
URL: https://github.com/apache/servicecomb-java-chassis/issues/1602
 
 
   有没有相关代码可以参考,谢谢

----------------------------------------------------------------
This is an automated message from the Apache Git Service.
To respond to the message, please log on to GitHub and use the
URL above to go to the specific comment.
 
For queries about this service, please contact Infrastructure at:
users@infra.apache.org


With regards,
Apache Git Services

[GitHub] [servicecomb-java-chassis] YYKI commented on issue #1602: 请教,highway通信模式下是否可以指定ip访问特定实例的接口

Posted by GitBox <gi...@apache.org>.
YYKI commented on issue #1602: 请教,highway通信模式下是否可以指定ip访问特定实例的接口
URL: https://github.com/apache/servicecomb-java-chassis/issues/1602#issuecomment-592911888
 
 
   补充下,这个ip是可以变化的,不是写到配置文件里的,
   类似于restTemplate.getForEntity("http://xxx.xxx.xxx.xxx:8081/SomeServiceImpl/sayHello?name=tom", String.class);

----------------------------------------------------------------
This is an automated message from the Apache Git Service.
To respond to the message, please log on to GitHub and use the
URL above to go to the specific comment.
 
For queries about this service, please contact Infrastructure at:
users@infra.apache.org


With regards,
Apache Git Services

[GitHub] [servicecomb-java-chassis] heyile commented on issue #1602: 请教,highway通信模式下是否可以指定ip访问特定实例的接口

Posted by GitBox <gi...@apache.org>.
heyile commented on issue #1602: 请教,highway通信模式下是否可以指定ip访问特定实例的接口
URL: https://github.com/apache/servicecomb-java-chassis/issues/1602#issuecomment-593746144
 
 
   provider 发布完之后, 本来就可以直接这样调用. 本来就支持的.
   
   但是有一个细节需要注意下, 调用 url  是 111.111.111.111:8080 这样的,走Spring的RestTemplate原生的逻辑,就是没有经过我们的handler链之类的了,不具备consumer端治理能力和Java-Chassis的扩展功能. url是 cse://serviceName/xxx 这样的,走的是Java-Chassis的逻辑发请求的,会经过我们的handler链之类的,有我们的consumer端治理能力

----------------------------------------------------------------
This is an automated message from the Apache Git Service.
To respond to the message, please log on to GitHub and use the
URL above to go to the specific comment.
 
For queries about this service, please contact Infrastructure at:
users@infra.apache.org


With regards,
Apache Git Services

[GitHub] [servicecomb-java-chassis] YYKI commented on issue #1602: 请教,highway通信模式下是否可以指定ip访问特定实例的接口

Posted by GitBox <gi...@apache.org>.
YYKI commented on issue #1602: 请教,highway通信模式下是否可以指定ip访问特定实例的接口
URL: https://github.com/apache/servicecomb-java-chassis/issues/1602#issuecomment-592916062
 
 
   之前用的dubbo,提供ReferenceConfig类支持直连ip,实现和这个类似,https://blog.csdn.net/BuquTianya/article/details/69229384

----------------------------------------------------------------
This is an automated message from the Apache Git Service.
To respond to the message, please log on to GitHub and use the
URL above to go to the specific comment.
 
For queries about this service, please contact Infrastructure at:
users@infra.apache.org


With regards,
Apache Git Services

[GitHub] [servicecomb-java-chassis] YYKI commented on issue #1602: 请教,highway通信模式下是否可以指定ip访问特定实例的接口

Posted by GitBox <gi...@apache.org>.
YYKI commented on issue #1602: 请教,highway通信模式下是否可以指定ip访问特定实例的接口
URL: https://github.com/apache/servicecomb-java-chassis/issues/1602#issuecomment-592911739
 
 
   补充下,这个ip是可以变化的,不是写到配置文件里的,
   类似于restTemplate.getForEntity("http://10.159.162.233:8081/SomeServiceImpl/sayHello?name=yyk", String.class);

----------------------------------------------------------------
This is an automated message from the Apache Git Service.
To respond to the message, please log on to GitHub and use the
URL above to go to the specific comment.
 
For queries about this service, please contact Infrastructure at:
users@infra.apache.org


With regards,
Apache Git Services

[GitHub] [servicecomb-java-chassis] heyile edited a comment on issue #1602: 请教,highway通信模式下是否可以指定ip访问特定实例的接口

Posted by GitBox <gi...@apache.org>.
heyile edited a comment on issue #1602: 请教,highway通信模式下是否可以指定ip访问特定实例的接口
URL: https://github.com/apache/servicecomb-java-chassis/issues/1602#issuecomment-593751042
 
 
   Provider:
   
   ```java
   
     @RequestMapping(path = "/sayhi", method = RequestMethod.POST, produces = "text/plain")
     public String sayHi(@RequestParam(name = "name", defaultValue = "test") String name) {
       return "Hello " + name;
     }
   
   ```
   
   Consumer:
   
   ```java
       String sayHiResult =
           restTemplate.postForObject("cse://springmvc/springmvchello/sayhi?name=Java Chassis", null, String.class);
       Assertion.assertEquals("Hello Java Chassis", sayHiResult);
   
       String sayHiResult2 =
           restTemplate.postForObject("http://localhost:8080/springmvchello/sayhi?name=Java Chassis", null, String.class);
       Assertion.assertEquals("Hello Java Chassis", sayHiResult2);
   
   
   ```

----------------------------------------------------------------
This is an automated message from the Apache Git Service.
To respond to the message, please log on to GitHub and use the
URL above to go to the specific comment.
 
For queries about this service, please contact Infrastructure at:
users@infra.apache.org


With regards,
Apache Git Services

[GitHub] [servicecomb-java-chassis] heyile commented on issue #1602: 请教,highway通信模式下是否可以指定ip访问特定实例的接口

Posted by GitBox <gi...@apache.org>.
heyile commented on issue #1602: 请教,highway通信模式下是否可以指定ip访问特定实例的接口
URL: https://github.com/apache/servicecomb-java-chassis/issues/1602#issuecomment-594369592
 
 
   抱歉, 有个地方会错意了.. 
   
   ```java
   
   // 这种方式可以通过设置配置, 偏好走 highway 或者rest. 
       String sayHiResult =
           restTemplate.postForObject("cse://springmvc/springmvchello/sayhi?name=Java Chassis", null, String.class);
   // 这种方式走的 RestTemplate原生的逻辑, 无法走 highway
       String sayHiResult2 =
           restTemplate.postForObject("http://ip:8080/springmvchello/sayhi?name=Java Chassis", null, String.class);
   
   ```
   

----------------------------------------------------------------
This is an automated message from the Apache Git Service.
To respond to the message, please log on to GitHub and use the
URL above to go to the specific comment.
 
For queries about this service, please contact Infrastructure at:
users@infra.apache.org


With regards,
Apache Git Services

[GitHub] [servicecomb-java-chassis] YYKI commented on issue #1602: 请教,highway通信模式下是否可以指定ip访问特定实例的接口

Posted by GitBox <gi...@apache.org>.
YYKI commented on issue #1602: 请教,highway通信模式下是否可以指定ip访问特定实例的接口
URL: https://github.com/apache/servicecomb-java-chassis/issues/1602#issuecomment-593789683
 
 
   抱歉,问题可能没有描述清楚,你给的demo,我之前是测过类似的,不过我理解这是rest通信模式,基于http的,不是highway,我想问的是highway通道,如highway://localhost:8080/springmvchello/sayhi?name=Java Chassis,看你的第一条回答,ip+端口是只支持rest吗?
   dubbo的相关实现代码,图片上传不了,看下这个链接https://blog.csdn.net/BuquTianya/article/details/69229384
   
   

----------------------------------------------------------------
This is an automated message from the Apache Git Service.
To respond to the message, please log on to GitHub and use the
URL above to go to the specific comment.
 
For queries about this service, please contact Infrastructure at:
users@infra.apache.org


With regards,
Apache Git Services

[GitHub] [servicecomb-java-chassis] heyile commented on issue #1602: 请教,highway通信模式下是否可以指定ip访问特定实例的接口

Posted by GitBox <gi...@apache.org>.
heyile commented on issue #1602: 请教,highway通信模式下是否可以指定ip访问特定实例的接口
URL: https://github.com/apache/servicecomb-java-chassis/issues/1602#issuecomment-593751186
 
 
   后面类似问题, 建议自己先写一个demo, 自己测一下

----------------------------------------------------------------
This is an automated message from the Apache Git Service.
To respond to the message, please log on to GitHub and use the
URL above to go to the specific comment.
 
For queries about this service, please contact Infrastructure at:
users@infra.apache.org


With regards,
Apache Git Services

[GitHub] [servicecomb-java-chassis] heyile commented on issue #1602: 请教,highway通信模式下是否可以指定ip访问特定实例的接口

Posted by GitBox <gi...@apache.org>.
heyile commented on issue #1602: 请教,highway通信模式下是否可以指定ip访问特定实例的接口
URL: https://github.com/apache/servicecomb-java-chassis/issues/1602#issuecomment-593751042
 
 
   Provider:
   
   ```java
   
     @RequestMapping(path = "/sayhi", method = RequestMethod.POST, produces = "text/plain")
     public String sayHi(@RequestParam(name = "name", defaultValue = "test") String name) {
       return "Hello " + name;
     }
   
   ```
   
   Consumer:
   
   ```java
       String sayHiResult =
           restTemplate.postForObject("cse://springmvc/springmvchello/sayhi?name=Java Chassis", null, String.class);
       Assertion.assertEquals("Hello Java Chassis", sayHiResult);
   
       /**
        *
        */
       String sayHiResult2 =
           restTemplate.postForObject("http://localhost:8080/springmvchello/sayhi?name=Java Chassis", null, String.class);
       Assertion.assertEquals("Hello Java Chassis", sayHiResult2);
   
   
   ```

----------------------------------------------------------------
This is an automated message from the Apache Git Service.
To respond to the message, please log on to GitHub and use the
URL above to go to the specific comment.
 
For queries about this service, please contact Infrastructure at:
users@infra.apache.org


With regards,
Apache Git Services

[GitHub] [servicecomb-java-chassis] heyile commented on issue #1602: 请教,highway通信模式下是否可以指定ip访问特定实例的接口

Posted by GitBox <gi...@apache.org>.
heyile commented on issue #1602: 请教,highway通信模式下是否可以指定ip访问特定实例的接口
URL: https://github.com/apache/servicecomb-java-chassis/issues/1602#issuecomment-593797064
 
 
   SpringMVC JAX-RS RPC 这些只是服务端编程模型,说白了只是你写代码的形式.
   highway 这些是传输模型. 两个模型本来就是解耦的.
   
   我给你的示例 是 SpringMVC 编程模型. 至于用不用 highway 是自己的配置.
   建议 先了解一下 基本的知识.
   http://1v96us.coding-pages.com/docs/java-chassis/zh_CN/start/terminology/

----------------------------------------------------------------
This is an automated message from the Apache Git Service.
To respond to the message, please log on to GitHub and use the
URL above to go to the specific comment.
 
For queries about this service, please contact Infrastructure at:
users@infra.apache.org


With regards,
Apache Git Services

[GitHub] [servicecomb-java-chassis] YYKI commented on issue #1602: 请教,highway通信模式下是否可以指定ip访问特定实例的接口

Posted by GitBox <gi...@apache.org>.
YYKI commented on issue #1602: 请教,highway通信模式下是否可以指定ip访问特定实例的接口
URL: https://github.com/apache/servicecomb-java-chassis/issues/1602#issuecomment-594353316
 
 
   提issue前,网上有的资料基本是都看了下的,有些地方确实不太理解,经过本地测试,再确认一个问题
   1、只提供rest通信
   ```
   microservice.yaml
   rest:
       address: 0.0.0.0:8080 # 服务REST端口
   ```
   
   2、只提供highway通信,不支持restTemplate.postForObject("http://ip:port/method?name=Java", null, String.class)访问形式;
   ```
   microservice.yaml
   highway:
       address: 0.0.0.0:8080 # 服务highway端口
   ```
   
   3、两种通信方式都提供
   ```
   microservice.yaml
   highway:
       address: 0.0.0.0:8080 # 服务highway端口
   rest:
       address: 0.0.0.0:8081 # 服务REST端口
   ```
   
   
   
   

----------------------------------------------------------------
This is an automated message from the Apache Git Service.
To respond to the message, please log on to GitHub and use the
URL above to go to the specific comment.
 
For queries about this service, please contact Infrastructure at:
users@infra.apache.org


With regards,
Apache Git Services

[GitHub] [servicecomb-java-chassis] heyile removed a comment on issue #1602: 请教,highway通信模式下是否可以指定ip访问特定实例的接口

Posted by GitBox <gi...@apache.org>.
heyile removed a comment on issue #1602: 请教,highway通信模式下是否可以指定ip访问特定实例的接口
URL: https://github.com/apache/servicecomb-java-chassis/issues/1602#issuecomment-593797064
 
 
   SpringMVC JAX-RS RPC 这些只是服务端编程模型,说白了只是你写代码的形式.
   highway 这些是传输模型. 两个模型本来就是解耦的.
   
   我给你的示例 是 SpringMVC 编程模型. 至于用不用 highway 是自己的配置.
   建议 先了解一下 基本的知识.
   http://1v96us.coding-pages.com/docs/java-chassis/zh_CN/start/terminology/

----------------------------------------------------------------
This is an automated message from the Apache Git Service.
To respond to the message, please log on to GitHub and use the
URL above to go to the specific comment.
 
For queries about this service, please contact Infrastructure at:
users@infra.apache.org


With regards,
Apache Git Services

[GitHub] [servicecomb-java-chassis] YYKI removed a comment on issue #1602: 请教,highway通信模式下是否可以指定ip访问特定实例的接口

Posted by GitBox <gi...@apache.org>.
YYKI removed a comment on issue #1602: 请教,highway通信模式下是否可以指定ip访问特定实例的接口
URL: https://github.com/apache/servicecomb-java-chassis/issues/1602#issuecomment-592911739
 
 
   补充下,这个ip是可以变化的,不是写到配置文件里的,
   类似于restTemplate.getForEntity("http://10.159.162.233:8081/SomeServiceImpl/sayHello?name=yyk", String.class);

----------------------------------------------------------------
This is an automated message from the Apache Git Service.
To respond to the message, please log on to GitHub and use the
URL above to go to the specific comment.
 
For queries about this service, please contact Infrastructure at:
users@infra.apache.org


With regards,
Apache Git Services

[GitHub] [servicecomb-java-chassis] YYKI closed issue #1602: 请教,highway通信模式下是否可以指定ip访问特定实例的接口

Posted by GitBox <gi...@apache.org>.
YYKI closed issue #1602: 请教,highway通信模式下是否可以指定ip访问特定实例的接口
URL: https://github.com/apache/servicecomb-java-chassis/issues/1602
 
 
   

----------------------------------------------------------------
This is an automated message from the Apache Git Service.
To respond to the message, please log on to GitHub and use the
URL above to go to the specific comment.
 
For queries about this service, please contact Infrastructure at:
users@infra.apache.org


With regards,
Apache Git Services