<?xml version="1.0" encoding="UTF-8"?>
<rss version="2.0" xmlns:content="http://purl.org/rss/1.0/modules/content/" xmlns:dc="http://purl.org/dc/elements/1.1/" xmlns:atom="http://www.w3.org/2005/Atom">
<channel>
	<title>Architecture – Elder Moraes</title>
	<atom:link href="https://eldermoraes.com/category/architecture/feed/" rel="self" type="application/rss+xml" />
	<link>https://eldermoraes.com</link>
	<description>Backend | Java | Quarkus | AI | Career</description>
	<language>en-US</language>
	<item>
		<title>You don't need microservices</title>
		<link>https://eldermoraes.com/you-dont-need-microservices/</link>
		<pubDate>Wed, 12 Aug 2020 00:00:00 +0000</pubDate>
		<category><![CDATA[Architecture]]></category>
		<category><![CDATA[Microservices]]></category>
		<guid isPermaLink="false">https://eldermoraes.com/?p=2622</guid>
		<description><![CDATA[In this post, I'll show you that maybe you are choosing microservices for the wrong reasons. I published a video about it. Check it out: If you are here probably you are in one of these situations: You want to start using microservices You are already using it In both cases, you want to use…]]></description>
		<content:encoded><![CDATA[<p>In this post, I'll show you that maybe you are choosing microservices for the wrong reasons.</p>
<p>I published a video about it. Check it out:</p>
<div class="yt-embed"><iframe src="https://www.youtube-nocookie.com/embed/jmyLDVbc8Ws" title="YouTube" loading="lazy" allowfullscreen></iframe></div>
<p>If you are here probably you are in one of these situations:</p>
<ol>
<li>You want to start using microservices</li>
<li>You are already using it</li>
</ol>
<p>In both cases, you want to use it right and for the right reasons. At least I hope so…</p>
<p>When I go to conferences is common that people ask me about "<em>how to start using microservices?</em>", "<em>what are the best practices?</em>", and so on… and I always ask them the same question: "<em>why do you want to use microservices?</em>".</p>
<p>The usual answers that I got are:</p>
<ul>
<li>To scale my application</li>
<li>To have smaller artifacts</li>
<li>To save memory (what?)</li>
</ul>
<p>I even got an answer from a big company where people said: "<em>because our manager demanded it</em>"... Ouch!</p>
<p>Let me tell you: all those answers are conceptually wrong! And the reason is:</p>
<blockquote>
<p>You are using microservices to scale software, but it was made to scale people.</p>
</blockquote>
<p>At this point, maybe you are uncomfortable on your chair, you are frowning, your disagreeing, or even you are mad at me! </p>
<p>I get it… give me a few minutes and I'll explain it to you! ;-)</p>
<p>The reason why I'm saying that microservices are made to scale people is a foundation. A concept. A law. Something called "Conway's Law". It states that:</p>
<blockquote>
<p><em>Any organization that designs a system will produce a design whose structure is a copy of the organization's communication structure.</em></p>
</blockquote>
<p>This was said by Mr. Melvin Conway in a paper written in… 1967! The link to the paper is at the end of this post.</p>
<p>Basically what Mr. Conway is saying is that the structure of your software is directly related to the communication structure of your organization. The way your company communicates is the way that it builds software.</p>
<p>But… how Melvin Conway came to this conclusion?</p>
<p>(I know, you are wondering what the hell all this has to do with microservices? You will get it, I promise…)</p>
<p>In this paper, he mentions a project where the team had 8 people and they needed to deliver two compilers: one for COBOL and another for ALGOL. After some discussions, they decided to assign 5 people for the COBOL compiler and 3 people for the ALGOL compiler.</p>
<p>At the end of the project they had: </p>
<ul>
<li>A COBOL compiler that worked in 5 phases</li>
<li>An ALGOL compiler that worked in 3 phases</li>
</ul>
<p>In the paper, you'll see more examples of this human behavior when building software.</p>
<p>So basically it was a sociological observation that ended in a technological result. Interesting, right?</p>
<p>Alright, back to microservices! What does it have to do with Conway's Law?</p>
<p>Let's perform a mental exercise. </p>
<p>Imagine that one company has 3 teams:</p>
<ul>
<li>DBA team</li>
<li>UI team</li>
<li>Middleware team</li>
</ul>
<p>Those teams are organized around themselves. DBAs working together, UI people as well, and so on...</p>
<p>Then let me ask you three questions:</p>
<ul>
<li>What the DBA team will deliver?</li>
<li>What the UI team will deliver?</li>
<li>What the Middleware team will deliver?</li>
</ul>
<p>It's quite obvious! DBAs will deliver databases, UI people will deliver UI, and Middleware devs will deliver services, APIs, and things like this.</p>
<p>This is called a siloed structure and it's the classical structure used for companies that build monolith applications.</p>
<p>Now let's imagine another company. It also has 3 teams, but they are structurally quite differently:</p>
<ul>
<li>Team 1 has a DBA, a UI dev and a Middleware dev;</li>
<li>Team 2 has also a DBA, a UI dev and a Middleware dev;</li>
<li>Team 3, guess what, also has a DBA, a UI dev, and a Middleware dev.</li>
</ul>
<p>These are what we call cross-functional teams.</p>
<p>Now the one and only question for this company: what each team will deliver?</p>
<p>The tendency of each one of these teams is to deliver what we call a self-contained application. A deliverable that has a database, a UI, and a Middleware.</p>
<p>Can this deliverable be considered a monolith? Well, yes. But a very small one, because the team that built it is smaller.</p>
<p>If it's smaller, it needs to be more specific, more specialized. It addresses one business task that has interactions with the other business tasks built by the other teams.</p>
<p>That's the so-called… microservices!</p>
<p>This concept of siloed and cross-functional teams that led us from monoliths to microservices is very well explored in the famous article about microservices written by Martin Fowler. </p>
<p>In fact, this article is so important that a lot of people include it in the history of microservices. The link to the article is at the end of this post.</p>
<p>Ok! So far you know:</p>
<ul>
<li>Conway's Law</li>
<li>Companies' communication structure reflects the structure of their software</li>
<li>Siloed structured companies tend to deliver monoliths</li>
<li>Cross-functional companies tend to deliver microservices</li>
</ul>
<p>After all… why did I say that you can be thinking about microservices for the wrong reasons?</p>
<p>Because another thing that I also said: <strong>microservices is something made to scale people, not software.</strong></p>
<p>If you look to the companies who are well succeeded using microservices (Amazon, Netflix, Uber, Spotify, to name a few), what they have in common?</p>
<p>When they started getting really big they noticed they had a need of:</p>
<ol>
<li>To scale their team management</li>
<li>To do it without loose agility (increasing it, actually)</li>
</ol>
<p>So they came to the conclusion that they needed smaller and self-managed teams. </p>
<p>And for those teams to have more agility, they needed to be as decoupled as possible from the other teams, for the sake of independence.</p>
<p>So these teams needed to be cross-functional and empowered enough to make their own decisions related to technology (languages, databases, etc).</p>
<p>(And yes, decoupled teams tend to generate decoupled services! Conway's Law again...)</p>
<p>And suddenly it was born: the microservices!</p>
<p>Notice that all start with a *need*. A need to rearrange the company structure, a need to distribute the teams, a need to increase communication agility. </p>
<p>In this scenario, microservices are inevitable. And if you don't have any of these needs, you don't need microservices as well.</p>
<p>Alright? I hope I've made my point clear here, and I'm looking forward to seeing your comments about it, so do not hesitate to leave them down below.</p>
<p>References:</p>
<ul>
<li><a href="http://www.melconway.com/Home/Committees_Paper.html">http://www.melconway.com/Home/Committees_Paper.html</a></li>
<li><a href="https://martinfowler.com/articles/microservices.html">https://martinfowler.com/articles/microservices.html</a></li>
</ul>
]]></content:encoded>
	</item>
	<item>
		<title>5 design patterns for microservices with Quarkus and MicroProfile</title>
		<link>https://eldermoraes.com/5-design-patterns-for-microservices-with-quarkus-and-microprofile/</link>
		<pubDate>Mon, 13 Jul 2020 00:00:00 +0000</pubDate>
		<category><![CDATA[Architecture]]></category>
		<category><![CDATA[Kubernetes]]></category>
		<category><![CDATA[Microprofile]]></category>
		<category><![CDATA[Microservices]]></category>
		<guid isPermaLink="false">https://eldermoraes.com/?p=2614</guid>
		<description><![CDATA[Before getting started, you may want to check my book "5 Steps to an extraordinary career", which will guide you to build your dream career as a software developer! Click here to check it out. Have you ever had any doubts about how to start your microservices-based application from scratch? Or how to break down…]]></description>
		<content:encoded><![CDATA[<p><strong>Before getting started, you may want to check my book "<a href="https://eldermoraes.com/5steps"><em>5 Steps to an extraordinary career</em></a>", which will guide you to build your dream career as a software developer! <a href="https://eldermoraes.com/5steps">Click here to check it out</a>.</strong></p>
<p> </p>
<p>Have you ever had any doubts about how to start your microservices-based application from scratch? Or how to break down your monolith into many microservices?</p>
<p>Usually, the answers to these questions are not unique, not even likely, which is not helpful at all. What brings another question: is there any safe and solid path that I can follow to have success on my microservices projects?</p>
<p>You bet! Microservices have some specific design patterns that can be a life saving for any project, and this post will show you some of the best of them.</p>
<p>If you are much more a visual person (or would like to see all the code here really working), check its related video:</p>
<div class="yt-embed"><iframe src="https://www.youtube-nocookie.com/embed/DOKscFylOwY" title="YouTube" loading="lazy" allowfullscreen></iframe></div>
<p>When using microservice for your projects it's important to do it in the right way and using the right approach, no matter if you are breaking down your monolith or starting a new project using microservice from scratch.</p>
<p>When doing it using design patterns, you'll be able to not only do it properly but also with less effort.</p>
<p>And of course, there are a lot of design partners for microservices. If you ever checked the content of Chris Richardson (which I recommend 100%) you know that he has mapped something around 40 to 50 microservices patterns. That's a lot! And so useful.</p>
<p>Today I'll cover five of them here and they are:</p>
<ul>
<li>Externalized Configurations</li>
<li>Circuit Breaker</li>
<li>Health Check</li>
<li>Distributed Tracing</li>
<li>API Metrics</li>
</ul>
<h2>Creating the project</h2>
<p>I create my projects using the site: <a href="http://code.quarkus.io">http://code.quarkus.io</a></p>
<p>If you do the same, configure your project with your preferences and choose these extensions:</p>
<ul>
<li>REST Client</li>
<li>SmallRye Fault Tolerance</li>
<li>SmallRye Health</li>
<li>SmallRye OpenTracing</li>
<li>SmallRye Metrics</li>
</ul>
<p>When you are ready, click the "Generate your application" button, download the file, and unzip it.</p>
<h2>Externalized Configuration</h2>
<p>This is the code of an endpoint that is using an externalized configuration:</p>
<p><a href="https://gist.github.com/eldermoraes/76185aedf5610a0b5f1194121765b3e6">https://gist.github.com/eldermoraes/76185aedf5610a0b5f1194121765b3e6</a></p>
<p>If you compile and execute this code just as it is here, it will print:</p>
<pre><code>Hello, Optional
</code></pre>
<p>Because it can't find the "config" property anywhere. So let's add it to your applications.properties file (available in the "resources" folder if you created your project as stated in the previous section):</p>
<p><a href="https://gist.github.com/eldermoraes/7f8c7ce96ea751e44f5ddc2ab24a2ae0">https://gist.github.com/eldermoraes/7f8c7ce96ea751e44f5ddc2ab24a2ae0</a></p>
<p>Now, if you compile and execute your code again, it will print:</p>
<pre><code>Hello, Config
</code></pre>
<p>It's better because it's getting the value from a config property, but it's still not so good because the property it's still inside the project. So let's move it to the environment.</p>
<p>If you are running your project using the Quarkus plugin for Maven you probably did something like this:</p>
<pre><code>mvn compile quarkus:dev
</code></pre>
<p>So do it instead:</p>
<pre><code>mvn compile quarkus:dev -Dconfig=Quarkus
</code></pre>
<p>Now if you execute the code it will print:</p>
<pre><code>Hello, Quarkus
</code></pre>
<p>This externalized configuration can be at your container, your server, your cluster, wherever your application is running, It will get the configuration from the environment.</p>
<h2>Circuit Breaker</h2>
<p>Imagine in your house where you have your electrical circuit where all the outlets and lights and are connected. And the circuit is closed because everything is going well.</p>
<p>But once you have some problem inside the circuit (a short circuit, overload, etc), it will open. That way the energy will not flow inside the circuit anymore, keep this energy problem away from your home appliances.</p>
<p>The same happens when we are using microservices and apply the circuit breaker pattern. Once you have some failing microservice the circuit will open. By doing this it will not start a cascade of failing inside your "circuit" (=your microservices that are communicating to each other). </p>
<p>For example, if you have a microservice giving a timeout error, the circuit will open and it will return an error right away, with no needing to all incoming requests to wait for the timeout to happen.</p>
<p>So, let's do it. This is the code of another endpoint that is using a circuit breaker design pattern:</p>
<p><a href="https://gist.github.com/eldermoraes/f239294539d40d07a1282c2e93fd3227">https://gist.github.com/eldermoraes/f239294539d40d07a1282c2e93fd3227</a></p>
<p>The proposal here is to show you how to design a microservice using a circuit breaker pattern. So we have a service that is returning a timeout exception. Let's break it down for better understanding:</p>
<ul>
<li>@Timeout - defines a timeout limit for this microservice</li>
<li>@Fallback - defines a method to be used in case of failure (note that the method is implemented at the end of the code with the name "fallback")</li>
<li>@CircuitBreaker - defines that on every 4 requests (requestVolumeThreshold), if we have 50% of them failing (failureRatio) the circuit will open. Then it should wait 2 seconds (delay) and try to close back the circuit. If it has 2 requests that perform successfully (successThreshold) it will keep closed. Otherwise, it will open and try again after 2 seconds (delay). </li>
</ul>
<p>So imagine that you have thousands of requests coming to this microservice and getting this exception. Without this circuit breaker implementation, all those requests would wait until timeout unnecessarily, which would create a huge queue of requests waiting for a response that will not come. That's when a cascade failure happens.</p>
<p>By giving an exception right away you give the requester service to handle it properly and faster.</p>
<h2>Health Check API</h2>
<p>One of the key aspects of the Cloud Native approach is that your service should be observable. And one of the features you should implement the health checks probes.</p>
<p>There are two probes that you will implement:</p>
<ul>
<li>Liveness probe: it will "say" if your microservice is alive or not</li>
<li>Readiness probe: it will "say" if you microservice is ready to handle requests or not</li>
</ul>
<p>Usually, your liveness probe won't have too much complexity, so here it is an example of implementation:</p>
<p><a href="https://gist.github.com/eldermoraes/2460cbc362dd87f1a7c47b7de5f96ede">https://gist.github.com/eldermoraes/2460cbc362dd87f1a7c47b7de5f96ede</a></p>
<p>So what makes a class to be your liveness probe:</p>
<ul>
<li>To implement the HealthCheck interface</li>
<li>Be annotated with @Liveness </li>
</ul>
<p>Now to the readiness probe. Imagine that you microservice have some required dependency before start answering requests (access some database, third party service, a message queue, etc); here it is where you should validate if this dependency is available/ready before start handling requests:</p>
<p><a href="https://gist.github.com/eldermoraes/5c12dc31ad703b9deec17428bff2af2e">https://gist.github.com/eldermoraes/5c12dc31ad703b9deec17428bff2af2e</a></p>
<p>Let's break this code down:</p>
<ul>
<li>Interface implementation: the same as for liveness (HealthCheck interface)</li>
<li>Annotation: @Readiness</li>
<li>call() implementation: here I made this probe to validate if my blog (<a href="http://eldermoraes.com">http://eldermoraes.com</a>) is up and running. If so, the readiness will be "up". If not, will be "down".</li>
</ul>
<p>How do these probes work on a Kubernetes cluster?</p>
<p>(I'm assuming that you are writing microservices to be managed in some orchestrated environment and that Kubernetes is the standard option for it today).</p>
<ul>
<li>Liveness probe: if it returns a status code (HTTP) different of 2xx, the node manager will kill the pod (where the container is) and will replace it with a brand new one</li>
<li>Readiness probe: if it returns a status code of 2xx, the manager will start sending requests to it. If not, it will hold on until it is… ready! :-)</li>
</ul>
<h2>Distributed Tracing</h2>
<p>This is the easiest one.</p>
<p><a href="https://gist.github.com/eldermoraes/3f78f330ea080a44236a25fe835accf3">https://gist.github.com/eldermoraes/3f78f330ea080a44236a25fe835accf3</a></p>
<p>You just need to annotate the class/method you would like to trace with @Traced. Now you just need some tracing tool (Kiali, Zipkin, etc).</p>
<p>Side note: for me, this is a great example of the advantages of using standards. It will ease your life in many ways.</p>
<h2>Metrics API</h2>
<p>Here is a class with some metrics being collected:</p>
<p><a href="https://gist.github.com/eldermoraes/8538cc2306ffb00f330060950c3a3108">https://gist.github.com/eldermoraes/8538cc2306ffb00f330060950c3a3108</a></p>
<p>Breaking it down:</p>
<ul>
<li>@Counted: will collect statistics related to the frequency of calling to this method</li>
<li>@Timed: will collect statistics related to the time consumed by this method</li>
</ul>
<p>To see it working, just call these methods many times and then call this URL:</p>
<pre><code>http://localhost:8080/metrics/application
</code></pre>
<p>That's it!</p>
<p>I hope it's useful for you. Remember, when we are using standards, we have a lot of heavy lifting of our coding being reduced by the standard. So that's why I like MicroProfile, especially when using it with Quarkus, which gives me a lot of productivity with its developer mode (and, of course, its crazy fast startup).</p>
<p>So this combination between MicroProfile and Quarkus is amazing!</p>
<p>If you tried to implement some of these design patterns, leave your comment here and tell me how it was your experience. And if you have any questions, I’ll be more than happy to answer them!</p>
]]></content:encoded>
	</item>
	<item>
		<title>How to connect external services and configure orchestrated applications</title>
		<link>https://eldermoraes.com/how-to-use-jakarta-ee-with-orchestrated-containers/</link>
		<pubDate>Fri, 03 Aug 2018 00:00:00 +0000</pubDate>
		<category><![CDATA[Architecture]]></category>
		<category><![CDATA[Containers]]></category>
		<category><![CDATA[Docker]]></category>
		<category><![CDATA[JakartaEE]]></category>
		<guid isPermaLink="false">https://eldermoraes.com/?p=1811</guid>
		<description><![CDATA[Learn how to connect external services and configure orchestrated applications in this tutorial by Sebastian Daschner, the author of Architecting Modern Java EE Applications. The orchestration framework orchestrates and integrates enterprise applications in clustered environments. It takes a lot of work off the used application technology. Container orchestration also greatly simplifies the configuration of orchestrated…]]></description>
		<content:encoded><![CDATA[<p><img src="https://eldermoraes.com/wp-content/uploads/2017/07/connections-300x188.jpg" alt=""></p>
<p><em>Learn how to connect external services and configure orchestrated applications in this tutorial by Sebastian Daschner, the author of</em> <a href="https://www.packtpub.com/application-development/architecting-modern-java-ee-applications"><em>Architecting Modern Java EE Applications</em></a><em>.</em></p>
<p>The orchestration framework orchestrates and integrates enterprise applications in clustered environments. It takes a lot of work off the used application technology. Container orchestration also greatly simplifies the configuration of orchestrated applications and connection to external services.</p>
<h2>Connecting external services</h2>
<p>Client controls require URLs to connect against in order to integrate external services. The URLs traditionally have been configured in files, which potentially differed in various environments. In an orchestrated environment, the application can resolve external services using a logical name via DNS. The following code snippet shows how to connect against the <strong>cloud processor</strong> application:</p>
<pre><code>@ApplicationScoped
public class HelloCloudProcessor {

   private Client client;
   private WebTarget target;

   @PostConstruct
   private void initClient() {
       client = ClientBuilder...
       target = client.target("http://cloud-processor:8080/processor/resources/hello");
   }

   public String processGreeting() {
       ...
   }
}
</code></pre>
<p>The same holds true for other URLs (for example datasource definitions). The application server configuration can simply point to the name of the database service and use it to resolve the corresponding instance at runtime.</p>
<h2>Configuring orchestrated applications</h2>
<p>Resolving services by logical names already eliminates a lot of configuration in the application. Since the same container image is being used in all environments, a potentially different configuration needs to be inserted from the orchestration environment. As shown in the previous example, Kubernetes config maps tackle this situation. The <strong>hello-cloud</strong> application expects that at runtime a properties file will reside under <strong>/opt/config/application.properties</strong>. The project code will hence access this location. The following demonstrates the integration of the properties file using a CDI producer:</p>
<pre><code>public class HelloGreeter {

   @Inject
   @Config("hello.greeting")
   String greeting;

   @Inject
   @Config("hello.name")
   String greetingName;

   public String processGreeting() {
       return greeting + ", " + greetingName;
   }
}
</code></pre>
<p>The CDI producer is defined similarly to the configuration example shown previously:</p>
<pre><code>@ApplicationScoped
public class ConfigurationExposer {

   private final Properties properties = new Properties();

   @PostConstruct
   private void initProperties() {
       try (InputStream inputStream =
               new FileInputStream("/opt/config/application.properties")) {
           properties.load(inputStream);
       } catch (IOException e) {
           throw new IllegalStateException("Could not init configuration", e);
       }
   }

   @Produces
   @Config("")
   public String exposeConfig(InjectionPoint injectionPoint) {
       Config config = injectionPoint.getAnnotated().getAnnotation(Config.class);
       if (config != null)
           return properties.getProperty(config.value());
       return null;
   }
}
</code></pre>
<p>The application loads the contents of the properties file into the properties map and produces the configured values using CDI. All managed beans can inject these values, which emerge from the Kubernetes config map.</p>
<p>In order to realize secret configuration values, Kubernetes includes the concept of secrets. A common practice is to make the contents of the secrets accessible in containers using environment variables.</p>
<p>Java applications use the <strong>System.getenv()</strong> method to access environment variables. This functionality is used for both secrets and config map values, respectively.</p>
<p>The demonstrated approaches and examples enable an enterprise application to be deployed, managed, and configured in a container orchestration cluster. They are sufficient for a majority of use cases.</p>
<p><em>You can now connect external services and configure orchestrated applications in Jakarta EE. If you found this tutorial helpful, you can explore</em> <a href="https://www.amazon.com/Architecting-Modern-Java-Applications-business-oriented/dp/1788393856"><em>Architecting Modern Java EE Applications</em></a><em>, an end-to-end guide to designing and developing modern, business-oriented applications using Java EE 8. So if you’re a Java EE developer keen on architecting enterprise-grade applications, this book is a must-read!</em></p>
]]></content:encoded>
	</item>
	<item>
		<title>Book Review - Hibernate Tips: More than 70 solutions to common Hibernate problems, by Thorben Janssen / @thjanssen123</title>
		<link>https://eldermoraes.com/book-review-hibernate-tips-more-than-70-solutions-to-common-hibernate-problems-by-thorben-janssen-thjanssen123/</link>
		<pubDate>Tue, 09 Jan 2018 00:00:00 +0000</pubDate>
		<category><![CDATA[Architecture]]></category>
		<category><![CDATA[Book]]></category>
		<category><![CDATA[JavaEE]]></category>
		<guid isPermaLink="false">https://eldermoraes.com/?p=1783</guid>
		<description><![CDATA[If you ever used Hibernate in your life and never had a look at this book, I have to tell you: you could be doing something in a not so good way. Or, worse, in a wrong one. First of all, let me tell you about the author. If you have no idea who Thorben…]]></description>
		<content:encoded><![CDATA[<p>If you ever used Hibernate in your life and never had a look at this book, I have to tell you: you could be doing something in a not so good way. Or, worse, in a wrong one.</p>
<p><img src="https://eldermoraes.com/wp-content/uploads/2018/01/thorben-book-1.jpg" alt="thorben-book"></p>
<p>First of all, let me tell you about the author. If you have no idea who Thorben Janssen is, you are really missing great content sharing by a great guy. With almost two decades of experience, he is blogger, author (of course!), trainer and consultant. He has been using Hibernate almost from the day one and has a lot to teach.</p>
<p>So have a break now and go follow him on Twitter: <a href="https://twitter.com/thjanssen123">https://twitter.com/thjanssen123</a>.</p>
<p>The book is made for developers with at least some basic knowledge of JPA and Hibernate. It is focused to help them with common tasks and problems, from the most basics to the most advanced ones.</p>
<p>The book is structured in a way that's impossible you don't find what you are looking for:</p>
<ul>
<li>Setting up</li>
<li>Basic Mappings</li>
<li>Advanced Mappings</li>
<li>Hibernate Specific Queries and Mappings</li>
<li>Java 8</li>
<li>Logging</li>
<li>JPQL</li>
<li>Native SQL Queries</li>
<li>Create queries programmatically with the Criteria API</li>
<li>Stored Procedures</li>
<li>Caching</li>
</ul>
<p>And inside each topic you will find tons of solutions. Actually, 70 in total! ;-)</p>
<p>Each solution (may I call it a "recipe"?) use a "problem -> solution" approach: a common problem is described and a solution is showed up. With code! Thank you, Thorben!</p>
<p>Then you can download the full source code of the solution and get more information in the "Learn More" section.</p>
<p>With simple and "straight to the point" explanations, the book helps you to understand that crazy code that your IDE generates when you use some wizard to create entities from the database.</p>
<p>The texts are concise, clear and very well written.</p>
<p>Some of my favorite solutions:</p>
<ol>
<li>From the Basic Mappings section, all solutions dealing with primary key values. Yes, it is basic... but also still bring some pain to many developers due to the different ways it can be done. So those recipes are like gold;</li>
<li>From the Advanced Mappings section, the solution that show how to calculate entity attributes using @Formula annotation;</li>
<li>The whole Java 8 section!</li>
<li>Cache section, specially because I discovered something that I was doing wrong... thanks again, Thorben!</li>
</ol>
<p>That's my impression of the book. Have you ever read it? If so, leave your comments here and share yours.</p>
<p>Are you a Hibernate/JPA developer and didn't read it? Oh, come on... :-)</p>
]]></content:encoded>
	</item>
	<item>
		<title>4 Essential Tools To Build Java EE Microservices Today (With Confidence!)</title>
		<link>https://eldermoraes.com/4-essential-tools-to-build-java-ee-microservices-today-with-confidence/</link>
		<pubDate>Mon, 10 Jul 2017 00:00:00 +0000</pubDate>
		<category><![CDATA[Architecture]]></category>
		<category><![CDATA[Community]]></category>
		<category><![CDATA[Docker]]></category>
		<category><![CDATA[JavaEE]]></category>
		<category><![CDATA[Microservices]]></category>
		<guid isPermaLink="false">https://eldermoraes.com/?p=1589</guid>
		<description><![CDATA[Lately many people has been asked me how they could begin with microservices, what they need to learn, what they have to do. To help answer these questions (and also to help on organizing and prioritizing things), I made this small guide. The tools mentioned here are not necessarily in order of importance or any…]]></description>
		<content:encoded><![CDATA[<p><img src="https://eldermoraes.com/wp-content/uploads/2017/07/connections-1024x640.jpg" alt="connections"></p>
<p>Lately many people has been asked me how they could begin with microservices, what they need to learn, what they have to do.</p>
<p>To help answer these questions (and also to help on organizing and prioritizing things), I made this small guide.</p>
<p>The tools mentioned here are not necessarily in order of importance or any other order at all.</p>
<h2>Docker</h2>
<p>No matter which server did you choose, I'd highly recommend to deploy your application using Docker. Why?</p>
<ol>
<li><strong>Isolation</strong>: It's easier to isolate your microservices from each other. You could deploy one microservice per container;</li>
<li><strong>More options</strong>: You can mix many application servers and/or services in the same environment. Only thing you need to do is to run another container with the service you need. I've wrote an article called "<a href="https://eldermoraes.com/2017/01/31/modular-and-reusable-java-ee-architecture-with-docker/">Modular and Reusable Java EE Architecture with Docker</a>" with Bruno Souza and André Carvalho where we explored it in more details;</li>
<li><strong>Clustering</strong>: Of course, you can build a cluster without containers. But it's easier with them! You can easily manage the amount of nodes for each microservice with a couple of command lines. If you mess somethings, just remove the container and run it again. You can even work with some orchestration and add elastic features to your architecture;</li>
<li><strong>Deploying:</strong> Deploy your application by deploying your container (called "appliance"). Lot of portability and will also help the Ops guys! See more at <a href="https://eldermoraes.com/2016/05/10/step-by-step-high-availability-with-docker-and-java-ee/">Step-by-Step High Availability with Docker and Java EE</a>.</li>
</ol>
<h2>Payara Micro</h2>
<p>Although you can use any Java EE compatible server to do it, Payara Micro will give you a much more "ready" environment.</p>
<p>It's small (&#x3C; 70MB) and has automatic and elastic clustering. It's ready for the cloud and for containers. And it has also some cool ready-to-use integrations that will bring more power to your service without overload them.</p>
<p>Check it out: <a href="https://www.payara.fish/payara_micro">https://www.payara.fish/payara_micro</a></p>
<p>Oh... of course, they have a pre-built Docker image available at Docker Hub... ;-)</p>
<p>The API's supported are:</p>
<ul>
<li>Servlets, JSTL, EL and JSPs</li>
<li>WebSockets</li>
<li>JSF</li>
<li>JAX-RS</li>
<li>EJB lite</li>
<li>JTA</li>
<li>JPA</li>
<li>Bean Validation</li>
<li>CDI</li>
<li>Interceptors</li>
<li>JBatch</li>
<li>Concurrency</li>
<li>JCache</li>
</ul>
<h2>Microprofile Initiative (community for the win!)</h2>
<p>If we will learn something, why not learn together? I'm an all about community person...</p>
<p>Eclipse Microprofile (<a href="http://microprofile.io/">http://microprofile.io</a>) is a initiative that joins many vendors, communities and individuals around this hot topic. The target is to discuss and create proper standardization for microservice architecture.</p>
<p>You can join as collaborator (see the list at the site) or just watch the mail list and see what is going on. It's a great and not so common opportunity to help on defining the future of something really big.</p>
<h2>A Mature CI/CD Process</h2>
<p>If you have problems with building/deploying one single WAR, guess what will happen with dozens? Hundreds? Thousands?</p>
<p>Once you multiply independent services and distributions, you also multiply all the problems they bring with them (environment, setup, security, etc).</p>
<p>So if you are wondering if you should break down your monolith, first automate its lifecycle.</p>
<p>Once you are deploying a few artifacts using any level of automation you can evolve it to a more complex scenarios. And then when you reach microservices you will be more comfortable and less susceptible to a painful build, test and deployment processes.</p>
<p> </p>
<p>So are you already using microservices? Did you migrate some monolith to this new architecture model? Leave your comments and experiences bellow.</p>
]]></content:encoded>
	</item>
</channel>
</rss>
