[GitHub] liubao68 opened a new pull request #837: [SCB-775]support invoke service using raw type like JsonObject & String
liubao68 opened a new pull request #837: [SCB-775]support invoke service using raw type like JsonObject & String URL: https://github.com/apache/incubator-servicecomb-java-chassis/pull/837 Follow this checklist to help us incorporate your contribution quickly and easily: - [ ] Make sure there is a [JIRA issue](https://issues.apache.org/jira/browse/SCB) filed for the change (usually before you start working on it). Trivial changes like typos do not require a JIRA issue. Your pull request should address just this issue, without pulling in other changes. - [ ] Each commit in the pull request should have a meaningful subject line and body. - [ ] Format the pull request title like `[SCB-XXX] Fixes bug in ApproximateQuantiles`, where you replace `SCB-XXX` with the appropriate JIRA issue. - [ ] Write a pull request description that is detailed enough to understand what the pull request does, how, and why. - [ ] Run `mvn clean install` to make sure basic checks pass. A more thorough check will be performed on your pull request automatically. - [ ] If this contribution is large, please file an Apache [Individual Contributor License Agreement](https://www.apache.org/licenses/icla.pdf). --- This is an automated message from the Apache Git Service. To respond to the message, please log on GitHub and use the URL above to go to the specific comment. For queries about this service, please contact Infrastructure at: us...@infra.apache.org With regards, Apache Git Services
[GitHub] liubao68 closed pull request #837: [SCB-775]support invoke service using raw type like JsonObject & String
liubao68 closed pull request #837: [SCB-775]support invoke service using raw type like JsonObject & String URL: https://github.com/apache/incubator-servicecomb-java-chassis/pull/837 This is a PR merged from a forked repository. As GitHub hides the original diff on merge, it is displayed below for the sake of provenance: As this is a foreign pull request (from a fork), the diff is supplied below (as it won't show otherwise due to GitHub magic): diff --git a/common/common-rest/src/main/java/org/apache/servicecomb/common/rest/codec/AbstractRestObjectMapper.java b/common/common-rest/src/main/java/org/apache/servicecomb/common/rest/codec/AbstractRestObjectMapper.java new file mode 100644 index 0..8a7ab0e1d --- /dev/null +++ b/common/common-rest/src/main/java/org/apache/servicecomb/common/rest/codec/AbstractRestObjectMapper.java @@ -0,0 +1,24 @@ +/* + * Licensed to the Apache Software Foundation (ASF) under one or more + * contributor license agreements. See the NOTICE file distributed with + * this work for additional information regarding copyright ownership. + * The ASF licenses this file to You under the Apache License, Version 2.0 + * (the "License"); you may not use this file except in compliance with + * the License. You may obtain a copy of the License at + * + * http://www.apache.org/licenses/LICENSE-2.0 + * + * Unless required by applicable law or agreed to in writing, software + * distributed under the License is distributed on an "AS IS" BASIS, + * WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied. + * See the License for the specific language governing permissions and + * limitations under the License. + */ + +package org.apache.servicecomb.common.rest.codec; + +import com.fasterxml.jackson.databind.ObjectMapper; + +public abstract class AbstractRestObjectMapper extends ObjectMapper { + abstract public String convertToString(Object value) throws Exception; +} diff --git a/common/common-rest/src/main/java/org/apache/servicecomb/common/rest/codec/RestObjectMapper.java b/common/common-rest/src/main/java/org/apache/servicecomb/common/rest/codec/RestObjectMapper.java index b0679f4a0..617e86be7 100644 --- a/common/common-rest/src/main/java/org/apache/servicecomb/common/rest/codec/RestObjectMapper.java +++ b/common/common-rest/src/main/java/org/apache/servicecomb/common/rest/codec/RestObjectMapper.java @@ -17,25 +17,37 @@ package org.apache.servicecomb.common.rest.codec; +import java.io.IOException; import java.text.FieldPosition; import java.util.Date; +import com.fasterxml.jackson.core.JsonGenerator; import com.fasterxml.jackson.core.JsonParser.Feature; import com.fasterxml.jackson.databind.DeserializationFeature; import com.fasterxml.jackson.databind.JavaType; +import com.fasterxml.jackson.databind.JsonSerializer; import com.fasterxml.jackson.databind.ObjectMapper; import com.fasterxml.jackson.databind.SerializationFeature; +import com.fasterxml.jackson.databind.SerializerProvider; +import com.fasterxml.jackson.databind.module.SimpleModule; import com.fasterxml.jackson.databind.type.TypeFactory; -public final class RestObjectMapper extends ObjectMapper { - public static final RestObjectMapper INSTANCE = new RestObjectMapper(); +import io.vertx.core.json.JsonObject; + +public class RestObjectMapper extends AbstractRestObjectMapper { + private static class JsonObjectSerializer extends JsonSerializer { +@Override +public void serialize(JsonObject value, JsonGenerator jgen, SerializerProvider provider) throws IOException { + jgen.writeObject(value.getMap()); +} + } private static final long serialVersionUID = -8158869347066287575L; private static final JavaType STRING_JAVA_TYPE = TypeFactory.defaultInstance().constructType(String.class); @SuppressWarnings("deprecation") - private RestObjectMapper() { + public RestObjectMapper() { // swagger中要求date使用ISO8601格式传递,这里与之做了功能绑定,这在cse中是没有问题的 setDateFormat(new com.fasterxml.jackson.databind.util.ISO8601DateFormat() { private static final long serialVersionUID = 7798938088541203312L; @@ -54,9 +66,20 @@ public StringBuffer format(Date date, StringBuffer toAppendTo, FieldPosition fie disable(SerializationFeature.FAIL_ON_EMPTY_BEANS); enable(DeserializationFeature.UNWRAP_SINGLE_VALUE_ARRAYS); enable(DeserializationFeature.ACCEPT_SINGLE_VALUE_AS_ARRAY); + +SimpleModule module = new SimpleModule(); +// custom types +module.addSerializer(JsonObject.class, new JsonObjectSerializer()); +registerModule(module); } + @Override public String convertToString(Object value) throws Exception { return convertValue(value, STRING_JAVA_TYPE); } + + @Override + public T convertValue(Object fromValue, JavaType toValueType) throws IllegalArgumentException { +return super.convertValue(fromValue, toValueType); + } } diff --git
[GitHub] liubao68 commented on a change in pull request #837: [SCB-775]support invoke service using raw type like JsonObject & String
liubao68 commented on a change in pull request #837: [SCB-775]support invoke service using raw type like JsonObject & String URL: https://github.com/apache/incubator-servicecomb-java-chassis/pull/837#discussion_r205319690 ## File path: demo/demo-schema/src/main/java/org/apache/servicecomb/demo/RestObjectMapperWithStringMapper.java ## @@ -56,7 +60,11 @@ public RestObjectMapperWithStringMapper() { public T convertValue(Object fromValue, JavaType toValueType) throws IllegalArgumentException { if (String.class.isInstance(fromValue) && !BeanUtils.isSimpleValueType(toValueType.getRawClass())) { - return super.convertValue(new JsonObject((String) fromValue), toValueType); + try { +return super.readValue((String) fromValue, toValueType); + } catch (IOException e) { +LOGGER.error("Failed to convert value for {}.", e.getMessage()); Review comment: I mean go on. Seems better. This is an automated message from the Apache Git Service. To respond to the message, please log on GitHub and use the URL above to go to the specific comment. For queries about this service, please contact Infrastructure at: us...@infra.apache.org With regards, Apache Git Services
[GitHub] liubao68 commented on a change in pull request #837: [SCB-775]support invoke service using raw type like JsonObject & String
liubao68 commented on a change in pull request #837: [SCB-775]support invoke service using raw type like JsonObject & String URL: https://github.com/apache/incubator-servicecomb-java-chassis/pull/837#discussion_r205319528 ## File path: demo/demo-schema/src/main/java/org/apache/servicecomb/demo/RestObjectMapperWithStringMapper.java ## @@ -43,6 +45,8 @@ * conversion change. You must write convertValue to check possible types using. */ public class RestObjectMapperWithStringMapper extends RestObjectMapper { Review comment: This is a demo This is an automated message from the Apache Git Service. To respond to the message, please log on GitHub and use the URL above to go to the specific comment. For queries about this service, please contact Infrastructure at: us...@infra.apache.org With regards, Apache Git Services
[GitHub] wujimin commented on a change in pull request #837: [SCB-775]support invoke service using raw type like JsonObject & String
wujimin commented on a change in pull request #837: [SCB-775]support invoke service using raw type like JsonObject & String URL: https://github.com/apache/incubator-servicecomb-java-chassis/pull/837#discussion_r205317386 ## File path: demo/demo-schema/src/main/java/org/apache/servicecomb/demo/RestObjectMapperWithStringMapper.java ## @@ -43,6 +45,8 @@ * conversion change. You must write convertValue to check possible types using. */ public class RestObjectMapperWithStringMapper extends RestObjectMapper { Review comment: put this demonstrate class in demo project or treat it as a product class? This is an automated message from the Apache Git Service. To respond to the message, please log on GitHub and use the URL above to go to the specific comment. For queries about this service, please contact Infrastructure at: us...@infra.apache.org With regards, Apache Git Services
[GitHub] wujimin commented on a change in pull request #837: [SCB-775]support invoke service using raw type like JsonObject & String
wujimin commented on a change in pull request #837: [SCB-775]support invoke service using raw type like JsonObject & String URL: https://github.com/apache/incubator-servicecomb-java-chassis/pull/837#discussion_r205317320 ## File path: demo/demo-schema/src/main/java/org/apache/servicecomb/demo/RestObjectMapperWithStringMapper.java ## @@ -43,6 +45,8 @@ * conversion change. You must write convertValue to check possible types using. */ public class RestObjectMapperWithStringMapper extends RestObjectMapper { + private static Logger LOGGER = LoggerFactory.getLogger(RestObjectMapperWithStringMapper.class); + private static final long serialVersionUID = -8158869347066287575L; private static final JavaType STRING_JAVA_TYPE = TypeFactory.defaultInstance().constructType(String.class); Review comment: declare but not used? This is an automated message from the Apache Git Service. To respond to the message, please log on GitHub and use the URL above to go to the specific comment. For queries about this service, please contact Infrastructure at: us...@infra.apache.org With regards, Apache Git Services
[GitHub] wujimin commented on a change in pull request #837: [SCB-775]support invoke service using raw type like JsonObject & String
wujimin commented on a change in pull request #837: [SCB-775]support invoke service using raw type like JsonObject & String URL: https://github.com/apache/incubator-servicecomb-java-chassis/pull/837#discussion_r205317041 ## File path: demo/demo-schema/src/main/java/org/apache/servicecomb/demo/RestObjectMapperWithStringMapper.java ## @@ -56,7 +60,11 @@ public RestObjectMapperWithStringMapper() { public T convertValue(Object fromValue, JavaType toValueType) throws IllegalArgumentException { if (String.class.isInstance(fromValue) && !BeanUtils.isSimpleValueType(toValueType.getRawClass())) { - return super.convertValue(new JsonObject((String) fromValue), toValueType); + try { +return super.readValue((String) fromValue, toValueType); + } catch (IOException e) { +LOGGER.error("Failed to convert value for {}.", e.getMessage()); Review comment: go on or throw? This is an automated message from the Apache Git Service. To respond to the message, please log on GitHub and use the URL above to go to the specific comment. For queries about this service, please contact Infrastructure at: us...@infra.apache.org With regards, Apache Git Services
[GitHub] liubao68 commented on a change in pull request #837: [SCB-775]support invoke service using raw type like JsonObject & String
liubao68 commented on a change in pull request #837: [SCB-775]support invoke service using raw type like JsonObject & String URL: https://github.com/apache/incubator-servicecomb-java-chassis/pull/837#discussion_r205309686 ## File path: common/common-rest/src/main/java/org/apache/servicecomb/common/rest/codec/RestObjectMapper.java ## @@ -17,25 +17,37 @@ package org.apache.servicecomb.common.rest.codec; +import java.io.IOException; import java.text.FieldPosition; import java.util.Date; +import com.fasterxml.jackson.core.JsonGenerator; import com.fasterxml.jackson.core.JsonParser.Feature; import com.fasterxml.jackson.databind.DeserializationFeature; import com.fasterxml.jackson.databind.JavaType; +import com.fasterxml.jackson.databind.JsonSerializer; import com.fasterxml.jackson.databind.ObjectMapper; import com.fasterxml.jackson.databind.SerializationFeature; +import com.fasterxml.jackson.databind.SerializerProvider; +import com.fasterxml.jackson.databind.module.SimpleModule; import com.fasterxml.jackson.databind.type.TypeFactory; -public final class RestObjectMapper extends ObjectMapper { - public static final RestObjectMapper INSTANCE = new RestObjectMapper(); +import io.vertx.core.json.JsonObject; + +public class RestObjectMapper extends AbstractRestObjectMapper { + private static class JsonObjectSerializer extends JsonSerializer { Review comment: This code looks bad. And I think if others use this, they can change it easily as this PR has done. So it's not a problem. This is an automated message from the Apache Git Service. To respond to the message, please log on GitHub and use the URL above to go to the specific comment. For queries about this service, please contact Infrastructure at: us...@infra.apache.org With regards, Apache Git Services
[GitHub] msnetc closed issue #656: bmi项目的log日志没有输出
msnetc closed issue #656: bmi项目的log日志没有输出 URL: https://github.com/apache/incubator-servicecomb-java-chassis/issues/656 This is an automated message from the Apache Git Service. To respond to the message, please log on GitHub and use the URL above to go to the specific comment. For queries about this service, please contact Infrastructure at: us...@infra.apache.org With regards, Apache Git Services
[GitHub] wujimin commented on a change in pull request #837: [SCB-775]support invoke service using raw type like JsonObject & String
wujimin commented on a change in pull request #837: [SCB-775]support invoke service using raw type like JsonObject & String URL: https://github.com/apache/incubator-servicecomb-java-chassis/pull/837#discussion_r205164776 ## File path: demo/demo-schema/src/main/java/org/apache/servicecomb/demo/RestObjectMapperWithStringMapper.java ## @@ -0,0 +1,65 @@ +/* + * Licensed to the Apache Software Foundation (ASF) under one or more + * contributor license agreements. See the NOTICE file distributed with + * this work for additional information regarding copyright ownership. + * The ASF licenses this file to You under the Apache License, Version 2.0 + * (the "License"); you may not use this file except in compliance with + * the License. You may obtain a copy of the License at + * + * http://www.apache.org/licenses/LICENSE-2.0 + * + * Unless required by applicable law or agreed to in writing, software + * distributed under the License is distributed on an "AS IS" BASIS, + * WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied. + * See the License for the specific language governing permissions and + * limitations under the License. + */ + +package org.apache.servicecomb.demo; + +import org.apache.commons.lang3.ClassUtils; +import org.apache.servicecomb.common.rest.codec.RestObjectMapper; + +import com.fasterxml.jackson.databind.JavaType; +import com.fasterxml.jackson.databind.type.TypeFactory; + +import io.vertx.core.json.JsonObject; + +/** + * Demonstrate how to using String as raw type when using RestTemplate to invoke a service that use POJO. e.g. + * + * Provider: + * + *public Response errorCodeWithHeader(MultiRequest request) + * + * + * Consumer: + * + *String stringRequest = "{\"key\":\"testValue\"}"; + *template.postForEntity(url, stringRequest, MultiResponse200.class); + * + * + * Caution: json will convert String to object based on String constructor, using this feature will make default + * conversion change. You must write convertValue to check possible types using. + */ +public class RestObjectMapperWithStringMapper extends RestObjectMapper { + private static final long serialVersionUID = -8158869347066287575L; + + private static final JavaType STRING_JAVA_TYPE = TypeFactory.defaultInstance().constructType(String.class); + + @SuppressWarnings("deprecation") + public RestObjectMapperWithStringMapper() { +super(); + } + + @Override + public T convertValue(Object fromValue, JavaType toValueType) throws IllegalArgumentException { +if (String.class.isInstance(fromValue) +&& !String.class.equals(toValueType.getRawClass()) +&& !java.util.Date.class.equals(toValueType.getRawClass()) +&& !ClassUtils.isPrimitiveOrWrapper(toValueType.getRawClass())) { + return super.convertValue(new JsonObject((String) fromValue), toValueType); Review comment: about toValueType, try org.springframework.beans.BeanUtils#isSimpleValueType? This is an automated message from the Apache Git Service. To respond to the message, please log on GitHub and use the URL above to go to the specific comment. For queries about this service, please contact Infrastructure at: us...@infra.apache.org With regards, Apache Git Services
[GitHub] wujimin commented on a change in pull request #837: [SCB-775]support invoke service using raw type like JsonObject & String
wujimin commented on a change in pull request #837: [SCB-775]support invoke service using raw type like JsonObject & String URL: https://github.com/apache/incubator-servicecomb-java-chassis/pull/837#discussion_r205157126 ## File path: demo/demo-schema/src/main/java/org/apache/servicecomb/demo/RestObjectMapperWithStringMapper.java ## @@ -0,0 +1,65 @@ +/* + * Licensed to the Apache Software Foundation (ASF) under one or more + * contributor license agreements. See the NOTICE file distributed with + * this work for additional information regarding copyright ownership. + * The ASF licenses this file to You under the Apache License, Version 2.0 + * (the "License"); you may not use this file except in compliance with + * the License. You may obtain a copy of the License at + * + * http://www.apache.org/licenses/LICENSE-2.0 + * + * Unless required by applicable law or agreed to in writing, software + * distributed under the License is distributed on an "AS IS" BASIS, + * WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied. + * See the License for the specific language governing permissions and + * limitations under the License. + */ + +package org.apache.servicecomb.demo; + +import org.apache.commons.lang3.ClassUtils; +import org.apache.servicecomb.common.rest.codec.RestObjectMapper; + +import com.fasterxml.jackson.databind.JavaType; +import com.fasterxml.jackson.databind.type.TypeFactory; + +import io.vertx.core.json.JsonObject; + +/** + * Demonstrate how to using String as raw type when using RestTemplate to invoke a service that use POJO. e.g. + * + * Provider: + * + *public Response errorCodeWithHeader(MultiRequest request) + * + * + * Consumer: + * + *String stringRequest = "{\"key\":\"testValue\"}"; + *template.postForEntity(url, stringRequest, MultiResponse200.class); + * + * + * Caution: json will convert String to object based on String constructor, using this feature will make default + * conversion change. You must write convertValue to check possible types using. + */ +public class RestObjectMapperWithStringMapper extends RestObjectMapper { + private static final long serialVersionUID = -8158869347066287575L; + + private static final JavaType STRING_JAVA_TYPE = TypeFactory.defaultInstance().constructType(String.class); + + @SuppressWarnings("deprecation") + public RestObjectMapperWithStringMapper() { +super(); + } + + @Override + public T convertValue(Object fromValue, JavaType toValueType) throws IllegalArgumentException { +if (String.class.isInstance(fromValue) +&& !String.class.equals(toValueType.getRawClass()) +&& !java.util.Date.class.equals(toValueType.getRawClass()) +&& !ClassUtils.isPrimitiveOrWrapper(toValueType.getRawClass())) { + return super.convertValue(new JsonObject((String) fromValue), toValueType); Review comment: try this: super.readValue((String)fromValue, toValueType) maybe also ok. This is an automated message from the Apache Git Service. To respond to the message, please log on GitHub and use the URL above to go to the specific comment. For queries about this service, please contact Infrastructure at: us...@infra.apache.org With regards, Apache Git Services
[incubator-servicecomb-saga] 02/05: SCB-692 WIP Upgrade the version of java-chassis
This is an automated email from the ASF dual-hosted git repository. ningjiang pushed a commit to branch SCB-692 in repository https://gitbox.apache.org/repos/asf/incubator-servicecomb-saga.git commit 15420827e6e383ca8568dcec6de738211f46fcc9 Author: Willem Jiang AuthorDate: Sun Jul 22 10:34:40 2018 +0800 SCB-692 WIP Upgrade the version of java-chassis --- pom.xml | 3 ++- saga-core/pom.xml | 2 ++ .../apache/servicecomb/saga/demo/car/rental/CarRentalApplication.java | 2 +- .../apache/servicecomb/saga/demo/car/rental/CarRentalController.java | 4 ++-- .../saga/demo/flight/booking/FlightBookingApplication.java| 2 +- .../servicecomb/saga/demo/flight/booking/FlightBookingController.java | 4 ++-- .../saga/demo/hotel/reservation/HotelReservationApplication.java | 2 +- .../saga/demo/hotel/reservation/HotelReservationController.java | 4 ++-- .../org/apache/servicecomb/saga/demo/payment/PaymentApplication.java | 2 +- .../org/apache/servicecomb/saga/demo/payment/PaymentController.java | 4 ++-- saga-discovery/saga-discovery-servicecenter/pom.xml | 2 +- .../saga/discovery/service/center/ServiceCenterDiscoveryConfig.java | 4 ++-- .../saga-discovery-servicecenter/src/main/resources/microservice.yaml | 1 + .../servicecomb/saga/discovery/service/center/DummyController.java| 2 +- .../discovery/service/center/ServiceCenterDiscoveryApplication.java | 2 +- .../service/center/ServiceCenterDiscoveryRestTransportTest.java | 4 ++-- .../main/java/org/apache/servicecomb/saga/web/SagaWebApplication.java | 2 +- 17 files changed, 25 insertions(+), 21 deletions(-) diff --git a/pom.xml b/pom.xml index 5ce27f6..e99b71e 100644 --- a/pom.xml +++ b/pom.xml @@ -51,7 +51,8 @@ UTF-8 1.8 0.6.7 -2.6.2 + +2.7 2.6.1 1.5.14.RELEASE 2.0.3.RELEASE diff --git a/saga-core/pom.xml b/saga-core/pom.xml index 1cc1c61..68fe949 100644 --- a/saga-core/pom.xml +++ b/saga-core/pom.xml @@ -85,6 +85,8 @@ org.mockito mockito-core + + 1.10.19 org.apache.commons diff --git a/saga-demo/dependency-free-transaction-demo/car-rental-service/src/main/java/org/apache/servicecomb/saga/demo/car/rental/CarRentalApplication.java b/saga-demo/dependency-free-transaction-demo/car-rental-service/src/main/java/org/apache/servicecomb/saga/demo/car/rental/CarRentalApplication.java index d3e0e95..ae9e5e5 100644 --- a/saga-demo/dependency-free-transaction-demo/car-rental-service/src/main/java/org/apache/servicecomb/saga/demo/car/rental/CarRentalApplication.java +++ b/saga-demo/dependency-free-transaction-demo/car-rental-service/src/main/java/org/apache/servicecomb/saga/demo/car/rental/CarRentalApplication.java @@ -20,7 +20,7 @@ package org.apache.servicecomb.saga.demo.car.rental; import org.springframework.boot.SpringApplication; import org.springframework.boot.autoconfigure.SpringBootApplication; -import io.servicecomb.springboot.starter.provider.EnableServiceComb; +import org.apache.servicecomb.springboot.starter.provider.EnableServiceComb; @SpringBootApplication @EnableServiceComb diff --git a/saga-demo/dependency-free-transaction-demo/car-rental-service/src/main/java/org/apache/servicecomb/saga/demo/car/rental/CarRentalController.java b/saga-demo/dependency-free-transaction-demo/car-rental-service/src/main/java/org/apache/servicecomb/saga/demo/car/rental/CarRentalController.java index 4a98141..68580e2 100644 --- a/saga-demo/dependency-free-transaction-demo/car-rental-service/src/main/java/org/apache/servicecomb/saga/demo/car/rental/CarRentalController.java +++ b/saga-demo/dependency-free-transaction-demo/car-rental-service/src/main/java/org/apache/servicecomb/saga/demo/car/rental/CarRentalController.java @@ -38,8 +38,8 @@ import org.springframework.stereotype.Controller; import org.springframework.web.bind.annotation.RequestAttribute; import org.springframework.web.bind.annotation.RequestMapping; -import io.servicecomb.provider.rest.common.RestSchema; -import io.servicecomb.swagger.invocation.exception.InvocationException; +import org.apache.servicecomb.provider.rest.common.RestSchema; +import org.apache.servicecomb.swagger.invocation.exception.InvocationException; import io.swagger.annotations.ApiResponse; import io.swagger.annotations.ApiResponses; diff --git a/saga-demo/dependency-free-transaction-demo/flight-booking-service/src/main/java/org/apache/servicecomb/saga/demo/flight/booking/FlightBookingApplication.java b/saga-demo/dependency-free-transaction-demo/flight-booking-service/src/main/java/org/apache/servicecomb/saga/demo/flight/booking/FlightBookingApplication.java index 5bee98d..d4a514c 100644 --- a/saga-demo/dependency-free-transaction-demo/flight-booking-service/src/main/java/org/apache/servicecomb/saga/demo/flight/booking/FlightBookingApplication.java +++
[incubator-servicecomb-saga] 03/05: SCB-692 Fixed the ServiceCenterDiscoveryRestTransportTest
This is an automated email from the ASF dual-hosted git repository. ningjiang pushed a commit to branch SCB-692 in repository https://gitbox.apache.org/repos/asf/incubator-servicecomb-saga.git commit fd9a4ae487459232d6df4bb06101e425b6796c48 Author: Willem Jiang AuthorDate: Wed Jul 25 14:03:05 2018 +0800 SCB-692 Fixed the ServiceCenterDiscoveryRestTransportTest --- .../service/center/ServiceCenterDiscoveryRestTransportTest.java | 4 +--- 1 file changed, 1 insertion(+), 3 deletions(-) diff --git a/saga-discovery/saga-discovery-servicecenter/src/test/java/org/apache/servicecomb/saga/discovery/service/center/ServiceCenterDiscoveryRestTransportTest.java b/saga-discovery/saga-discovery-servicecenter/src/test/java/org/apache/servicecomb/saga/discovery/service/center/ServiceCenterDiscoveryRestTransportTest.java index 15ffc02..493db76 100644 --- a/saga-discovery/saga-discovery-servicecenter/src/test/java/org/apache/servicecomb/saga/discovery/service/center/ServiceCenterDiscoveryRestTransportTest.java +++ b/saga-discovery/saga-discovery-servicecenter/src/test/java/org/apache/servicecomb/saga/discovery/service/center/ServiceCenterDiscoveryRestTransportTest.java @@ -62,9 +62,7 @@ public class ServiceCenterDiscoveryRestTransportTest { } private static void setUpLocalRegistry() { -ClassLoader loader = Thread.currentThread().getContextClassLoader(); -URL resource = loader.getResource("registry.yaml"); -System.setProperty(LOCAL_REGISTRY_FILE_KEY, resource.getPath()); +System.setProperty(LOCAL_REGISTRY_FILE_KEY,"notExistJustForceLocal"); } @Test
[incubator-servicecomb-saga] branch SCB-692 updated (f16ed7d -> 0901401)
This is an automated email from the ASF dual-hosted git repository. ningjiang pushed a change to branch SCB-692 in repository https://gitbox.apache.org/repos/asf/incubator-servicecomb-saga.git. discard f16ed7d SCB-692 Updated the microservice configuration discard 991b618 SCB-692 Keep fixing the build error discard 100907c SCB-692 Fixed the ServiceCenterDiscoveryRestTransportTest discard 32018ca SCB-692 WIP Upgrade the version of java-chassis discard 2a19cf5 SCB-692 Restore the old sage files add f05b0ea [SCB-750] Add missing dependency management add f21fd37 SCB-741 change payloads database type from varbinary(10240) to blob add be00cf4 SCB-741 keep the stack trace size below 10240 add 10e1f95 SCB-766 Upgraded spring boot version 1.5.13 and 2.0.3. new 0d18eaa SCB-692 Restore the old sage files new 1542082 SCB-692 WIP Upgrade the version of java-chassis new fd9a4ae SCB-692 Fixed the ServiceCenterDiscoveryRestTransportTest new cbf6274 SCB-692 Keep fixing the build error new 0901401 SCB-692 Updated the microservice configuration This update added new revisions after undoing existing revisions. That is to say, some revisions that were in the old version of the branch are not in the new version. This situation occurs when a user --force pushes a change and generates a repository containing something like this: * -- * -- B -- O -- O -- O (f16ed7d) \ N -- N -- N refs/heads/SCB-692 (0901401) You should already have received notification emails for all of the O revisions, and so the following emails describe only the N revisions from the common base, B. Any revisions marked "omit" are not gone; other references still refer to them. Any revisions marked "discard" are gone forever. The 5 revisions listed above as "new" are entirely new to this repository and will be described in separate emails. The revisions listed as "add" were already present in the repository and have only been added to this reference. Summary of changes: .../src/main/resources/schema-mysql.sql| 4 +- alpha/alpha-server/src/test/resources/schema.sql | 4 +- .../saga/omega/transaction/TxAbortedEvent.java | 9 +- .../omega-transport-servicecomb/pom.xml| 1 - pom.xml| 123 - saga-distribution/src/release/LICENSE | 56 +- 6 files changed, 160 insertions(+), 37 deletions(-)
[incubator-servicecomb-saga] 04/05: SCB-692 Keep fixing the build error
This is an automated email from the ASF dual-hosted git repository. ningjiang pushed a commit to branch SCB-692 in repository https://gitbox.apache.org/repos/asf/incubator-servicecomb-saga.git commit cbf6274253a493a0a556fd3017ccb787de2005ac Author: Willem Jiang AuthorDate: Wed Jul 25 15:15:37 2018 +0800 SCB-692 Keep fixing the build error --- .../java/org/apache/servicecomb/saga/spring/SagaController.java | 4 ++-- .../apache/servicecomb/saga/spring/SagaExecutionQueryService.java | 2 +- .../java/org/apache/servicecomb/saga/spring/GreetingController.java | 2 +- .../apache/servicecomb/saga/spring/SagaServiceDiscoveryTest.java| 6 ++ 4 files changed, 6 insertions(+), 8 deletions(-) diff --git a/saga-spring/src/main/java/org/apache/servicecomb/saga/spring/SagaController.java b/saga-spring/src/main/java/org/apache/servicecomb/saga/spring/SagaController.java index 1a73b7b..5271f95 100644 --- a/saga-spring/src/main/java/org/apache/servicecomb/saga/spring/SagaController.java +++ b/saga-spring/src/main/java/org/apache/servicecomb/saga/spring/SagaController.java @@ -46,10 +46,10 @@ import org.springframework.web.bind.annotation.RequestParam; import com.fasterxml.jackson.annotation.JsonAutoDetect; -import io.servicecomb.provider.rest.common.RestSchema; +import org.apache.servicecomb.provider.rest.common.RestSchema; import org.apache.servicecomb.saga.core.SagaException; import org.apache.servicecomb.saga.core.application.SagaExecutionComponent; -import io.servicecomb.swagger.invocation.exception.InvocationException; +import org.apache.servicecomb.swagger.invocation.exception.InvocationException; import io.swagger.annotations.ApiResponse; import io.swagger.annotations.ApiResponses; import kamon.annotation.EnableKamon; diff --git a/saga-spring/src/main/java/org/apache/servicecomb/saga/spring/SagaExecutionQueryService.java b/saga-spring/src/main/java/org/apache/servicecomb/saga/spring/SagaExecutionQueryService.java index 15f8cc5..356131b 100644 --- a/saga-spring/src/main/java/org/apache/servicecomb/saga/spring/SagaExecutionQueryService.java +++ b/saga-spring/src/main/java/org/apache/servicecomb/saga/spring/SagaExecutionQueryService.java @@ -56,7 +56,7 @@ import org.apache.servicecomb.saga.core.TransactionEndedEvent; import org.apache.servicecomb.saga.core.application.interpreter.FromJsonFormat; import org.apache.servicecomb.saga.core.dag.GraphBuilder; -import io.servicecomb.swagger.invocation.exception.InvocationException; +import org.apache.servicecomb.swagger.invocation.exception.InvocationException; @Service public class SagaExecutionQueryService { diff --git a/saga-spring/src/test/java/org/apache/servicecomb/saga/spring/GreetingController.java b/saga-spring/src/test/java/org/apache/servicecomb/saga/spring/GreetingController.java index 0710c01..4d9cab0 100644 --- a/saga-spring/src/test/java/org/apache/servicecomb/saga/spring/GreetingController.java +++ b/saga-spring/src/test/java/org/apache/servicecomb/saga/spring/GreetingController.java @@ -25,7 +25,7 @@ import org.springframework.stereotype.Controller; import org.springframework.web.bind.annotation.RequestAttribute; import org.springframework.web.bind.annotation.RequestMapping; -import io.servicecomb.provider.rest.common.RestSchema; +import org.apache.servicecomb.provider.rest.common.RestSchema; @Controller @RequestMapping("/rest") diff --git a/saga-spring/src/test/java/org/apache/servicecomb/saga/spring/SagaServiceDiscoveryTest.java b/saga-spring/src/test/java/org/apache/servicecomb/saga/spring/SagaServiceDiscoveryTest.java index 7ca683c..92aaf4a 100644 --- a/saga-spring/src/test/java/org/apache/servicecomb/saga/spring/SagaServiceDiscoveryTest.java +++ b/saga-spring/src/test/java/org/apache/servicecomb/saga/spring/SagaServiceDiscoveryTest.java @@ -19,7 +19,7 @@ package org.apache.servicecomb.saga.spring; import static io.restassured.RestAssured.given; import static io.restassured.http.ContentType.TEXT; -import static io.servicecomb.serviceregistry.client.LocalServiceRegistryClientImpl.LOCAL_REGISTRY_FILE_KEY; +import static org.apache.servicecomb.serviceregistry.client.LocalServiceRegistryClientImpl.LOCAL_REGISTRY_FILE_KEY; import static org.hamcrest.CoreMatchers.containsString; import static org.hamcrest.core.Is.is; import static org.junit.Assert.assertThat; @@ -83,9 +83,7 @@ public class SagaServiceDiscoveryTest { } private static void setUpLocalRegistry() { -ClassLoader loader = Thread.currentThread().getContextClassLoader(); -URL resource = loader.getResource("registry.yaml"); -System.setProperty(LOCAL_REGISTRY_FILE_KEY, resource.getPath()); +System.setProperty(LOCAL_REGISTRY_FILE_KEY,"notExistJustForceLocal"); } @Test
[incubator-servicecomb-saga] 05/05: SCB-692 Updated the microservice configuration
This is an automated email from the ASF dual-hosted git repository. ningjiang pushed a commit to branch SCB-692 in repository https://gitbox.apache.org/repos/asf/incubator-servicecomb-saga.git commit 0901401d0d70ac5bb483fdf8b1c4f3d911224603 Author: Willem Jiang AuthorDate: Wed Jul 25 16:10:14 2018 +0800 SCB-692 Updated the microservice configuration --- .../car-rental-service/src/main/resources/microservice.yaml | 2 +- .../flight-booking-service/src/main/resources/microservice.yaml | 2 +- .../hotel-reservation-service/src/main/resources/microservice.yaml | 2 +- 3 files changed, 3 insertions(+), 3 deletions(-) diff --git a/saga-demo/dependency-free-transaction-demo/car-rental-service/src/main/resources/microservice.yaml b/saga-demo/dependency-free-transaction-demo/car-rental-service/src/main/resources/microservice.yaml index c60e75a..0c47d2f 100644 --- a/saga-demo/dependency-free-transaction-demo/car-rental-service/src/main/resources/microservice.yaml +++ b/saga-demo/dependency-free-transaction-demo/car-rental-service/src/main/resources/microservice.yaml @@ -18,7 +18,7 @@ APPLICATION_ID: saga service_description: name: car-rental-service version: 0.0.1 -cse: +servicecomb: service: registry: address: http://sc.servicecomb.io:30100 diff --git a/saga-demo/dependency-free-transaction-demo/flight-booking-service/src/main/resources/microservice.yaml b/saga-demo/dependency-free-transaction-demo/flight-booking-service/src/main/resources/microservice.yaml index fe96db7..d2dd302 100644 --- a/saga-demo/dependency-free-transaction-demo/flight-booking-service/src/main/resources/microservice.yaml +++ b/saga-demo/dependency-free-transaction-demo/flight-booking-service/src/main/resources/microservice.yaml @@ -18,7 +18,7 @@ APPLICATION_ID: saga service_description: name: flight-booking-service version: 0.0.1 -cse: +servicecomb: service: registry: address: http://sc.servicecomb.io:30100 diff --git a/saga-demo/dependency-free-transaction-demo/hotel-reservation-service/src/main/resources/microservice.yaml b/saga-demo/dependency-free-transaction-demo/hotel-reservation-service/src/main/resources/microservice.yaml index ea01a2a..4342d6c 100644 --- a/saga-demo/dependency-free-transaction-demo/hotel-reservation-service/src/main/resources/microservice.yaml +++ b/saga-demo/dependency-free-transaction-demo/hotel-reservation-service/src/main/resources/microservice.yaml @@ -18,7 +18,7 @@ APPLICATION_ID: saga service_description: name: hotel-reservation-service version: 0.0.1 -cse: +servicecomb: service: registry: address: http://sc.servicecomb.io:30100
[GitHub] liubao68 opened a new pull request #837: [SCB-775]support invoke service using raw type like JsonObject & String
liubao68 opened a new pull request #837: [SCB-775]support invoke service using raw type like JsonObject & String URL: https://github.com/apache/incubator-servicecomb-java-chassis/pull/837 Follow this checklist to help us incorporate your contribution quickly and easily: - [ ] Make sure there is a [JIRA issue](https://issues.apache.org/jira/browse/SCB) filed for the change (usually before you start working on it). Trivial changes like typos do not require a JIRA issue. Your pull request should address just this issue, without pulling in other changes. - [ ] Each commit in the pull request should have a meaningful subject line and body. - [ ] Format the pull request title like `[SCB-XXX] Fixes bug in ApproximateQuantiles`, where you replace `SCB-XXX` with the appropriate JIRA issue. - [ ] Write a pull request description that is detailed enough to understand what the pull request does, how, and why. - [ ] Run `mvn clean install` to make sure basic checks pass. A more thorough check will be performed on your pull request automatically. - [ ] If this contribution is large, please file an Apache [Individual Contributor License Agreement](https://www.apache.org/licenses/icla.pdf). --- This is an automated message from the Apache Git Service. To respond to the message, please log on GitHub and use the URL above to go to the specific comment. For queries about this service, please contact Infrastructure at: us...@infra.apache.org With regards, Apache Git Services
[incubator-servicecomb-website] 03/03: Publish the website
This is an automated email from the ASF dual-hosted git repository. ningjiang pushed a commit to branch asf-site in repository https://gitbox.apache.org/repos/asf/incubator-servicecomb-website.git commit ab94b5bccf8f5160c1cba65fe5fbf014af09d8df Author: Willem Jiang AuthorDate: Wed Jul 25 18:23:01 2018 +0800 Publish the website --- content/cn/developers/team/index.html | 6 ++ content/developers/team/index.html| 11 ++- content/feed.xml | 2 +- 3 files changed, 13 insertions(+), 6 deletions(-) diff --git a/content/cn/developers/team/index.html b/content/cn/developers/team/index.html index b36409b..91660aa 100644 --- a/content/cn/developers/team/index.html +++ b/content/cn/developers/team/index.html @@ -509,6 +509,12 @@ Huawei + + zhfeng + Feng Zheng + Redhat + + diff --git a/content/developers/team/index.html b/content/developers/team/index.html index 89962a4..9e127d3 100644 --- a/content/developers/team/index.html +++ b/content/developers/team/index.html @@ -486,6 +486,12 @@ Huawei + + zhfeng + Feng Zheng + Redhat + + @@ -618,11 +624,6 @@ OneAPM - zhfeng - Feng Zheng - Redhat - - zhuhoudong Zhu Houdong diff --git a/content/feed.xml b/content/feed.xml index b6fcbde..77dc307 100644 --- a/content/feed.xml +++ b/content/feed.xml @@ -1,4 +1,4 @@ -http://www.w3.org/2005/Atom; >https://jekyllrb.com/; version="3.4.3">Jekyll2018-07-23T16:22:45+08:00/Apache ServiceComb (incubating)The homepage of ServiceComb{name=nil, avatar= [...] +http://www.w3.org/2005/Atom; >https://jekyllrb.com/; version="3.4.3">Jekyll2018-07-25T18:22:23+08:00/Apache ServiceComb (incubating)The homepage of ServiceComb{name=nil, avatar= [...] p在最近发布的a href=https://github.com/hashicorp/consul/releasesConsul1.2/a中,a href=https://www.hashicorp.com/HashiCorp/a宣布支持Service Mesh。作为一个优秀的分布式服务发现解决方案,Consul是如何支持Service Mesh的呢?本文将带读者一探究竟。/p
[incubator-servicecomb-website] 01/03: Updated the team list with new voted committer zhfeng
This is an automated email from the ASF dual-hosted git repository. ningjiang pushed a commit to branch asf-site in repository https://gitbox.apache.org/repos/asf/incubator-servicecomb-website.git commit a9fb14c5458f11b9a6ce0357a0b777ffe4c43365 Author: Willem Jiang AuthorDate: Wed Jul 25 18:21:51 2018 +0800 Updated the team list with new voted committer zhfeng --- _developers/cn/team.md | 2 +- _developers/team.md| 2 +- 2 files changed, 2 insertions(+), 2 deletions(-) diff --git a/_developers/cn/team.md b/_developers/cn/team.md index a17ebe7..e1b9e47 100644 --- a/_developers/cn/team.md +++ b/_developers/cn/team.md @@ -26,7 +26,7 @@ last_modified_at: 2018-06-01T19:18:43+08:00 | wujimin | Wu Jimin | Huawei | * | | zhangqi | Zhang qi | Huawei | | | zhengyangyong | Zheng Yangyong | Huawei | | - +| zhfeng| Feng Zheng | Redhat | | * Contributors: diff --git a/_developers/team.md b/_developers/team.md index a296946..06be201 100644 --- a/_developers/team.md +++ b/_developers/team.md @@ -27,6 +27,7 @@ This page lists who we are. By all means add yourself to the list - lets sort it | wujimin | Wu Jimin | Huawei | * | | zhangqi | Zhang qi | Huawei | | | zhengyangyong | Zheng Yangyong | Huawei | | +| zhfeng| Feng Zheng | Redhat | | * Contributors: @@ -56,5 +57,4 @@ This page lists who we are. By all means add yourself to the list - lets sort it | zenlinTechnofreak | Lin Zhinan | Huawei | | zhanglongchun | Zhang LongChun | | | zhang2014 | Zhang Jian | OneAPM | -| zhfeng| Feng Zheng | Redhat | | zhuhoudong| Zhu Houdong| |
[incubator-servicecomb-website] 02/03: Merge branch 'master' into asf-site
This is an automated email from the ASF dual-hosted git repository. ningjiang pushed a commit to branch asf-site in repository https://gitbox.apache.org/repos/asf/incubator-servicecomb-website.git commit 9d22dc5f120c4dfda09e86b6eb9ab8ee62628fdd Merge: bb7d8d5 a9fb14c Author: Willem Jiang AuthorDate: Wed Jul 25 18:22:05 2018 +0800 Merge branch 'master' into asf-site _config.yml| 2 +- _developers/cn/team.md | 2 +- _developers/team.md| 2 +- 3 files changed, 3 insertions(+), 3 deletions(-)
[incubator-servicecomb-website] branch asf-site updated (bb7d8d5 -> ab94b5b)
This is an automated email from the ASF dual-hosted git repository. ningjiang pushed a change to branch asf-site in repository https://gitbox.apache.org/repos/asf/incubator-servicecomb-website.git. from bb7d8d5 Publish the website add 9a58b9a Add the article 'Consul Service Mesh Practices' add a43637f Add the author info of 'Zhen Ju' add 413770b Rename 'gems' to 'plugins' in Gemfile.lock to remove the warnings Ref: https://github.com/jekyll/jekyll/issues/4509 new a9fb14c Updated the team list with new voted committer zhfeng new 9d22dc5 Merge branch 'master' into asf-site new ab94b5b Publish the website The 3 revisions listed above as "new" are entirely new to this repository and will be described in separate emails. The revisions listed as "add" were already present in the repository and have only been added to this reference. Summary of changes: _config.yml | 2 +- _developers/cn/team.md| 2 +- _developers/team.md | 2 +- content/cn/developers/team/index.html | 6 ++ content/developers/team/index.html| 11 ++- content/feed.xml | 2 +- 6 files changed, 16 insertions(+), 9 deletions(-)
[GitHub] WillemJiang commented on issue #123: add gitbook cn version of user guide
WillemJiang commented on issue #123: add gitbook cn version of user guide URL: https://github.com/apache/incubator-servicecomb-website/pull/123#issuecomment-407705362 There are too much changes here, we just need to updated the content directory in asf-site for the new released the git doc page. This is an automated message from the Apache Git Service. To respond to the message, please log on GitHub and use the URL above to go to the specific comment. For queries about this service, please contact Infrastructure at: us...@infra.apache.org With regards, Apache Git Services
[incubator-servicecomb-docs] 01/02: update mock registry description
This is an automated email from the ASF dual-hosted git repository. liubao pushed a commit to branch master in repository https://gitbox.apache.org/repos/asf/incubator-servicecomb-docs.git commit 89b4ab7ce8d31fccf85e0e90abea7718a4fe1599 Author: wujimin AuthorDate: Wed Jul 25 15:31:38 2018 +0800 update mock registry description --- .gitignore | 1 + .../general-development/local-develop-test.md | 55 -- 2 files changed, 32 insertions(+), 24 deletions(-) diff --git a/.gitignore b/.gitignore new file mode 100644 index 000..a09c56d --- /dev/null +++ b/.gitignore @@ -0,0 +1 @@ +/.idea diff --git a/java-chassis-reference/zh_CN/general-development/local-develop-test.md b/java-chassis-reference/zh_CN/general-development/local-develop-test.md index 5f368cf..e38f946 100644 --- a/java-chassis-reference/zh_CN/general-development/local-develop-test.md +++ b/java-chassis-reference/zh_CN/general-development/local-develop-test.md @@ -40,13 +40,11 @@ ``` 注意:前端(frontend)在Linux环境下默认会绑定ipv6地址,导致浏览器报错,修复办法为:先修改conf/app.conf中的httpaddr为外部可达网卡ip,之后修改app/appList/apiList.js中`ip : 'http://127.0.0.1'`为对应ip,最后重启ServiceCenter即可。 -{: .notice--warning} 注意:Window和Linux版本均只支持64位系统。 - {: .notice--warning} 2. 以Docker的方式运行 @@ -59,11 +57,11 @@ docker run -d -p 30100:30100 servicecomb/service-center:latest ```yaml servicecomb: - service: - registry: - address: -http://127.0.0.1:30100 - #服务中心地址及端口 + service: +registry: + address: +# 服务中心地址及端口 +http://127.0.0.1:30100 ``` * **步骤 3 **开发服务提供/消费者,启动微服务进行本地测试。 @@ -71,35 +69,44 @@ http://127.0.0.1:30100 **结束** ## Mock机制启动服务中心 +在本进程内存中模拟一个只能本进程使用的服务中心,一般是在测试场景中使用。 +* ### 进程内调用 +只需要在启动ServiceComb引擎之前声明一下即可启用: +```java +System.setProperty("local.registry.file", "notExistJustForceLocal"); +``` +* ### 跨进程调用 +如果部署比较简单,并且部署信息是静态的,即使有跨进程调用也可以使用本Mock机制 +producer端仍然像“进程内调用”一样声明即可 +但是,因为Mock并不能跨进程生效,所以consumer端的Mock,需要提供一个本地的配置文件,在里面描述调用目标的详细信息,包括名字、版本、地址、schema id等等信息 +同样,因为Mock不能跨进程,consumer也无法动态取得producer的契约信息,所以,需要在本地提供契约文件 +(这个场景,使用Mock服务中心,比使用standalone的服务中心,成本高得多得多,不建议使用) -* **步骤 1**新建本地服务中心定义文件registry.yaml,内容如下: +* **步骤 1**新建本地服务中心定义文件,假设名字为registry.yaml,内容示例如下: ```yaml -springmvctest: - - id: "001" -version: "1.0" -appid: myapp #调试的服务id -instances: - - endpoints: -- rest://127.0.0.1:8080 +localserv: + - id: "100" +version: "0.0.1" +appid: localservreg +schemaIds: + - hello +instances: + - endpoints: +- rest://localhost:8080 +- highway://localhost:7070 ``` +* **步骤 2**consumer本地部署契约文件 - 注意:mock机制需要自己准备契约,并且当前只支持在本地进行服务消费端\(consumer\)侧的调试,不支持服务提供者\(provider\) - -* **步骤 2**在服务消费者Main函数首末添加如下代码: +参考:[定义服务契约](https://huaweicse.github.io/servicecomb-java-chassis-doc/zh_CN/build-provider/define-contract.html) +* **步骤 3**在consumer main函数,启动ServiceComb引擎之前声明: ```java -public class xxxClient { -public static void main(String[] args) { System.setProperty("local.registry.file", "/path/registry.yaml"); -// your code - System.clearProperty("local.registry.file"); -} ``` setProperty第二个参数填写registry.yaml在磁盘中的系统绝对路径,注意区分在不同系统下使用对应的路径分隔符。 -* **步骤 3**开发服务消费者,启动微服务进行本地测试。 ## 通过设置环境信息方便本地调试 java chassis在设计时,严格依赖于契约,所以正常来说契约变了就必须要修改微服务的版本。但是如果当前还是开发模式,那么修改接口是很正常的情况,每次都需要改版本的话,对用户来说非常的不友好,所以增加了一个环境设置。如果微服务配置成开发环境,接口修改了(schema发生了变化),重启就可以注册到服务中心,而不用修改版本号。但是如果有consumer已经调用了重启之前的服务,那么consumer端需要重启才能获取最新的schema。比如A -> B,B接口进行了修改并且重启,那么A这个时候还是使用B老的schema,调用可能会出错,以免出现未知异常,A也需要重启。有三种方式可以设置,推荐使用方法1
[GitHub] liubao68 closed pull request #22: Update local develop
liubao68 closed pull request #22: Update local develop URL: https://github.com/apache/incubator-servicecomb-docs/pull/22 This is a PR merged from a forked repository. As GitHub hides the original diff on merge, it is displayed below for the sake of provenance: As this is a foreign pull request (from a fork), the diff is supplied below (as it won't show otherwise due to GitHub magic): diff --git a/.gitignore b/.gitignore new file mode 100644 index 000..a09c56d --- /dev/null +++ b/.gitignore @@ -0,0 +1 @@ +/.idea diff --git a/java-chassis-reference/zh_CN/build-provider/define-contract.md b/java-chassis-reference/zh_CN/build-provider/define-contract.md index 31efa97..e653c7e 100644 --- a/java-chassis-reference/zh_CN/build-provider/define-contract.md +++ b/java-chassis-reference/zh_CN/build-provider/define-contract.md @@ -1,8 +1,17 @@ # 定义服务契约 - +`` ## 概念阐述 -服务契约,指基于OpenAPI规范的微服务接口契约,是服务端与消费端对于接口的定义。java chassis提供了两种方式定义契约:显示和隐式。显示契约用于开发者使用RPC方式开发代码,然后期望内部程序客户端使用RPC方式访问,同时期望浏览器、手机终端等通过HTTP访问后台接口场景,显示契约需要开发者在yaml文件中描述接口的访问方式。隐式契约中的契约完全由框架根据默认规则(对于RPC方式)或者Annotation(Spring MVC和JAX RS方式)来生成运行时的契约,不需要准备单独的yaml文件。 +服务契约,指基于OpenAPI规范的微服务接口契约,是服务端与消费端对于接口的定义。java chassis提供了两种方式定义契约:code first和contract first。 +* code first + +producer使用Jax-RS或SpringMVC的RESTful annotation声明接口的输入、输出参数,或者再配合OpenAPI的annotation,增加人类可读的信息,比如样例代码、文本描述等等;ServiceComb引擎启动时,根据这些annotation生成契约描述,并自动上传到服务中心。producer也可以使用透明RPC方式开发,但是因为没有任何RESTful的annotation指导如何生成契约,所以此时自动生成的契约非常的不RESTful化,不建议使用。 +consumer使用透明RPC或RestTemplate进行调用。 +code first的开发模式下,开发人员,不必手写契约。 + +* contract first + +此场景下,不使用框架自动生成的契约,而是直接使用开发人员提供的契约文件,这需要由开发人员保证契约与代码的一致性。 ## 场景描述 @@ -95,7 +104,10 @@ definitions: > **注意**: > -> * 根据swagger标准,basePath配置的路径需要包括web server的webroot。 +> * ServiceComb中的契约,建议basePath不要包含web container的web root,以及servlet的url pattern。 + +因为ServiceComb支持部署解耦,既可以脱离servlet container独立部署,也可使用war的方式部署到servlet container中,还可以使用embedded servlet container的方式运行。 +只要base path不包含web root以及url pattern,则部署方式修改导致的实际url变更,ServiceComb consumer业务代码并不需要感知,框架会自动适配。 > * info.x-java-interface需要标明具体的接口路径,根据项目实际情况而定。 > * > SchemaId中可以包含"."字符,但不推荐这样命名。这是由于ServiceComb使用的配置文件是yaml格式的,"."符号用于分割配置项名称,如果SchemaId中也包含了"."可能会导致一些支持契约级别的配置无法正确被识别。 > * OperationId的命名中不可包含"."字符。 diff --git a/java-chassis-reference/zh_CN/general-development/local-develop-test.md b/java-chassis-reference/zh_CN/general-development/local-develop-test.md index 5f368cf..e38f946 100644 --- a/java-chassis-reference/zh_CN/general-development/local-develop-test.md +++ b/java-chassis-reference/zh_CN/general-development/local-develop-test.md @@ -40,13 +40,11 @@ ``` 注意:前端(frontend)在Linux环境下默认会绑定ipv6地址,导致浏览器报错,修复办法为:先修改conf/app.conf中的httpaddr为外部可达网卡ip,之后修改app/appList/apiList.js中`ip : 'http://127.0.0.1'`为对应ip,最后重启ServiceCenter即可。 -{: .notice--warning} 注意:Window和Linux版本均只支持64位系统。 - {: .notice--warning} 2. 以Docker的方式运行 @@ -59,11 +57,11 @@ docker run -d -p 30100:30100 servicecomb/service-center:latest ```yaml servicecomb: - service: - registry: - address: -http://127.0.0.1:30100 - #服务中心地址及端口 + service: +registry: + address: +# 服务中心地址及端口 +http://127.0.0.1:30100 ``` * **步骤 3 **开发服务提供/消费者,启动微服务进行本地测试。 @@ -71,35 +69,44 @@ http://127.0.0.1:30100 **结束** ## Mock机制启动服务中心 +在本进程内存中模拟一个只能本进程使用的服务中心,一般是在测试场景中使用。 +* ### 进程内调用 +只需要在启动ServiceComb引擎之前声明一下即可启用: +```java +System.setProperty("local.registry.file", "notExistJustForceLocal"); +``` +* ### 跨进程调用 +如果部署比较简单,并且部署信息是静态的,即使有跨进程调用也可以使用本Mock机制 +producer端仍然像“进程内调用”一样声明即可 +但是,因为Mock并不能跨进程生效,所以consumer端的Mock,需要提供一个本地的配置文件,在里面描述调用目标的详细信息,包括名字、版本、地址、schema id等等信息 +同样,因为Mock不能跨进程,consumer也无法动态取得producer的契约信息,所以,需要在本地提供契约文件 +(这个场景,使用Mock服务中心,比使用standalone的服务中心,成本高得多得多,不建议使用) -* **步骤 1**新建本地服务中心定义文件registry.yaml,内容如下: +* **步骤 1**新建本地服务中心定义文件,假设名字为registry.yaml,内容示例如下: ```yaml -springmvctest: - - id: "001" -version: "1.0" -appid: myapp #调试的服务id -instances: - - endpoints: -- rest://127.0.0.1:8080 +localserv: + - id: "100" +version: "0.0.1" +appid: localservreg +schemaIds: + - hello +instances: + - endpoints: +- rest://localhost:8080 +- highway://localhost:7070 ``` +* **步骤 2**consumer本地部署契约文件 - 注意:mock机制需要自己准备契约,并且当前只支持在本地进行服务消费端\(consumer\)侧的调试,不支持服务提供者\(provider\) - -* **步骤 2**在服务消费者Main函数首末添加如下代码: +参考:[定义服务契约](https://huaweicse.github.io/servicecomb-java-chassis-doc/zh_CN/build-provider/define-contract.html) +* **步骤 3**在consumer main函数,启动ServiceComb引擎之前声明: ```java -public class xxxClient { -public static void main(String[] args) { System.setProperty("local.registry.file", "/path/registry.yaml"); -// your code - System.clearProperty("local.registry.file"); -} ``` setProperty第二个参数填写registry.yaml在磁盘中的系统绝对路径,注意区分在不同系统下使用对应的路径分隔符。 -* **步骤 3**开发服务消费者,启动微服务进行本地测试。 ## 通过设置环境信息方便本地调试 java
[incubator-servicecomb-docs] branch master updated (636d51d -> ad03876)
This is an automated email from the ASF dual-hosted git repository. liubao pushed a change to branch master in repository https://gitbox.apache.org/repos/asf/incubator-servicecomb-docs.git. from 636d51d 补充实例隔离ping机制和黑白名单机制 new 89b4ab7 update mock registry description new ad03876 update contract description The 2 revisions listed above as "new" are entirely new to this repository and will be described in separate emails. The revisions listed as "add" were already present in the repository and have only been added to this reference. Summary of changes: .gitignore | 1 + .../zh_CN/build-provider/define-contract.md| 18 +-- .../general-development/local-develop-test.md | 55 -- 3 files changed, 47 insertions(+), 27 deletions(-) create mode 100644 .gitignore
[incubator-servicecomb-docs] 02/02: update contract description
This is an automated email from the ASF dual-hosted git repository. liubao pushed a commit to branch master in repository https://gitbox.apache.org/repos/asf/incubator-servicecomb-docs.git commit ad03876ee96b7b3490d729c4c69edd654a512b4d Author: wujimin AuthorDate: Wed Jul 25 16:56:01 2018 +0800 update contract description --- .../zh_CN/build-provider/define-contract.md| 18 +++--- 1 file changed, 15 insertions(+), 3 deletions(-) diff --git a/java-chassis-reference/zh_CN/build-provider/define-contract.md b/java-chassis-reference/zh_CN/build-provider/define-contract.md index 31efa97..e653c7e 100644 --- a/java-chassis-reference/zh_CN/build-provider/define-contract.md +++ b/java-chassis-reference/zh_CN/build-provider/define-contract.md @@ -1,8 +1,17 @@ # 定义服务契约 - +`` ## 概念阐述 -服务契约,指基于OpenAPI规范的微服务接口契约,是服务端与消费端对于接口的定义。java chassis提供了两种方式定义契约:显示和隐式。显示契约用于开发者使用RPC方式开发代码,然后期望内部程序客户端使用RPC方式访问,同时期望浏览器、手机终端等通过HTTP访问后台接口场景,显示契约需要开发者在yaml文件中描述接口的访问方式。隐式契约中的契约完全由框架根据默认规则(对于RPC方式)或者Annotation(Spring MVC和JAX RS方式)来生成运行时的契约,不需要准备单独的yaml文件。 +服务契约,指基于OpenAPI规范的微服务接口契约,是服务端与消费端对于接口的定义。java chassis提供了两种方式定义契约:code first和contract first。 +* code first + +producer使用Jax-RS或SpringMVC的RESTful annotation声明接口的输入、输出参数,或者再配合OpenAPI的annotation,增加人类可读的信息,比如样例代码、文本描述等等;ServiceComb引擎启动时,根据这些annotation生成契约描述,并自动上传到服务中心。producer也可以使用透明RPC方式开发,但是因为没有任何RESTful的annotation指导如何生成契约,所以此时自动生成的契约非常的不RESTful化,不建议使用。 +consumer使用透明RPC或RestTemplate进行调用。 +code first的开发模式下,开发人员,不必手写契约。 + +* contract first + +此场景下,不使用框架自动生成的契约,而是直接使用开发人员提供的契约文件,这需要由开发人员保证契约与代码的一致性。 ## 场景描述 @@ -95,7 +104,10 @@ definitions: > **注意**: > -> * 根据swagger标准,basePath配置的路径需要包括web server的webroot。 +> * ServiceComb中的契约,建议basePath不要包含web container的web root,以及servlet的url pattern。 + +因为ServiceComb支持部署解耦,既可以脱离servlet container独立部署,也可使用war的方式部署到servlet container中,还可以使用embedded servlet container的方式运行。 +只要base path不包含web root以及url pattern,则部署方式修改导致的实际url变更,ServiceComb consumer业务代码并不需要感知,框架会自动适配。 > * info.x-java-interface需要标明具体的接口路径,根据项目实际情况而定。 > * > SchemaId中可以包含"."字符,但不推荐这样命名。这是由于ServiceComb使用的配置文件是yaml格式的,"."符号用于分割配置项名称,如果SchemaId中也包含了"."可能会导致一些支持契约级别的配置无法正确被识别。 > * OperationId的命名中不可包含"."字符。
[GitHub] wujimin opened a new pull request #22: Update local develop
wujimin opened a new pull request #22: Update local develop URL: https://github.com/apache/incubator-servicecomb-docs/pull/22 This is an automated message from the Apache Git Service. To respond to the message, please log on GitHub and use the URL above to go to the specific comment. For queries about this service, please contact Infrastructure at: us...@infra.apache.org With regards, Apache Git Services
[incubator-servicecomb-saga] branch SCB-692 updated (d80e835 -> f16ed7d)
This is an automated email from the ASF dual-hosted git repository. ningjiang pushed a change to branch SCB-692 in repository https://gitbox.apache.org/repos/asf/incubator-servicecomb-saga.git. discard d80e835 Fixed the ServiceCenterDiscoveryRestTransportTest new 100907c SCB-692 Fixed the ServiceCenterDiscoveryRestTransportTest new 991b618 SCB-692 Keep fixing the build error new f16ed7d SCB-692 Updated the microservice configuration This update added new revisions after undoing existing revisions. That is to say, some revisions that were in the old version of the branch are not in the new version. This situation occurs when a user --force pushes a change and generates a repository containing something like this: * -- * -- B -- O -- O -- O (d80e835) \ N -- N -- N refs/heads/SCB-692 (f16ed7d) You should already have received notification emails for all of the O revisions, and so the following emails describe only the N revisions from the common base, B. Any revisions marked "omit" are not gone; other references still refer to them. Any revisions marked "discard" are gone forever. The 3 revisions listed above as "new" are entirely new to this repository and will be described in separate emails. The revisions listed as "add" were already present in the repository and have only been added to this reference. Summary of changes: .../car-rental-service/src/main/resources/microservice.yaml | 2 +- .../flight-booking-service/src/main/resources/microservice.yaml | 2 +- .../hotel-reservation-service/src/main/resources/microservice.yaml | 2 +- .../java/org/apache/servicecomb/saga/spring/SagaController.java | 4 ++-- .../apache/servicecomb/saga/spring/SagaExecutionQueryService.java | 2 +- .../java/org/apache/servicecomb/saga/spring/GreetingController.java | 2 +- .../apache/servicecomb/saga/spring/SagaServiceDiscoveryTest.java| 6 ++ 7 files changed, 9 insertions(+), 11 deletions(-)
[incubator-servicecomb-saga] 01/03: SCB-692 Fixed the ServiceCenterDiscoveryRestTransportTest
This is an automated email from the ASF dual-hosted git repository. ningjiang pushed a commit to branch SCB-692 in repository https://gitbox.apache.org/repos/asf/incubator-servicecomb-saga.git commit 100907ceb749aa7c045abeb833f8796dc2ca Author: Willem Jiang AuthorDate: Wed Jul 25 14:03:05 2018 +0800 SCB-692 Fixed the ServiceCenterDiscoveryRestTransportTest --- .../service/center/ServiceCenterDiscoveryRestTransportTest.java | 4 +--- 1 file changed, 1 insertion(+), 3 deletions(-) diff --git a/saga-discovery/saga-discovery-servicecenter/src/test/java/org/apache/servicecomb/saga/discovery/service/center/ServiceCenterDiscoveryRestTransportTest.java b/saga-discovery/saga-discovery-servicecenter/src/test/java/org/apache/servicecomb/saga/discovery/service/center/ServiceCenterDiscoveryRestTransportTest.java index 15ffc02..493db76 100644 --- a/saga-discovery/saga-discovery-servicecenter/src/test/java/org/apache/servicecomb/saga/discovery/service/center/ServiceCenterDiscoveryRestTransportTest.java +++ b/saga-discovery/saga-discovery-servicecenter/src/test/java/org/apache/servicecomb/saga/discovery/service/center/ServiceCenterDiscoveryRestTransportTest.java @@ -62,9 +62,7 @@ public class ServiceCenterDiscoveryRestTransportTest { } private static void setUpLocalRegistry() { -ClassLoader loader = Thread.currentThread().getContextClassLoader(); -URL resource = loader.getResource("registry.yaml"); -System.setProperty(LOCAL_REGISTRY_FILE_KEY, resource.getPath()); +System.setProperty(LOCAL_REGISTRY_FILE_KEY,"notExistJustForceLocal"); } @Test
[incubator-servicecomb-java-chassis] annotated tag 1.0.0 updated (2d86453 -> b1ef392)
This is an automated email from the ASF dual-hosted git repository. asifdxtreme pushed a change to annotated tag 1.0.0 in repository https://gitbox.apache.org/repos/asf/incubator-servicecomb-java-chassis.git. *** WARNING: tag 1.0.0 was modified! *** from 2d86453 (commit) to b1ef392 (tag) tagging 2d8645355febc215b33818770ae18468aba6146a (commit) replaces 0.4.0 by asifdxtreme on Wed Jul 25 12:28:33 2018 +0530 - Log - Java-Chassis 1.0.0 Release --- No new revisions were added by this update. Summary of changes:
[incubator-servicecomb-java-chassis] branch master updated: Cut 1.0.0 (RC-02) Release
This is an automated email from the ASF dual-hosted git repository. asifdxtreme pushed a commit to branch master in repository https://gitbox.apache.org/repos/asf/incubator-servicecomb-java-chassis.git The following commit(s) were added to refs/heads/master by this push: new 2d86453 Cut 1.0.0 (RC-02) Release 2d86453 is described below commit 2d8645355febc215b33818770ae18468aba6146a Author: asifdxtreme AuthorDate: Wed Jul 25 12:27:41 2018 +0530 Cut 1.0.0 (RC-02) Release --- archetypes/business-service-jaxrs/pom.xml | 2 +- .../src/main/resources/archetype-resources/pom.xml | 2 +- archetypes/business-service-pojo/pom.xml | 2 +- .../src/main/resources/archetype-resources/pom.xml | 2 +- .../business-service-spring-boot-starter/pom.xml | 2 +- .../src/main/resources/archetype-resources/pom.xml | 2 +- archetypes/business-service-springmvc/pom.xml | 2 +- .../src/main/resources/archetype-resources/pom.xml | 2 +- archetypes/pom.xml | 2 +- common/common-javassist/pom.xml| 2 +- common/common-protobuf/pom.xml | 2 +- common/common-rest/pom.xml | 2 +- common/pom.xml | 2 +- core/pom.xml | 2 +- coverage-reports/pom.xml | 44 +- demo/demo-crossapp/crossapp-client/pom.xml | 4 +- demo/demo-crossapp/crossapp-server/pom.xml | 4 +- demo/demo-crossapp/pom.xml | 2 +- demo/demo-edge/authentication/pom.xml | 2 +- demo/demo-edge/business-1-1-0/pom.xml | 4 +- demo/demo-edge/business-1.0.0/pom.xml | 4 +- demo/demo-edge/business-2.0.0/pom.xml | 4 +- demo/demo-edge/consumer/pom.xml| 4 +- demo/demo-edge/edge-service/pom.xml| 2 +- demo/demo-edge/model/pom.xml | 2 +- demo/demo-edge/pom.xml | 2 +- demo/demo-jaxrs/jaxrs-client/pom.xml | 2 +- demo/demo-jaxrs/jaxrs-server/pom.xml | 4 +- demo/demo-jaxrs/pom.xml| 2 +- demo/demo-local/pom.xml| 2 +- demo/demo-multiple/a-client/pom.xml| 2 +- demo/demo-multiple/a-server/pom.xml| 2 +- demo/demo-multiple/b-client/pom.xml| 2 +- demo/demo-multiple/b-server/pom.xml| 2 +- demo/demo-multiple/multiple-client/pom.xml | 4 +- demo/demo-multiple/multiple-server/pom.xml | 4 +- demo/demo-multiple/pom.xml | 10 +-- demo/demo-pojo/pojo-client/pom.xml | 4 +- demo/demo-pojo/pojo-server/pom.xml | 4 +- demo/demo-pojo/pojo-tests/pom.xml | 2 +- demo/demo-pojo/pom.xml | 2 +- demo/demo-schema/pom.xml | 2 +- demo/demo-server-servlet/pom.xml | 2 +- demo/demo-signature/pom.xml| 2 +- .../demo-spring-boot-discovery-client/pom.xml | 4 +- .../demo-spring-boot-discovery-server/pom.xml | 4 +- .../demo-spring-boot-zuul-proxy/pom.xml| 4 +- demo/demo-spring-boot-discovery/pom.xml| 2 +- .../demo-spring-boot-jaxrs-client/pom.xml | 4 +- .../demo-spring-boot-jaxrs-server/pom.xml | 4 +- .../demo-spring-boot-springmvc-client/pom.xml | 2 +- .../demo-spring-boot-springmvc-server/pom.xml | 2 +- demo/demo-spring-boot-provider/pom.xml | 2 +- .../demo-spring-boot-pojo-client/pom.xml | 4 +- .../demo-spring-boot-pojo-server/pom.xml | 4 +- demo/demo-spring-boot-transport/pom.xml| 2 +- demo/demo-springmvc/pom.xml| 2 +- demo/demo-springmvc/springmvc-client/pom.xml | 4 +- demo/demo-springmvc/springmvc-server/pom.xml | 4 +- demo/docker-build-config/pom.xml | 2 +- demo/docker-run-config/pom.xml | 2 +- demo/perf/pom.xml | 2 +- demo/pom.xml | 28 +++ dynamic-config/config-apollo/pom.xml | 2 +- dynamic-config/config-cc/pom.xml | 2 +- dynamic-config/pom.xml | 2 +- edge/edge-core/pom.xml | 2 +- edge/pom.xml | 2 +- foundations/foundation-common/pom.xml | 2 +- foundations/foundation-config/pom.xml | 2 +- foundations/foundation-metrics/pom.xml | 2 +- foundations/foundation-ssl/pom.xml | 2 +- foundations/foundation-test-scaffolding/pom.xml| 2 +- foundations/foundation-vertx/pom.xml | 2 +- foundations/pom.xml
[incubator-servicecomb-website] branch master updated (9f503c1 -> 413770b)
This is an automated email from the ASF dual-hosted git repository. ningjiang pushed a change to branch master in repository https://gitbox.apache.org/repos/asf/incubator-servicecomb-website.git. omit 9f503c1 Update the call() func's parameter according to the deprecation of sass This update removed existing revisions from the reference, leaving the reference pointing at a previous point in the repository history. * -- * -- N refs/heads/master (413770b) \ O -- O -- O (9f503c1) Any revisions marked "omit" are not gone; other references still refer to them. Any revisions marked "discard" are gone forever. No new revisions were added by this update. Summary of changes: _sass/minimal-mistakes/vendor/susy/susy/output/support/_support.scss | 2 +- 1 file changed, 1 insertion(+), 1 deletion(-)
[incubator-servicecomb-saga] branch SCB-692 updated: Fixed the ServiceCenterDiscoveryRestTransportTest
This is an automated email from the ASF dual-hosted git repository. ningjiang pushed a commit to branch SCB-692 in repository https://gitbox.apache.org/repos/asf/incubator-servicecomb-saga.git The following commit(s) were added to refs/heads/SCB-692 by this push: new d80e835 Fixed the ServiceCenterDiscoveryRestTransportTest d80e835 is described below commit d80e83510f369f5aaded2d2de6e0d5dc16bf74eb Author: Willem Jiang AuthorDate: Wed Jul 25 14:03:05 2018 +0800 Fixed the ServiceCenterDiscoveryRestTransportTest --- .../service/center/ServiceCenterDiscoveryRestTransportTest.java | 4 +--- 1 file changed, 1 insertion(+), 3 deletions(-) diff --git a/saga-discovery/saga-discovery-servicecenter/src/test/java/org/apache/servicecomb/saga/discovery/service/center/ServiceCenterDiscoveryRestTransportTest.java b/saga-discovery/saga-discovery-servicecenter/src/test/java/org/apache/servicecomb/saga/discovery/service/center/ServiceCenterDiscoveryRestTransportTest.java index 15ffc02..493db76 100644 --- a/saga-discovery/saga-discovery-servicecenter/src/test/java/org/apache/servicecomb/saga/discovery/service/center/ServiceCenterDiscoveryRestTransportTest.java +++ b/saga-discovery/saga-discovery-servicecenter/src/test/java/org/apache/servicecomb/saga/discovery/service/center/ServiceCenterDiscoveryRestTransportTest.java @@ -62,9 +62,7 @@ public class ServiceCenterDiscoveryRestTransportTest { } private static void setUpLocalRegistry() { -ClassLoader loader = Thread.currentThread().getContextClassLoader(); -URL resource = loader.getResource("registry.yaml"); -System.setProperty(LOCAL_REGISTRY_FILE_KEY, resource.getPath()); +System.setProperty(LOCAL_REGISTRY_FILE_KEY,"notExistJustForceLocal"); } @Test