DZone
Thanks for visiting DZone today,
Edit Profile
  • Manage Email Subscriptions
  • How to Post to DZone
  • Article Submission Guidelines
Sign Out View Profile
  • Post an Article
  • Manage My Drafts
Over 2 million developers have joined DZone.
Log In / Join
Please enter at least three characters to search
Refcards Trend Reports
Events Video Library
Refcards
Trend Reports

Events

View Events Video Library

Zones

Culture and Methodologies Agile Career Development Methodologies Team Management
Data Engineering AI/ML Big Data Data Databases IoT
Software Design and Architecture Cloud Architecture Containers Integration Microservices Performance Security
Coding Frameworks Java JavaScript Languages Tools
Testing, Deployment, and Maintenance Deployment DevOps and CI/CD Maintenance Monitoring and Observability Testing, Tools, and Frameworks
Culture and Methodologies
Agile Career Development Methodologies Team Management
Data Engineering
AI/ML Big Data Data Databases IoT
Software Design and Architecture
Cloud Architecture Containers Integration Microservices Performance Security
Coding
Frameworks Java JavaScript Languages Tools
Testing, Deployment, and Maintenance
Deployment DevOps and CI/CD Maintenance Monitoring and Observability Testing, Tools, and Frameworks

Modernize your data layer. Learn how to design cloud-native database architectures to meet the evolving demands of AI and GenAI workkloads.

Secure your stack and shape the future! Help dev teams across the globe navigate their software supply chain security challenges.

Releasing software shouldn't be stressful or risky. Learn how to leverage progressive delivery techniques to ensure safer deployments.

Avoid machine learning mistakes and boost model performance! Discover key ML patterns, anti-patterns, data strategies, and more.

Related

  • Integrating Salesforce APEX REST
  • Rethinking Enterprise Integration: The Understated Role of Enterprise Service Bus (ESB)
  • JMS Explained
  • Enterprise Software Integration: How To Build a Unified IT Environment

Trending

  • Building Scalable and Resilient Data Pipelines With Apache Airflow
  • Java’s Next Act: Native Speed for a Cloud-Native World
  • The 4 R’s of Pipeline Reliability: Designing Data Systems That Last
  • Event-Driven Architectures: Designing Scalable and Resilient Cloud Solutions
  1. DZone
  2. Testing, Deployment, and Maintenance
  3. Deployment
  4. Ultra-Fast Microservices: The Enterprise Integration Makes It Easy

Ultra-Fast Microservices: The Enterprise Integration Makes It Easy

In this article, explore more about the integration between MicroStream, Jakarta EE, and MicroProfile, thanks to CDI.

By 
Otavio Santana user avatar
Otavio Santana
DZone Core CORE ·
Sep. 13, 22 · Tutorial
Likes (6)
Comment
Save
Tweet
Share
13.2K Views

Join the DZone community and get the full member experience.

Join For Free

When we talk about enterprise integration in the Java world, it brings a huge challenge, mainly in the news architecture trends such as microservices and the cloud age. We have several points to think about, such as a platform to integrate. This article will cover why and how to incorporate a persistence tool with the standard of Java enterprise applications. Then, we can explore and enjoy ultra-fast applications.

This rocket market is experiencing a vast revolution. Right now, the market is not exclusive to extensive and mature companies such as Red Hat, Google, etc. We can see even start-ups exploring this demand.

That is the case of MicroStream, a dynamic persistence company whose focus is to help the Java developer handle data easily and ultra-fast.

What or Who Is MicroStream?

Persistence in Java has always been complex, effortful, and expensive. During the runtime, Java database apps are often too slow. It happens mainly because the parser and the mapping process are needed.

The MicroStream vision was not to build yet another database system or ORM framework but to fundamentally change database development in Java to simplify and accelerate the entire database development process.
- About MicroStream

By default, MicroStream works in memory and persists locally in a disk; thus, it will avoid lost data in the process of the shutdown of the server. It also provides integration with other storage targets. Therefore, you can use it beyond file systems such as relational databases such as MySQL, NoSQL such as MongoDB, and blog stores such as Amazon S3.

MicroStream is an excellent solution that has proven to minimize latency, maximize throughput and workload, and save around 90% CPU power and costs.

Integration Based on Specifications

Java became popular with the word "WORA" or Write Once Run Anywhere. However, it is not true when we talk about developer experience; indeed, the vast flavors of platforms and tools we have right now in the Java world are enormous!

When we talk about MicroStream integration, all of those platforms look like a considerable challenge; primarily, each platform is provided by a different company. How do we achieve all of those?

The instant answer would be: let's create one API or implementation for each solution, but it is expensive and hard to maintain and update. 

Thus, let's explore the hottest feature in the Java world that is outside the code: the specification.

The specification guarantees all the parts in the technology industry a path to walk through, so it brings benefits to developers, companies, and technology providers.

  • Developer: A low learning curve and cognitive load

  • The company: An easy way to avoid vendor-locking

  • The technology creator: An expected minimum requirement to follow

