as I mentioned I want to implement a backup/snapshot feature for my web app.
As for details, imagine each User has several Projects which has several Components which also has several Subcomponents. Those are the entities that I want to backup apart from User.
The goal that I want to achieve is that user may save the current state as a snapshot and later if he doesn't like the new configuration, can easily turn back to his save and there can be multiple snapshots. Those snapshots has to be read only.
I'm asking for a design architecture or style or any kind of idea to implement. That's why I didn't put my entities here.
Thanks, beforehand!
I have some similar versioning in a project where I manage that in a service by simply introduced another entity. In your case that would be a ProjectVersion and the Project has a list (OneToMany) of these versions and additionally a ManyToOne (or OneToOne) relation to one ProjectVersion called master. The Project itself has no more fields.
A few days ago I stumbled across #Version from java persistence API (not the spring one) and this annotation should help to automatically increase and manage a version value in the entity during updates. But I haven’t tested it myself.
Related
I have an application with file-supplier Srping Cloud module included. My workflow is like track file creating/modifying in particular directory->push events to Kafka topic if there are such events. FileSupplierConfiguration is used to configure this file supplier. But now I have to track one more directory and push events to another relevant Kafka topic. So, there is an issue, because there is no possibility to include multiple FileSupplierConfiguration in project for configuration another file supplier. I remember that one of the main principles of microservices for which spring-cloud-stream was designed for is you do one thing and do it well without affecting others, but it still the same microservice with same tracking/pushing functionality but for another directory and topic. Is there any possibility to add one more file supplier with relevant configuration with file-supplier module? Or is the best solution for this issue to run one more application instance with another configuration?
Yes, the best way is to have another instance of this application, but with its own specific configuration properties. This is really how these functions have been designed: microservice based on the convention on configuration. What you are asking really contradicts with Spring Boot expectations. Imaging you'd need to connect to several data bases. So, you only can have a single JdbcTemplate auto-configured. The rest is only possible manually. But better to have the same code base which relies on the auto-configuration and may apply different props.
Please ignore English grammar.
For Learning purpose I want to create a microservice project in Spring and I download some sample project and now I have some very basic
idea of microservices. But I am confused how I start my own project.
I want to implement the following simple use case.
In my database I have three table
Product,
ProductStock
and Order and I want to write microservice for each table.
Product microservice will have end point for crud operation.
ProductStock microservice will only have update stock and check stock end point.
Order microservice will only have posting order operation.
I create a multi module maven project and now I have following question.
1: Is creating multi module maven project is the only way to create microservices project.
2: I am using Hibernate so in which module(microservice) I create model classes. I need model classes in every module(microservice).
(Model classes are Product, ProductStock and Order).
3: Where I set hibernate confiuration.
Even if this question is way too broad, i'll try to answer your question as good as i can:
A multimodule project is not the only way (and i would even say, not a recommended way for different services). Usually you have completely separated Maven projects for each service.
Every service has to have its own data model and entity classes. Services should never share any entities, and should not access the same databases/schemas. They can use the same database server with different schemas.
In every service, which uses Hibernate.
The microservice architecture is not a trivial area so I would suggest to you that you start with some theory first. One of the books which is often referred here and there is Building Microservices By Sam Neuman. I highly recommend reading it or at least a part of it. This is the theoretical part.
Then for some hands on experiences you may want to clone/fork the PiggyMetrics project. This is an educational project but at the same time it contains quite a lot of patterns and advanced stuff.
After that you will be able to answer your own questions yourself, albeit there will be much more to ask ;-)
Good luck!
I have been playing with Spring Cloud Config and like many of the ideas I see there. I would like to better understand how its creators intended on it being used though.
Lets say that I have several services that support a larger API. Because these services are independent from each other, their source is managed in separate repositories. This allows us to version them and deploy them separately from one another. Today, their properties are managed individually.
I like the idea of having a single config server provide all of the configuration information for the individual applications/services that support this larger API. Looking at the default implementation of EnvironmentRepository (which is GIT based), I would have to have a single repository with all of my application config files in it. Because they all live within the same repository, they would all be managed/versioned together in a single place.
How do I make both models work with each other? Would it be better to have a repository per application instead of one for all applications? What are your thoughts?
-Joshua
It might just be a detail of the implementation of the EnvironmentRepository. See here for some discussion on how and when that might happen.
Just a general question on any techniques used to seperate your web application for customer specific requirements. At the moment I have one web application but I need to add new functionality for one customer thats not needed by another. I know spring 3 comes with new support for profiles but I'm just curious if anyone has had a similar problem and how they went about solving it particularly using spring mvc and maven as a build management tool
The proper way to do this would be as follows:
Have a web assembly module. This module will build a war file containing the proper features extracted into separate modules simply defined as dependencies. My advice is to have a separate web assembly project per client. This way you will keep things neat for yourself, avoid mix-ups (such as releasing features to clients who haven't paid for them) and have an overall easier maintenance.
Furthermore decide whether to do your version separation at the level of the version tag or classifier:
The version tag you can use in order to separate things in branches.
The classifier tag you can also use to separate configurations specific to your clients.
I was scheduled to begin work on a new project and decided to make my life easier by adopting a new technology that I had no experience with: Spring!
Specifically Spring Roo, and therein lies my problem.
Spring Roo does so much auto-magical stuff that I really do not know how to proceed. As this runs the risk of turning into a rant, let me be more specific and then follow it up with my question:
Spring works great for setting up my classes and persisting them with Hibernate and all that. The main problem I am having is in trying to scaffold my project.
I am working on a project that manages a few "set" references with many-to-many and many-to-one relationships. This immediately will have problem with the scaffolding application.
Trying to add Google Web Toolkit via 'gwt setup' kills the application immediately. Trying to load in Tomcat server becomes impossible and there is no way to undo the process (as far as I know). Now what? I have to restart my project from the original commands and reapply my changes as far as I can tell.
With this being said it seems to me that the best process is to use ROO to generate my project artifacts and then create my own View/Controller setup. Even here I am having problems though, because the tiles configuration seems so obscured from how it works. I am having a hard time figuring out how to take a custom JSP that can process some of these complex many-to-one relationships (AJAX enabled) and add it to my web front.
Are there any guides for this?
FYI: in the existing Roo Generated MVC I tried
Copying over my JSP
Creating a Form Backing Objects that wraps the different entity types
Modifying the views.xml file in the folder to recognize the page
One this was accomplished, though, I have been unsure how to proceed. How do I access my JSP? Manually typing the URL as it is defined in views.xml does not work.
Should I think about abandoning Roo altogether and starting a Spring project from scratch?
Bet way to learn Spring Roo
read documentation (Spring Roo, enter link description here)
experiment with Roo and watch console output. See files that change, what changes if you add new controller etc.
read and discuss matters in SpringSource forum
follow spring-roo tag in SO
Using Spring Roo for scaffolding
user version control system or backup project. If result does not satisfies you - rollback changes.
Eclipse or SpringSource Tool suite have have hiccups (1, 2). Be aware of them. Use mvn eclipse:clean eclipse:eclipse and re-import project if necessarily.
know the difference between MVC architectural pattern, Web MVC framework and GWT scaffold application.
know limitations and behaviour of scaffolding (ITDs: GWT Style, Expected GWT Add-On Behaviour, JSP Views)
know how Validation, Data Binding, and Type Conversion works, to use effetely in your views
investigate request pipeline (Adding a custom page in spring roo, Adding new Activity in GWT scaffolded app)