- Is Spingboot thread-safe?
It depends. The main factor which determines the thread-safety of a component is its scope.
In a standard servlet-based Spring web application, every new HTTP request generates a new thread. If the container creates. a new bean instance just for that particular request, we can say this bean is thread-safe.
Is Spring singleton thread-safe?
The short answer is: no, it isn't.
Reference: http://dolszewski.com/spring / spring-bean-thread-safety-guide /
- Different scopes of beans ?
- singleton : Singleton is the default scope for a Bean
- prototype
- request
- session
- application
- websocket
- What are the disadvantages of Springboot?
- What are different design patterns you use in the Microservices ?
- How do we implement spring security?
start by creating a Spring Security configuration class that extends WebSecurityConfigurerAdapter . By adding @EnableWebSecurity, we get Spring Security and MVC integration support.
rest security
security config class-
basic auth
authentication filter-> authentication object-> not validated-> authentication manager builder->
finds authetication providers-> like DAO or custom authentication provider
we can pass JWT token in header for authentication.
server validates if it is generated by itself.
session-based vs token based security.
tokens are stateless
requests can go to any node which doesn't understand previous session settings.
What is Bearer (ur the owner of the token) Vs Basic
after authentication is done only we get JWT token which is used for authorization
JWT --OAUTH Grant Types:
implicit --Implicit Grant
authorization_code --Authorization Code Grant- This grant type flow is also called "three-legged" OAuth.
You've seen this flow anytime your app opens a browser to the resource server's login page and invites you log in to your actual account (for example, Facebook or Twitter).
If you successfully log in, the app will receive an authorization code that it can use to negotiate an access token with the authorization server.
client_credentials --Client Credentials Grant
password --Resource Owner Password Grant
refresh_token --Use Refresh Tokens
urn: ietf: params: oauth: grant-type: device_code --Device Authorization Grant
Reference: https://developer.okta.com/blog/2018/10/05/build-a-spring-boot-app-with-user-authentication
3. How to cancel an order for user-specific settings at the spring level?
3b. Multi calls between ms to ms?
Using discovery services like Eureka we can route calls between internal microservices effectively.
- How do we resolve cyclic dependency issues in Springboot?
By using @Lazy annotation on the dependency we can resolveor avoid constructor based injection in SB and use setter based injection
- Tomcat Max Threads settings in Springboot application?
server.tomcat.max-connections | 8192 |
Maximum number of connections that the server accepts and processes at any given time. Once the limit has been reached, the operating system may still accept connections based on the "acceptCount" property.
|
server.tomcat.max-http-form-post-size | 2MB |
Maximum size of the form content in any HTTP post request.
|
server.tomcat.max-swallow-size | 2MB |
Maximum amount of request body to swallow.
|
server.tomcat.max-threads | 200 |
Maximum amount of worker threads.
|
server.tomcat.mbeanregistry.enabled | false |
Whether Tomcat's MBean Registry should be enabled.
|
server.tomcat.min-spare-threads | 10 |
Minimum amount of worker threads.
|
server.tomcat.port-header | X-Forwarded-Port |
Name of the HTTP header used to override the original port value.
|
server.tomcat.processor-cache | 200 |
Maximum number of idle processors that will be retained in the cache and reused with a subsequent request. When set to -1 the cache will be unlimited with a theoretical maximum size equal to the maximum number of connections.
|
server.tomcat.protocol-header |
Header that holds the incoming protocol, usually named "X-Forwarded-Proto".
|
https://docs.spring.io/spring-boot/docs/current/reference/html/appendix-application-properties.html
- Sort Employee salary using Java Streams and display salary which is greater than X amount? Java 8 --streams, lambda expression
// find employees whose salaries are above 10000
empList.stream().filter(emp->emp.getSalary() >
10000
).forEach(System.out::println);
Reference:
https://www.java2novice.com/java-8/streams/filter-method-example/
- Spring boot --Dependency injection types?
There are basically three types of dependency injection:
constructor injection: the dependencies are provided through a class constructor.
setter injection: the client exposes a setter method that the injector uses to inject the dependency.
Interface injection: the dependency provides an injector method that will Clients must implement an interface that exposes a setter method that accepts the dependency.
So now its the dependency injection's responsibility to:
- Create the objects
- Know which classes require those objects
- And provide them all those objects
- How do we do monitoring of REST APIS ?
- How do we call External Microservices in Springboot REST APIS ?
Resttemplate : getForEntity(gets full responseEntity) vs getForObject (only object we get)
exchange also do the same
- What are status codes for DELETE API ?
Right Status codes for delete - 204 - content not found
200 - OK
- Why Do we need Timeout setting in REST APIs ?
For each request, a thread is blocked.
at one point in time threads will be out. so time out is needed to release threads. Default is 200 threads in thread pool.
Ex :Read time out(not able to complete reading data) , server time out (not able to get connection)
- Versioning in REST APIs ?
the new functionality will be rolled with new version apis
using request param or path param
also using headers
uri @Getmapping
- What is content negotiation in the REST ?
mediatype : Produces or consumes is nothing but content negotiation.
- What are cross-cutting concerns?
AOP - for logging purposes,
security setup using Request Filters, and Interceptors for managing requests and response data
- How do you create custom annotation in spring boot?
STEP1: Create an interface with the annotation name
STEP2: Create an Aspect
STEP3: Add the annotation
@Target(ElementType.METHOD)
@Retention(RetentionPolicy.RUNTIME)
public @interface Traceable {
}
- Pagination and Sorting using Spring Data JPA
public interface ProductRepository extends PagingAndSortingRepository<Product, Integer> {
List<Product> findAllByPrice(double price, Pageable pageable);
}
Conversely, we could have chosen to extend JpaRepository instead, as it extends PagingAndSortingRepository too.
HATEOAS constraint of REST means enabling the client of the API to discover the next and previous pages based on the current page in the navigation.
we're going to use the Link HTTP header, coupled with the “next“, “prev“, “first” and “last” link relation types.
In the case of pagination, the event – PaginatedResultsRetrievedEvent – is fired in the controller layer. Then we'll implement discoverability with a custom listener for this event.
- REST Controller
@Api
@RequestMapping("/v1")
public interface ProfileV1Interface{
@ApiOperation(value = "Api to Get a specific setting for a cluster", notes = "Get a specific setting for a Cluster")
@GetMapping(value = "/cluster/{name}/settings", produces = MediaType.APPLICATION_JSON_VALUE)
Map<String, String> getClusterSetting(@RequestParam(required = true) String clusterId,@PathVariable(required = true) String name);
}
- @autowire Vs @Inject
@Autowired
is Spring's own annotation. @Inject
is part of a Java technology called CDI that defines a standard for dependency injection similar to Spring. In a Spring application, the two annotations work the same way as Spring has decided to support some JSR-299 annotations in addition to their own.
- Tell me some important annotations in springboot?
@Controller: The @Controller is a class-level annotation. It is a specialization of @Component. It marks a class as a web request handler. It is often used to serve web pages. By default, it returns a string that indicates which route to redirect. It is mostly used with @RequestMapping annotation.
0 comments to "Java Springboot Microservices FAQs"
Popular Posts
-
The best solution to know about these init levels is to understand the " man init " command output on Unix. There are basically 8...
-
How to Unlock BSNL 3G data card to use it with Airtel and Vodafone Model no : LW272 ? How to unlock BSNL 3G data card( Model no : LW272 )us...
-
How to transfer bike registration from one State to other (Karnataka to Andhra)?? Most of us having two wheelers purchased and registered in...
-
ఓం శ్రీ స్వామియే శరణం ఆయ్యప్ప!! Related posts : Trip to Sabarimala - Part 1 Trip to Sabarimala - Part 2 Ayappa Deeksha required things...
-
Following are some of interesting blogs I found till now ...please comment to add your blog here. Blogs in English : http://nitawriter.word...
Popular posts
- Airtel and vodafone GPRS settings for pocket PC phones
- Andhra 2 America
- Ayyappa Deeksha required things
- Blogs I watch !
- Captions for your bike
- DB2 FAQs
- Deepavali Vs The Goddes of sleep
- ETV - Dhee D2 D3
- Evolution of smoking in India Women
- How to make credit card payments?
- init 0, init 1, init 2 ..
- Java-J2EE interview preparation
- mCheck Application jar or jad download
- My SQL FAQs
- My Travelogues
- Old is blod - New is italic
- Online pay methids for credit cards
- Oracle FAQs
- Pilgrimages
- Smoking in Indian Women
- Technology Vs Humans
- Twitter feeds for all Telugu stars on single page.
- Unix best practices
- Unix FAQs
Post a Comment
Whoever writes Inappropriate/Vulgar comments to context, generally want to be anonymous …So I hope U r not the one like that?
For lazy logs, u can at least use Name/URL option which doesn’t even require any sign-in, The good thing is that it can accept your lovely nick name also and the URL is not mandatory too.
Thanks for your patience
~Krishna(I love "Transparency")