tag:blogger.com,1999:blog-6083591398829367286.post2483944636182117570..comments2024-02-23T02:47:40.444-08:00Comments on Code Breeze !: Asynchronous Spring MVC – Hello World ExampleSheng Wanghttp://www.blogger.com/profile/05937490114133583753noreply@blogger.comBlogger12125tag:blogger.com,1999:blog-6083591398829367286.post-30571270295607143902017-06-19T08:37:40.026-07:002017-06-19T08:37:40.026-07:00this is not working for methis is not working for meAurelianohttps://www.blogger.com/profile/10763565520097467236noreply@blogger.comtag:blogger.com,1999:blog-6083591398829367286.post-68148819400923351172017-04-04T08:44:07.691-07:002017-04-04T08:44:07.691-07:00Of course, MDC is just for Request Context (In oth...Of course, MDC is just for Request Context (In other word, ThreadLocal of Request)<br />When you call MDC in other thread -> Difference from ThreadLocal.<br />So, you must create other map to store you MDC and then pass it down the pipeline.<br />Ex:<br />Map ctx = MDC. getCopyOfContextMap();<br />Callable x = new Callable(){<br />public Object call(){<br />String myId = ctx.get("your-key");<br />log.("{}", myId);<br />return ;<br />}<br />};Anonymoushttps://www.blogger.com/profile/14288914814071883088noreply@blogger.comtag:blogger.com,1999:blog-6083591398829367286.post-60343396863609350512016-11-12T09:07:44.082-08:002016-11-12T09:07:44.082-08:00Spring sync mvc is not design for this actually, i...Spring sync mvc is not design for this actually, it is for optimization on server side. For browser<->server interaction, the big picture is still the same(i.e blocking). leonhttps://www.blogger.com/profile/04471025968275159904noreply@blogger.comtag:blogger.com,1999:blog-6083591398829367286.post-56704466285262728762016-07-20T20:28:27.902-07:002016-07-20T20:28:27.902-07:00browser doesn’t get response until 3 seconds later...browser doesn’t get response until 3 seconds later, all threads finish. can browser get<br /> response when main thread finish,if some thread is time-consuming,the custormer will wait for a long time<br />Anonymousnoreply@blogger.comtag:blogger.com,1999:blog-6083591398829367286.post-40671679014993010382016-05-10T08:01:56.802-07:002016-05-10T08:01:56.802-07:00Hi Sheng. Could you give me an example using this ...Hi Sheng. Could you give me an example using this project with MDC Logger? I'm trying to use Spring MVC Rest Async but when I try to use MDC but I've lost the reference and the MDC logger doesn't work. Could you help me, please?<br />Thanks!Anonymoushttps://www.blogger.com/profile/09015782388884099791noreply@blogger.comtag:blogger.com,1999:blog-6083591398829367286.post-4881499565656196882015-12-22T15:49:44.739-08:002015-12-22T15:49:44.739-08:00Sheng, Thanks a lot for your article. I followed y...Sheng, Thanks a lot for your article. I followed your instruction. That's how I started getting our application to switch to Spring MVC async using Callable. The following articles are also useful.<br />https://docs.spring.io/spring/docs/current/spring-framework-reference/htmlsingle/#mvc-ann-async (Which give an overall picture and If you use java filter and Spring MVC interceptor), http://docs.spring.io/spring/docs/current/javadoc-api/org/springframework/web/servlet/AsyncHandlerInterceptor.html (Useful for MVC interceptors too).<br /><br /> Our async application is deployed in Tomcat. That works fine. However, I just couldn't get one test passed. Our tests use embedded Jetty 8 server. I traced and found.out that Spring MVC will return 404 Not Found "No mapping request found for HTTP request URI....". if the async web request execution time is longer than 100ms, Very similar requests with execution time < 100ms works fine in embedded Jetty 8. Similar requests with async web request taking longer than 1 second (due to remote Mongodb) work fine in Tomcat. I configured default-timeout in mvc:async-support. It does not look like it has something to do with this issue.<br /><br />According to timeout section in the article<br />https://spring.io/blog/2012/05/10/spring-mvc-3-2-preview-making-a-controller-method-asynchronous/, <br />"You can configure the timeout value (of async web request) through the MVC Java config and the MVC namespace, or directly on the RequestMappingHandlerAdapter. If not configured, the timeout value will depend on the underlying Servlet container. On Tomcat it is 10 seconds and it starts after the initial Servlet container thread exits all the way out."<br /><br />That seems to match what I experienced. It did not elaborate how to do that. Let me know if you know any solution. Currently, I am research on <br />spring.mvc.async.request-timeout (preferred) and also if I can override embedded Jetty server servlet (async) request timeout <br /><br /> <br />threecupteahttps://www.blogger.com/profile/14651406363321158795noreply@blogger.comtag:blogger.com,1999:blog-6083591398829367286.post-29769874627936796762015-12-03T04:53:27.116-08:002015-12-03T04:53:27.116-08:00Hi Sheng, How we can download your source code (th...Hi Sheng, How we can download your source code (this project)? <br />Thanks,<br />SayaliAnonymousnoreply@blogger.comtag:blogger.com,1999:blog-6083591398829367286.post-83020355636508646382015-11-12T19:20:46.570-08:002015-11-12T19:20:46.570-08:00The controller can only response to the user(brows...The controller can only response to the user(browser) ONCE. Async Servlet is designed to improve server's performance by reduce thread number in large concurrent environment. For your requirement, sending out multi-times from controller, use websocket or long-poll instead. Sheng Wanghttps://www.blogger.com/profile/05937490114133583753noreply@blogger.comtag:blogger.com,1999:blog-6083591398829367286.post-39661807799493848062015-11-11T12:03:38.734-08:002015-11-11T12:03:38.734-08:00Hi,
Very much appreciated of your detailed explan...Hi, <br />Very much appreciated of your detailed explanation.<br />I would like to use spring mvc async support as described by you, but i would like to have event notification service from the controller response, which keeps sending out events. Can you please let me know how can this be accomplished, as the async support discussed above will return a single response asynchronously but it does not send multiple outputs in intervals.<br /><br />Thanks<br />NareshAnonymoushttps://www.blogger.com/profile/07370624564859918781noreply@blogger.comtag:blogger.com,1999:blog-6083591398829367286.post-9194173430513617472015-09-29T22:12:01.343-07:002015-09-29T22:12:01.343-07:00I haven't use maven in the application. the as...I haven't use maven in the application. the async support turns on. controller is working but async part is not. If possible could i share the application with you. Anonymousnoreply@blogger.comtag:blogger.com,1999:blog-6083591398829367286.post-58486365006853436412015-09-28T08:08:28.663-07:002015-09-28T08:08:28.663-07:00Hi there, I can't point out exactly but sounds...Hi there, I can't point out exactly but sounds like async doesn't work. First make sure you have correctly reach the right method in your controller, then maybe you should check if you have turn async support on in web.xml and make sure you do reply a callable for your controller method.Sheng Wanghttps://www.blogger.com/profile/05937490114133583753noreply@blogger.comtag:blogger.com,1999:blog-6083591398829367286.post-1671476419047229392015-09-27T23:46:14.740-07:002015-09-27T23:46:14.740-07:00Hi Thanks for this demo.... but after reaching th...Hi Thanks for this demo.... but after reaching the controller it's giving me directly the index page without performing the doslowwork() method part. Please helpAnonymousnoreply@blogger.com