We can see it everywhere: SQL to databases, HTML and HTTP to web, and so on.

Be aware that popularity and standards are two different things: one tool might be popular and won't be a standard. A standard has fundamental components: Process, API, TCK, and an organization behind it to orchestrate and make everything work.

Jakarta EE: The WORA’s Answer to Integration

On Enterprise Java, we have the Jakarta EE, the successor of Java EE, with a vibrant community under the Eclipse Foundation umbrella.

It has several components to make the Java developer's life even better.

The CDI is one of the most critical specifications on Jakarta EE, which works as glue. Thanks to CDI, we can inject resources to JAR-RS, JMS, and JPA with the @Inject annotation, which will work like a charm. 

Jakarta EE also inspires the MicroProfile initiative, where several organizations, companies, and communities create an optimized profile to work with both microservices and cloud-age.

We decided to have an API based on Jakarta EE using CDI specifications. With a single library, we can now have support for several twenty-one Jakarta vendors and around ten Microprofile vendors.

Besides the CDI, MicroStream uses MicroProfile configuration. This API helps optimize the environment's settings by applying the Twelve factor App.

Thus, one implementation to over-thirty vendors.

MicroStream + CDI Integration Hands-On

We discussed why we decided to use CDI instead of code directly on each one of the third vendors. In the next step, let's examine the code and the API.

The first step in the integration is to add the integration library. Please look at the latest version and add it to your application.

XML
 
 <dependency>
      <groupId>one.microstream</groupId>
      <artifactId>microstream-integrations-cdi</artifactId>
      <version>LAST_VERSION_HERE</version>
  </dependency>


MicroStream operates on any Object graph, so you're free to create the ideal structure for your application, and the engine will take care of the rest. To focus more on the API, we'll create a simple store that will handle entity Names where we'll have a Set of Strings.

To highlight, we can explore any Java structure. As a recommendation, explore immutable as much as possible on this design.

Java
 
@Storage
public class Names implements Supplier<Set<String>> {
    private final Set<String> names = new HashSet<>();

    public void add(final String name) {
        this.names.add(Objects.requireNonNull(name, "name is required"));
    }
//...
}


To define the root of the object graph, we have the Storage annotation. The integration will do the work. If you enjoy DDD as I do, think of the Storage modeling as an aggregate root.

But how do we work with this root class? That's easy: use it, and explore the power of CDI with the @Inject annotation.

Java
 
@ApplicationScoped
public class NamesService {
    @Inject
    private Names names;

    @Store
    public void add(final String name) {
        this.names.add(name);
    }

    public Set<String> getNames() {
        return this.names.get();
    }

}


There is the Store annotation to commit the operation on the MicroStream engine. Anything else is Java. So, you can explore any data structure smoothly and inject it simply as that.

Java
 
public class App {
    public static void main(final String[] args) {
        try (SeContainer container = SeContainerInitializer.newInstance().initialize()) {
            final StorageManager manager = container.select(StorageManager.class).get();
            final Object root = manager.root();
            System.out.println("The root value: " + root);
            final NamesService service = container.select(NamesService.class).get();

            System.out.println("The names: " + service.getNames());
            service.add("Sebastian");
            service.add("Otavio");
            service.add("Ada");
            service.add("Mari");
        }
        System.exit(0);
    }
}


MicroStream also supports cache with JCache, where you can inject this dependency using CDI and this cache can be persistent.

Java
 
@Inject
@StorageCache
private Cache<String, Integer> counter;


As we said, if you want to know more or even explore more the power of Jakarta EE combined with MicroStream, we do have several tutorials for you:

  • Open Liberty

  • Wildfly

  • Payara

  • Helidon

The CDI and MicroStream are a good combination when discussing enterprise solutions. In the cloud age, you can explore this solution on Java with several architectural styles such as monolith and microservices. We can see a significant and vibrant future ahead.

Enterprise integration

Opinions expressed by DZone contributors are their own.

Related

  • Integrating Salesforce APEX REST
  • Rethinking Enterprise Integration: The Understated Role of Enterprise Service Bus (ESB)
  • JMS Explained
  • Enterprise Software Integration: How To Build a Unified IT Environment

Partner Resources

×

Comments
Oops! Something Went Wrong

The likes didn't load as expected. Please refresh the page and try again.

ABOUT US

  • About DZone
  • Support and feedback
  • Community research
  • Sitemap

ADVERTISE

  • Advertise with DZone

CONTRIBUTE ON DZONE

  • Article Submission Guidelines
  • Become a Contributor
  • Core Program
  • Visit the Writers' Zone

LEGAL

  • Terms of Service
  • Privacy Policy

CONTACT US

  • 3343 Perimeter Hill Drive
  • Suite 100
  • Nashville, TN 37211
  • support@dzone.com

Let's be friends:

Likes
There are no likes...yet! 👀
Be the first to like this post!
It looks like you're not logged in.
Sign in to see who liked this post!