diff --git a/examples/showcase/src/main/java/org/springside/examples/showcase/demos/hystrix/web/HystrixDemoController.java b/examples/showcase/src/main/java/org/springside/examples/showcase/demos/hystrix/web/HystrixDemoController.java index bfc029e0..b1dd0d78 100644 --- a/examples/showcase/src/main/java/org/springside/examples/showcase/demos/hystrix/web/HystrixDemoController.java +++ b/examples/showcase/src/main/java/org/springside/examples/showcase/demos/hystrix/web/HystrixDemoController.java @@ -16,6 +16,7 @@ import org.springside.examples.showcase.demos.hystrix.dependency.DependencyResou import org.springside.examples.showcase.demos.hystrix.service.UserService; import org.springside.examples.showcase.webservice.rest.RestException; import org.springside.examples.showcase.webservice.rest.UserDTO; +import org.springside.modules.web.MediaTypes; import com.google.common.collect.Maps; @@ -24,7 +25,7 @@ public class HystrixDemoController { private static Logger logger = LoggerFactory.getLogger(HystrixDemoController.class); - private static Map allStatus = Maps.newHashMap(); + private static Map allStatus = Maps.newLinkedHashMap(); static { allStatus.put("normal", "正常"); @@ -44,7 +45,7 @@ public class HystrixDemoController { return "story/hystrix"; } - @RequestMapping(value = "/hystrix/user/{id}", method = RequestMethod.GET) + @RequestMapping(value = "/hystrix/user/{id}", method = RequestMethod.GET, produces = MediaTypes.JSON_UTF_8) @ResponseBody public UserDTO getUser(@PathVariable("id") Long id) { try { diff --git a/examples/showcase/src/main/webapp/WEB-INF/views/story/hystrix.jsp b/examples/showcase/src/main/webapp/WEB-INF/views/story/hystrix.jsp index f866f963..33415f03 100644 --- a/examples/showcase/src/main/webapp/WEB-INF/views/story/hystrix.jsp +++ b/examples/showcase/src/main/webapp/WEB-INF/views/story/hystrix.jsp @@ -11,6 +11,15 @@ $(document).ready(function() { $("#hystrix-tab").addClass("active"); }); + + function accessHystrixService() { + $.ajax("${ctx}/hystrix/user/1") + .done( function(data,textStatus ,jqXHR) { + $('#hystrixResponse').text('Status: '+jqXHR.status+' ,Content: ' + jqXHR.responseText ); + }).fail( function(data,textStatus ,jqXHR) { + $('#hystrixResponse').text('Status:' + textStatus ); + }); + } @@ -20,9 +29,10 @@

Netflix Hystrix 是一个延迟与容错类库,通过独立访问远程系统、服务和第三方库的节点,在复杂的分布式系统里停止雪崩及提供恢复能力。

演示操作

-
依赖资源当前状态为:
-
访问服务:Hystrix服务、依赖资源
- +
依赖资源状态:
+
+
+

主要用户故事