I have a spring integration project that sends data to various sources via gateway and also fetching data from databases and updating certain tables.
It is working fine just there are so many points of failure and wish I could wrap the calls to these gateways with Netflix's Hystrix framework and have it displayed the Hystrix DashBoard.
All Ideas and Suggestions are welcomed.
Thanks
You can find all the info you need in the Hystrix GitHub repo page here.
Documentation regarding the dashboard is found in the same place, but in the master branch here
There are several ways to use the framework, but most commonly, you would wrap your service/call inside a HystrixCommand object, and fill the run() and fallback() methods. You can find an example here
Regarding the dashboard, you need to build the project and you can use it "out of the box"; that is if you don't want to go deep into its configuration. You will then be able to access it through your web explorer, and trace the calls from the service(s) that are wrapped up with Hystrix, by entering their URL in the dashboard homepage.
You can find additional documentation about the dashboard in the Hystrix wiki.
Related
It's not very clear to me what is the difference between the options below in https://start.spring.io/ select dependencies fields
Web -
Full-stack web development with Tomcat and Spring MVC
Rest Repositories -
Expressing Spring Data repositories over REST via
spring-data-rest-webmvc
The way I see it, Rest Repositories is pure backend dependencies..
I want to create( learn ) a spring project that has an endpoint to specify for a webhook consumption and can send HTTP request to APIs after doing some backend processing
What I understood is (in lame terms), Rest Repositories enable Spring to automatically add "our so-called Controller specific code" & allows developers to skip adding them for simple purposes.
e.g. this page here shows how easy it would be for us to directly query a DB without adding own API & Service layers.
Spring did it all for us. Plus it also added configurations to override them if we want.
Never used spring data rest but it look that it's main purpose is to make rest webservice over a datasource. I think this is limited.
So you should go with a Web full stack.
You can still do REST with it, and if you don't want view, just return json or anything.
I would like to set up a standalone swagger-ui application, to view the different APIs from different servers in one central place.
In a second step I would like to customise swagger-ui to show multiple APIs at once.
I don't want to add swagger-ui to all the servers that provide swagger api-docs though.
To do so I would like to use spring boot and thought this should be an easy task. However, I have trouble getting it to work.
Here is what I did:
Generated a Spring Boot application using https://start.spring.io
included spring-boot-starter-web
added io.springfox:springfox-swagger-ui:2.3.1 dependency
When opening http://localhost:8080/swagger-ui.html I see a 404 error and UI seems broken:
Is there any reason for using Spring-boot instead of a simple web server for this?
See for example here with Nginx, including some basic authentication (pretty old link but still looking alright), or in the ReadMe of the swagger-ui github reposiory directly for easily serving with Connect/gulp-serve inside Docker (the setup can also be reproduced directly without Docker if wanted).
Also I have no idea why you're getting resources requested by the page on a different port... Just ask in case you still need help now on this topic.
I am developing a jsp dynamic web project on eclipse.
I want to create an website with login functionality. I intend to store users' accounts and passwords in MySQL database. Of course, different users have different roles and rights to access different web pages. What is the best approach to implement it?
So far, I know these approaches:
1) Users enter accounts/passwords in login.jsp. LoginServlet then connects to MySQL database to check if it is correct. AuthenticationFilters will make sure only users with rights can access certain pages.
2) Use Role Based Authentication by declaring user roles in web.xml. I find this approach is not flexible, because I need to declare roles in advance.
3) Use HttpServletRequest's login/logout methods. I have not studied it.
Is my understanding correct? Could someone gives me some suggestions? Some clues would be very helpful!
Besides, I know that using POST alone to send passwords is not safe enough. Many websites suggest to use HTTPS connections. So if using HTTPS connections, does it affect the approach I choose to implement the login function?
Thanks!
--
Now, I know I need to use Spring. But Spring seems difficult for me... In Spring website I cant find out the link to download jar files. The user guide says I need to use Gradle or Maven, which I haven't used before, and have no idea why I need them. Besides, there are many Spring projects. Which one should I choose? Spring framework?
--
Have you looked into using Spring Security? It's built for just that. You don't need to be familiar with Spring but it may help.
Here are a couple of tutorials that use database authentication:
1: Spring Security Authentication and Authorization Example with Database Credentials
2: Spring Security Login Example with Database
Edit:
You don't have to Maven or Gradle. You can simply add the jars to your build path and they will work. The only projects you need to implement for the login to work is the Spring Framework and Spring Security.
To use Spring Security without Maven or Gradle:
Download the Spring Framework jars, unzip them, and add them to your project and build path. It's probably a good idea to find a hello world tutorial using Spring to get you started. A quick Google search should turn up many results.
After you have Spring implemented in your project, download the Spring Security jars, unzip those, and add them to your build path. The links to the tutorials that I previously posted will get you started. They may take a little while to go through and you may not understand exactly what is happening behind the scenes, but once you get it set up is works outstanding. I'm also not sure if you are using xml configuration or Java config but I believe those tutorials are for xml.
Spring Security was built so that it could be added to any project and have you up and running with basic configuration in about 15 minutes. After you get the basic login going (it will use the generic login form), you can search for how to implement your own custom login form, add permissions or restrictions to users and url patters, adding custom filters, etc. I encourage you to spend some time learning it as it is highly flexible and customizable.
I want to deploy an application with a web interface. I want to use Spring YARN for this because that eases all the basic setup, and I can start the application with java -jar.
What steps do I have to do to:
have my application expose a web interface
have the tracking URI I get when submitting it proxy to that web interface
Unfortunately, I cannot find anything about this on the net, there is npthing on that particular issue in the Spring documentation and Google searches do not get me the correct results either.
Easiest way to do this is simply use Spring YARN Boot application model and framework is then trying to do the heavy lifting on your behalf. I actually showed a demo of this during my session at SpringOne 2GX 2014. You can find my session recording from youtube https://www.youtube.com/watch?v=qlvX7_r9aUA.
Interesting stuff for this particular feature is at the end (starting from 1:16:22) and you can see how web server address is registered into YARN resource manager and how I query it using a Spring YARN Boot CLI (around 1:32:13). Spring YARN will actually see that there is an embedded servlet context and registers it automatically. In this demo property "server.port=0" makes tomcat to choose random port which is then registered.
Code for this particular UI demo can be found from github https://github.com/SpringOne2GX-2014/JanneValkealahti-SpringYarn/tree/master/gs-yarn-rabbit. Demo was around RabbitMQ just to have some real UI functionality and not just a dummy hello world page.
There's also more up-to-date sample in https://github.com/spring-projects/spring-hadoop-samples/tree/master/boot/yarn-store-groups which doesn't have a real UI(just Boot management endpoints). Thought it's relatively easy to add Spring MVC magic there just by following normal Boot functionality(i.e. following https://spring.io/guides/gs/rest-service).
Lemmy know if this helps!
I have a number of micro-services built with Spring Boot, so for a bit of fun, I thought I'd have a go at adding HATEOAS to them to help set up cross-resource linking. It seems to work quite nicely within a particular project, but I was wondering whether there's a good way to link across APIs. As an example, imagine I have 3 services:
A user details service:
Code:
/users/{userid}
A user calendar service:
Code:
/users/{userid}/appointments
/users/{userid}/appointments/{appointmentid}
A user messaging service:
Code:
/users/{userid}/messages
/users/{userid}/messages/{messageid}
To make this browsable via the API, it would be good to have links from a user resource to its appointments and messages. Similarly, it would be nice to have links back from those resources. This is all very achievable when I have a single API with everything on the classpath, where I can write code such as:
Code:
user.add(linkTo(methodOn(CalendarController.class).appointments(user.getKey())).withRel("appointments"))
However I'm not able to do this if CalendarController is not on the classpath of the service I'm currently hitting.
Is there a good/recommended method for creating links to controllers which are not in the current project?
Referenced from spring forums
Maybe this is a bit more involved than you were hoping, but as mentioned here, this is exactly what Eureka is for. It also has really nice integration with the new Spring Cloud project.