"Hystrix stream is not generating for my spring mvc application" - spring-mvc

I have a simple Spring MVC application. For that application I have Implemented Circuit Breaker Pattern using #EnableCircuitBreaker Annotation. It is working fine. But While trying to generate the hystrix stream it showing 404 error. Can anyone please help me out this.

Hystrix stream (/hystrix.stream) is only enabled if you have spring boot actuator dependency. Please try to add the below dependency into your pom or gradle build file.
org.springframework.boot:spring-boot-starter-actuator
Updated # 2017/06/26
If your application is not based on spring boot, you need to configure HystrixMetricsStreamServlet by yourself. Because /hystrix.stream is auto-configured by spring cloud netflix and it is based on spring boot.
First, you need to add dependency of com.netflix.hystrix:hystrix-metrics-event-stream into your application.
Second, you should HystrixMetricsStreamServlet servlet into web.xml like below.
<servlet>
<description></description>
<display-name>HystrixMetricsStreamServlet</display-name>
<servlet-name>HystrixMetricsStreamServlet</servlet-name>
<servlet-class>com.netflix.hystrix.contrib.metrics.eventstream.HystrixMetricsStreamServlet</servlet-class>
</servlet>
<servlet-mapping>
<servlet-name>HystrixMetricsStreamServlet</servlet-name>
<url-pattern>/hystrix.stream</url-pattern>
</servlet-mapping
If you find the details about how to configure HystrixMetricsStreamServlet in your web application here.

Related

How to add logging appender in spring boot configuration

I have a Spring Framework application and I am migrating it to Spring Boot. How to configure it in such a way that it can create log for each day?
This is my logging configuration so far:
logging.level.org.springframework.web=DEBUG
logging.level.org.hibernate=ERROR
From the docs
Spring boot will use Logback if its in the classpath. If you put a logback.xml in the root of your classpath it will be picked up from there automatically.
You can customize this logback.xml to provide your configurations for adding a rolling appender and so on based on your requirement. The documentation and the examples here will help you.
Update
You can even use log4j2 for logging. Just ensure that the correct dependencies are included. In that case, spring boot will check if there is a log4j2.xml in the classpath. You can provide the required configurations using log4j2.xml.

How can I add webflow using Spring Boot and Thymeleaf?

I have written a Spring web app for baseball umpires using Spring Boot and Thymeleaf. I like Spring Boot because it resolves dependency w/o a lot of configuration. Now I want to add Sprng WebFlow so umpires can order uniforms, a typical "shopping cart" application. There are many examples on the web but none using Spring Boot. They all are the traditional xml config with jsp and jstl. Has anyone used Spring Boot and WebFlow? There are WebFlow examples on the official Spring web site but very complicated. Thanks Rob
Spring Roo 2.0.0.M3 generates Spring Boot applications and integrates Spring Web Flow easier than ever.
The reference guide includes detailed descriptions of all the features, plus an extensive user guide for main use cases.

Router servlet for webservice project

In my recent project i started using maven , instead of depending on RAD to deploy and build ear, i have been coming across little things why to use , which one is best..
My question here is , below code i copied form web.xml and it us com.ibm.ws.websvcs.transport.http.WASAxis2Servlet servlet by ibm to route http request to web services, is there any servlet present from java that can replace the above one , we dont want our ear generation should be dependent on specific application server
<servlet>
<servlet-name>com.test.HelloWorld</servlet-name>
<servlet-class>com.ibm.ws.websvcs.transport.http.WASAxis2Servlet</servlet-class>
</servlet>
<servlet-mapping>
<servlet-name>com.test.HelloWorld</servlet-name>
<url-pattern>/HelloWorldService</url-pattern>
</servlet-mapping>
No.
The Servlet that you're seeing in the web.xml is an IBM-proprietary Servlet that routes HTTP requests to Web Services and, as far as I can tell, if you're running WAS 7.0 onwards you don't need it. You can simply use JAX-WS to annotate your Web Service class.
EDIT as per OP's comment
As you're using WAS 8.5, you have JavaEE 6.0 at your disposal. You don't need any router project anymore. IBM's proprietary router was needed in previous versions of WAS in order to route HTTP requests to Web Services and/or EJBs; however, with JavaEE 6.0, you can use JAX-WS in order to automatically intercept HTTP requests by Web Service classes as well as EJBs.
If you have a "router" project, you can safely throw it away.

Does Mule supports Spring MVC?

I have web app which is already developed based on Spring MVC. I need to re-implement that web app in Mule.
Can I develop the mule application based on Spring MVC?
Can I declare the Spring MVC dispatcher servlet inside a mule's servlet endpoint and take things further from there?
The web app has web.xml where it defines the DispatcherServlet, the contextparams, the listener classes and so on. How can we remodel that in a mule application?
Any examples where a mule application is developed based on SpringMVC would be great.
Thanks to its embedded Jetty container, you can deploy any JavaEE web application in Mule. So there's no need to remodel anything.
The "Boosktore" example application demonstrates running web-apps within Mule: https://github.com/mulesoft/mule/tree/mule-3.x/examples/bookstore
Mule ESB is not an MVC Framework. It is developed using enterprise integration patterns in mind.
Please go through this blog, to know when to use ESB.
spring mvc can be integrated with mule.
Define all your spring related configuration in separate xml file and include it in mule configuration file.
You can write your custom transformers ,in the custom transformations you can inject or do an autowire of your service classes and from service object you can interact with dao layers.

How to initialize a web app?

My Web App will be deployed as a WAR package in a Jetty instance. It needs to perform a lot of caching before serving requests. How do I call the caching method before anything else? is the a static void main() in the web app standard?
A standard (old) way is to code a Servlet which takes care of initialization stuff in its init() method. You force it to be initialized at application start by adding a load-on-startup positive value in your web.xml
<servlet>
<servlet-name>myinit</servlet-name>
<servlet-class>com.example.MyInitServlet</servlet-class>
<load-on-startup>2</load-on-startup>
</servlet>
Today it's more usual to have a bean container like Spring, which takes care of this kind of things (instantiating services objects, preloading cacheable sharable data, etc).
Note: this recipe is for webapps in general, not specific to Jetty.

Resources