### Question:
ServiceRouter extends AbstractInit implements Router { public Object syncCallService(ServiceContext serviceContext) throws TimeoutException { serviceContext.setSync(true); ActorWrapper actorRefWrapper = chooseOne(serviceContext); Timeout timeout = new Timeout(serviceConfig.getTimeout(), TimeUnit.MILLISECONDS); Future<Object> future = null; if (actorRefWrapper instanceof ActorLocalWrapper) { future = Patterns.ask(((ActorLocalWrapper) actorRefWrapper).getActorRef(), serviceContext, timeout); } else { future = Patterns.ask(((ActorRemoteWrapper) actorRefWrapper).getActorRef(), serviceContext, timeout); } try { Duration duration = Duration.create(serviceConfig.getTimeout(), TimeUnit.MILLISECONDS); FlowMessage response = (FlowMessage) Await.result(future, duration); if (response.isError()) { throw new FlowException("fail to invoke \r\nCaused by: " + response.getException()); } byte[] messageByte = response.getMessage(); Serializer serializer = ExtensionLoader.load(Serializer.class).load(serviceContext.getCodec()); return serializer.decode(messageByte, null); } catch (FlowException e) { throw e; } catch (TimeoutException e) { throw e; } catch (Exception e) { throw new FlowException(returnType + ", serviceContext : " + serviceContext, e); } } ServiceRouter(ServiceConfig serviceConfig, FlowerFactory flowerFactory);  ServiceRouter(ServiceConfig serviceConfig, FlowerFactory flowerFactory, int actorNumber); Object syncCallService(ServiceContext serviceContext); void asyncCallService(ServiceContext serviceContext); void asyncCallService(ServiceContext serviceContext, ActorRef sender); ServiceConfig getServiceConfig(); @Override String toString();  }### Answer:
@Test public void testSyncCallServiceSimple() throws Exception { String flowName = getClass().getSimpleName() + "testSyncCallServiceSimple"; ServiceFlow serviceFlow = serviceFactory.getOrCreateServiceFlow(flowName); serviceFlow.buildFlow(UserServiceA.class, UserServiceB.class); serviceFlow.buildFlow(UserServiceB.class, UserServiceC1.class); serviceFlow.build(); User user = new User(); user.setName("响应式编程 "); user.setAge(2); ServiceContext serviceContext = ServiceContextUtil.context(user); serviceContext.setFlowName(flowName); serviceContext.setCurrentServiceName(FlowerServiceUtil.getServiceName(UserServiceA.class)); Object o = getServiceRouter(flowName).syncCallService(serviceContext); System.out.println("响应结果： " + o); }
@Test public void testSyncCallServiceMutliThread() throws Exception { String flowName = getClass().getSimpleName() + "testSyncCallServiceMutliThread"; ServiceFlow serviceFlow = serviceFactory.getOrCreateServiceFlow(flowName); serviceFlow.buildFlow(UserServiceA.class, UserServiceB.class); serviceFlow.buildFlow(UserServiceB.class, UserServiceC1.class); final int threadNum = 4; final int numPerThread = 10; for (int i = 0; i < threadNum; i++) { final int temp = i; new Thread(() -> { for (int j = 0; j < numPerThread; j++) { final String name = "响应式编程 - " + temp + "-" + j; User user = new User(); user.setName(name); user.setAge(2); try { ServiceContext serviceContext = ServiceContextUtil.context(user); serviceContext.setCurrentServiceName(FlowerServiceUtil.getServiceName(UserServiceA.class)); serviceContext.setFlowName(flowName); User o = (User) getServiceRouter(flowName).syncCallService(serviceContext); Assert.assertEquals(name, o.getName()); } catch (Exception e) { e.printStackTrace(); } } }).start(); } }