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 2019/02/12 10:06:51 UTC

[GitHub] willard-kali opened a new issue #1092: Use RestTemplate to request another micro service in dispatcher occurred Thread blocked VertxException

willard-kali opened a new issue #1092: Use RestTemplate to request another micro service in dispatcher occurred Thread blocked VertxException
URL: https://github.com/apache/servicecomb-java-chassis/issues/1092
 
 
   I followed by 
   https://github.com/huaweicse/cse-java-chassis-samples/tree/master/porter/gateway-service/src/main/java/com/huawei/cse/porter/gateway
   in UiDispatcher, I added like this.
   ```
   public class UiDispatcher extends AbstractEdgeDispatcher {
     ...
     private RestTemplate restTemplate = RestTemplateBuilder.create();
   
     @Override
     public int getOrder(){...}
   
     @Override
     public void init(Router router) {
     ...
     router.routeWithRegex(regex).failureHandler(this::onFailure).handler(this::onRequest);
     }
   
     protected void onRequest(RoutingContext context) {
       ...
       String sessionInfo =
                       restTemplate.getForObject(requestUrl, String.class);
       if (isValid(sessionInfo)) {...}
       ....
   
       HttpClientRequest clietRequest =
               httpClient.request(...);
       ....
     }
   
   ```
   
   After a few click, it occurred exception and blocked.
   error message:
   
   ```
   2019-02-12 17:25:07,309 [WARN] Thread Thread[transport-vert.x-eventloop-thread-2,5,main] has been blocked for 36189 ms, time limit is 2000 io.vertx.core.impl.BlockedThreadChecker$1.run(BlockedThreadChecker.java:52)
   io.vertx.core.VertxException: Thread blocked
   	at sun.misc.Unsafe.park(Native Method)
   	at java.util.concurrent.locks.LockSupport.park(LockSupport.java:175)
   	at java.util.concurrent.locks.AbstractQueuedSynchronizer.parkAndCheckInterrupt(AbstractQueuedSynchronizer.java:836)
   	at java.util.concurrent.locks.AbstractQueuedSynchronizer.doAcquireSharedInterruptibly(AbstractQueuedSynchronizer.java:997)
   	at java.util.concurrent.locks.AbstractQueuedSynchronizer.acquireSharedInterruptibly(AbstractQueuedSynchronizer.java:1304)
   	at java.util.concurrent.CountDownLatch.await(CountDownLatch.java:231)
   	at org.apache.servicecomb.core.provider.consumer.SyncResponseExecutor.waitResponse(SyncResponseExecutor.java:53)
   	at org.apache.servicecomb.core.provider.consumer.InvokerUtils.innerSyncInvoke(InvokerUtils.java:75)
   	at org.apache.servicecomb.provider.springmvc.reference.CseClientHttpRequest.doInvoke(CseClientHttpRequest.java:204)
   	at org.apache.servicecomb.provider.springmvc.reference.CseClientHttpRequest.invoke(CseClientHttpRequest.java:194)
   	at org.apache.servicecomb.provider.springmvc.reference.CseClientHttpRequest.execute(CseClientHttpRequest.java:146)
   	at org.springframework.web.client.RestTemplate.doExecute(RestTemplate.java:660)
   	at org.springframework.web.client.RestTemplate.execute(RestTemplate.java:621)
   	at org.springframework.web.client.RestTemplate.getForObject(RestTemplate.java:295)
   	at org.apache.servicecomb.provider.springmvc.reference.RestTemplateWrapper.getForObject(RestTemplateWrapper.java:79)
           ...
   ```
   
   is there anything wrong in my code?
   

----------------------------------------------------------------
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:
users@infra.apache.org


With regards,
Apache Git Services