Java-Based Microservices Architecture and Abixen
Do you want to try microservices out but find yourself blocked? Well, Abixen has an open-source platform specifically made for Java-based microservices.
Join the DZone community and get the full member experience.Join For Free
microservices are getting constantly more and more popular. every month, there are more libraries and solutions supporting a development process, testing, and further support. many java developers have heard about the microservices approach, but a significant number of companies have not taken the challenge of implementing a microservices-based architecture. does this sound familiar?
"i know, microservices are awesome, microservices bring easier maintenance and further development, but we have no resources to build a good microservices-based architecture."
in this article, let us give a try to go through the architecture of abixen platform and explain how this solution helps java developers to start a microservices adventure. you can also find the platform on github .
a lot of developers who have tried to create a microservices-based application (e.g. using the netflix oss stack) have wondered if they have sufficient knowledge to configure the whole system. the situation here is very different to monolithic applications, as the extra components come along with desirable functionalities, like request monitoring, a queue for sharing communication between services, a registry service, a configuration service, and many others. it's also common to have a good database, as it's a good practice to keep a separate data model for each microservice.
when creating a modularized web application, developers have to be focused on a well-made domain design. minimizing all links between modules to a minimum avoids a complex architecture.
microservices architecture in the abixen platform
in the diagram below, you can see the key application elements of the abixen platform.
click to enlarge
in the diagram, we can find:
eureka : works as a registry service.
hystrix dashboard : allows us to monitor request status in real time (e.g. how many requests time out, how many are successful, how many fail, and so on).
zipkin : a distributed tracing system that helps gather timing data needed to troubleshoot latency problems in the application.
redis database : used for keeping information about signed-in users.
rabbitmq : used as a queue for sending messages between particular microservices. for example, in a case when the core microservice must remove a module instance and let the business intelligence service or web content service remove all configurations related to it.
abixen platform common : a jar containing a common api that can be implemented using a new functional microservice.
abixen platform configuration : a configuration microservice. here, an entire application can keep configs for each profile in yaml files.
abixen platform web client : static content of the core functionality, like page and module management, security management, and others.
abixen platform gateway : plays the role of a security gateway. each request must go through this microservice.
abixen platform core : has its own core database and holds the core functionalities of the platform, like page and module management, security management, etc.
abixen platform business intelligence service : since the application brings functional microservices, here is where we place a module for business intelligence reporting, chart creation, and further management. it also has its own database.
abixen platform web content service : this is similar to the above service, but this one brings content creation functionalities — e.g. a user is able to create articles. it also has its own database.
your services : a place designated for custom microservices created by developers using the platform.
the architecture is based on the netflix oss stack. the functional microservices are not required to properly work through the whole platform. if you want to use the platform, but say you don't need to report charts or an article manager, you can deploy the platform and use solely independently developed microservices.
the architecture is well-mapped to amazon components as well. an application can be deployed on aws using services like ec2, alb, ecs, ecr, route53, cloudwatch, elasticache, erd, and ses.
how does it work?
a user generates a request using a web client. through zuul proxy, the request is forwarded to the gateway. now, the gateway microservice performs security operations. if the user is not authenticated, it throws an "unauthorized" exception. if it is authenticated, then zuul proxy decides whether the request should be sent to core or a particular functional microservice, like business intelligence, web content, or one created by third-party developers. in the listing below, we can see a sample configuration of the routing:
zuul: host: connect-timeout-millis: 10000 socket-timeout-millis: 60000 routes: # begin of custom module microservices - add mapping relevant to your microservice # begin of business intelligence microservice businessintelligenceapplication: path: /service/abixen/business-intelligence/application/** url: http://business-intelligence-service:9091/service/abixen/business-intelligence/application sensitive-headers: businessintelligenceapplicationapi: path: /api/service/abixen/business-intelligence/application/** url: http://business-intelligence-service:9091/api/service/abixen/business-intelligence/application sensitive-headers: businessintelligenceadmin: path: /service/abixen/business-intelligence/control-panel/** url: http://business-intelligence-service:9091/service/abixen/business-intelligence/control-panel sensitive-headers: businessintelligenceadminapi: path: /api/service/abixen/business-intelligence/control-panel/** url: http://business-intelligence-service:9091/api/service/abixen/business-intelligence/control-panel sensitive-headers: # end of business intelligence microservice # begin of web content microservice webcontentapplication: path: /service/abixen/web-content/application/** url: http://web-content-service:9092/service/abixen/web-content/application sensitive-headers: webcontentapplicationapi: path: /api/service/abixen/web-content/application/** url: http://web-content-service:9092/api/service/abixen/web-content/application sensitive-headers: webcontentadmin: path: /service/abixen/web-content/control-panel/** url: http://web-content-service:9092/service/abixen/web-content/control-panel sensitive-headers: webcontentadminapi: path: /api/service/abixen/web-content/control-panel/** url: http://web-content-service:9092/api/service/abixen/web-content/control-panel sensitive-headers: # end of web content microservice # end of custom module microservices resource: path: /resource/** url: http://core:9000 sensitive-headers: api: path: /api/** url: http://core:9000/api sensitive-headers:
either a particular functional microservice or core serves content adequate to the request. core supports only a rest. despite this, the functional microservices can handle requests for both a rest and a static content. the mentioned components support an authorization process — that is why they are able to throw a forbidden exception.
developers who want to create their own functional microservice can leverage a generic api, where they can find both abstracts and interfaces. the service must obtain a deployment descriptor. this file describes what modules a developer included inside, what static resources are available, and if there is any configuration panel in a control panel (because there is an opportunity for further configuration in the control panel). in the listing below, we cover a sample deployment descriptor of a microservice:
the core microservice uses the descriptor to get information about the functional microservice and, based on this, injects all the delivered features to the platform.
as we can see, java developers do not have to create a whole microservices architecture from scratch. if it suits your needs, we've covered a ready-made solution and started the development of functional microservices. of course, there may be situations where modifications of areas other than one's own microservices will be required, but still, the architecture exists.
Opinions expressed by DZone contributors are their own.