• Latest
  • Trending
  • All
  • Business News
  • Startup Investments
  • Startup News
  • Programming
  • Software Architecture
  • Web Security
Quick Microservices: When Microstream Meets Helidon

Quick Microservices: When Microstream Meets Helidon

8 months ago
Lowering incident response time for OutSystems with AWS serverless know-how

Lowering incident response time for OutSystems with AWS serverless know-how

3 days ago
8 Knowledge Constructions That Energy Your Databases

8 Knowledge Constructions That Energy Your Databases

1 week ago
Let’s Architect! Architecting for governance and administration

Let’s Architect! Designing event-driven architectures

1 week ago
EP 42: Designing a chat utility

EP 42: Designing a chat utility

2 weeks ago
Textual content analytics on AWS: implementing an information lake structure with OpenSearch

Textual content analytics on AWS: implementing an information lake structure with OpenSearch

2 weeks ago
EP 41: What’s Kubernetes?

EP 41: What’s Kubernetes?

3 weeks ago
Streaming the AWS Wickr desktop consumer with Amazon AppStream 2.0

Streaming the AWS Wickr desktop consumer with Amazon AppStream 2.0

3 weeks ago
EP 40: Git workflow – by Alex Xu

EP 40: Git workflow – by Alex Xu

4 weeks ago
Genomics workflows, Half 4: processing archival information

Genomics workflows, Half 4: processing archival information

1 month ago
EP 39: Accounting 101 in Fee Techniques

EP 39: Accounting 101 in Fee Techniques

1 month ago
Prime 10 AWS Structure Weblog posts of 2022

Prime 10 AWS Structure Weblog posts of 2022

1 month ago
Deploying Oracle RAC in AWS Outposts by way of FlashGrid Cluster

Deploying Oracle RAC in AWS Outposts by way of FlashGrid Cluster

1 month ago
  • Home
  • About Us
  • Contact Us
  • Disclaimer
  • Privacy Policy
  • Terms & Conditions
Sunday, February 5, 2023
  • Login
Startup News
  • Home
  • Startups
    • All
    • Business News
    • Startup Investments
    • Startup News
    Market analysis startup Bolt Perception receives funding from 212 — Retail Know-how Innovation Hub

    Market analysis startup Bolt Perception receives funding from 212 — Retail Know-how Innovation Hub

    [Funding alert] Fintech startup FinBox raises $15M in Sequence A spherical led by A91 Companions

    [Funding alert] Fintech startup FinBox raises $15M in Sequence A spherical led by A91 Companions

    NRMA backs VC’s $50 million agritech fund

    NRMA backs VC’s $50 million agritech fund

    Fanclash funding: Esports fantasy startup FanClash raises $40 million Collection B spherical

    Fanclash funding: Esports fantasy startup FanClash raises $40 million Collection B spherical

    Turkish enterprise capital fund ‘hunts’ for seed-stage startups

    Turkish enterprise capital fund ‘hunts’ for seed-stage startups

    The rise of API-first corporations, in fintech and past – TechCrunch

    The rise of API-first corporations, in fintech and past – TechCrunch

    QSTP-funded startup brings digital actuality to life

    QSTP-funded startup brings digital actuality to life

    Payglocal Funding: Cross-border funds startup PayGlocal raises $12 million from Tiger International, Sequoia

    Payglocal Funding: Cross-border funds startup PayGlocal raises $12 million from Tiger International, Sequoia

    [Funding alert] Fintech startup PayGlocal raises $12M from Tiger World, Sequoia, BEENEXT

    [Funding alert] Fintech startup PayGlocal raises $12M from Tiger World, Sequoia, BEENEXT

    With $110M in new funds, Aidoc is branching out of radiology

    With $110M in new funds, Aidoc is branching out of radiology

    Trending Tags

    • startup advice
    • startup funding
    • startup
    • funding
    • fund
    • Tips
  • Software & Development
    • All
    • Programming
    • Software Architecture
    • Web Security
    Lowering incident response time for OutSystems with AWS serverless know-how

    Lowering incident response time for OutSystems with AWS serverless know-how

    8 Knowledge Constructions That Energy Your Databases

    8 Knowledge Constructions That Energy Your Databases

    Let’s Architect! Architecting for governance and administration

    Let’s Architect! Designing event-driven architectures

    EP 42: Designing a chat utility

    EP 42: Designing a chat utility

    Textual content analytics on AWS: implementing an information lake structure with OpenSearch

    Textual content analytics on AWS: implementing an information lake structure with OpenSearch

    EP 41: What’s Kubernetes?

    EP 41: What’s Kubernetes?

    Streaming the AWS Wickr desktop consumer with Amazon AppStream 2.0

    Streaming the AWS Wickr desktop consumer with Amazon AppStream 2.0

    EP 40: Git workflow – by Alex Xu

    EP 40: Git workflow – by Alex Xu

    Genomics workflows, Half 4: processing archival information

    Genomics workflows, Half 4: processing archival information

    EP 39: Accounting 101 in Fee Techniques

    EP 39: Accounting 101 in Fee Techniques

    Trending Tags

    • Java
    • Microsoft
    • employee wellness programs
    • Project
    • Dev
    • Hackers
    • Security
  • Contact Us
No Result
View All Result
Startup News
Home Software & Development Programming

Quick Microservices: When Microstream Meets Helidon

by Startupnews Writer
June 6, 2022
in Programming
0
Quick Microservices: When Microstream Meets Helidon
492
SHARES
1.4k
VIEWS
Share on FacebookShare on Twitter


Microservices have turn into a buzzword after we speak about making a scalable software. However is that sufficient? The straightforward reply isn’t any. As with every software program structure determination, it has a trade-off and a number of other challenges. Fortunate for us Java builders, there’s a mixture of two instruments to make our life simpler: Microstream and MicroProfile. This text will cowl combining Microstream and Helidon to create a microservice software that’s simply steady and ultra-fast.

 Be at liberty to take a look at Half 1, Half 2, and Half 3 as effectively.

Microservices With Helidon

Microservices present a number of challenges to software program engineers, particularly as a primary step to dealing with distributed programs; but it surely doesn’t imply that we’re alone. Certainly there are a number of instruments to make our life simpler within the Java world, particularly, MicroProfile. 

MicroProfile has a purpose to optimize Enterprise Java for a Microservices Structure. It’s primarily based on the Java EE/Jakarta EE normal plus API particularly for microservices reminiscent of Relaxation Shopper, Configuration, Open API, and so forth.

Helidon is a cloud-native, open‑supply set of Java libraries for writing microservices that run on a quick net core powered by Netty.

Knowledge Persistence Actually Quick With Microstream

As soon as we speak about microservices, we talk about the distributed system and its challenges, and this summons would be the similar within the persistence layer. 

Sadly, we do not have sufficient articles that speak about it. We should always have a mannequin, even the schemaless databases when you’ve extra unsure details about the enterprise. Nonetheless, the persistence layer has extra points, primarily as a result of it’s tougher to vary.

One of many secrets and techniques to creating a scalable software is stateless, however we can’t afford it within the persistence layer. Primarily, the database goals to maintain the knowledge and its state.

One of many options to make your knowledge persistence layer extra pure is to combine instantly with the Java Entity as a graph. That’s what Microstream does. 

Microstream realizes ultra-fast in-memory knowledge processing with pure Java. It supplies microsecond question time, low-latency knowledge entry, gigantic knowledge throughput, and workloads. Thus it saves a number of CPU energy, CO2 emission, and prices within the knowledge middle.

Present Me the Code

Let’s mix each to make an ultra-fast microservice. As soon as the principle purpose is to indicate how each mix, we’ll select a clean demo. On this pattern, we’ll create a easy CRUD with a product, its title, and score and export it as Relaxation API.

Step one is to create the MicroProfile skeleton: it’s easy and clean, primarily as a result of we are able to establish visually with the MicroProfile starter. Set Microprofile model 3.3 with Java 11 and Helidon, as the image exhibits under.

Yep, we now have the skeleton of our software. The subsequent step is so as to add the Microstream and make each work collectively. Luckily, there’s a library to combine each by means of CDI extension. Thus, any software with CDI and MicroProfile Config can work because of this API.

Please take a look at the newest model and add it to your software.

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

The Skeleton is about, so let’s begin with the code. The mannequin is the central half. As soon as it’s a clean pattern, we’ll create a Product entity with just a few fields. The principle suggestion to make use of Microstream is to make use of immutable entities. Due to this fact, we’ll create a Product as an immutable entity.

public class Product {
    non-public closing lengthy id;
    non-public closing String title;
    non-public closing String description;
    non-public closing int score;

    @JsonbCreator
    public Product(
            @JsonbProperty("id") closing lengthy id,
            @JsonbProperty("title") closing String title,
            @JsonbProperty("description") closing String description,
            @JsonbProperty("score") closing int score){
            //...
            }

}

JSON annotations solely educate MicroProfile serialize the entity as JSON.

The subsequent step is defining a set of merchandise, which we’ll name Stock. The Stock class is a set of merchandise with a number of operation strategies. 

This class is the hyperlink between your entity and the Microstream engine. The reference to Microstream is utilizing the Storage annotation.

import java.util.Collections;
import java.util.HashSet;
import java.util.Objects;
import java.util.Non-obligatory;
import java.util.Set;
import java.util.operate.Predicate;

import one.microstream.integrations.cdi.sorts.Storage;


@Storage
public class Stock {
    non-public closing Set<Product> merchandise = new HashSet<>();

    public void add(closing Product product) {
        Objects.requireNonNull(product, "product is required");
        this.merchandise.add(product);
    }

    public Set<Product> getProducts() {
        return Collections.unmodifiableSet(this.merchandise);
    }

    public Non-obligatory<Product> findById(closing lengthy id) {
        return this.merchandise.stream().filter(this.isIdEquals(id)).restrict(1).findFirst();
    }

    public void deleteById(closing lengthy id) {
        this.merchandise.removeIf(this.isIdEquals(id));

    }

    non-public Predicate<Product> isIdEquals(closing lengthy id) {
        return p -> p.getId() == id;
    }

  @Override
  public boolean equals(Object o)  getClass() != o.getClass()) return false;
    Stock stock = (Stock) o;
    return Objects.equals(merchandise, stock.merchandise);
  

  @Override
  public int hashCode() {
    return Objects.hash(merchandise);
  }

  @Override
  public String toString() {
    return "Stock{" +
        "merchandise=" + merchandise +
        '}';
  }
}

With the gathering prepared, let’s create the repository. To make use of our Stock class, we are able to use the Inject annotation from CDI. We have to commit this operation to every operation that may change this assortment. For any technique that modifications the stock, there may be the Retailer annotation that handles it robotically for us.

ublic interface ProductRepository
{
  Assortment<Product> getAll();
  
  Product save(Product merchandise);
  
  Non-obligatory<Product> findById(lengthy id);
  
  void deleteById(lengthy id);
}


@ApplicationScoped
public class ProductRepositoryStorage implements ProductRepository {
    non-public static closing Logger LOGGER = Logger.getLogger(ProductRepositoryStorage.class.getName());

    @Inject
    non-public Stock stock;
  
    @Override
    public Assortment<Product> getAll() {
        return this.stock.getProducts();
    }

    @Override
    @Retailer
    public Product save(closing Product merchandise) {
        this.stock.add(merchandise);
        return merchandise;
    }

    @Override
    public Non-obligatory<Product> findById(closing lengthy id) {
        LOGGER.information("Discovering the merchandise by id: " + id);
        return this.stock.findById(id);
    }

    @Override
    @Retailer
    public void deleteById(closing lengthy id) {
        this.stock.deleteById(id);
    }
}

The final step is to reveal this product as a Relaxation API. Then, we’ll return with MicroProfile utilizing the Jakarta EE API: JAX-RS. Subsequent, we’ll create Open API documentation utilizing MicroProfile.

@RequestScoped
@Path("merchandise")
@Consumes(MediaType.APPLICATION_JSON)
@Produces(MediaType.APPLICATION_JSON)
public class ProductController
{
  @Inject
  non-public ProductRepository repository;
  
  // TODO do not apprehensive about pagination
  @GET
   public Assortment<Product> getAll()
  {
    return this.repository.getAll();
  }
  
  @GET
  @Path("{id}")
  @Operation(abstract = "Discover a product by id", description = "Discover a product by id")
   public Product findById(@PathParam("id") closing lengthy id)
  {
    return this.repository.findById(id).orElseThrow(
      () -> new WebApplicationException("There isn't any product with the id " + id, Response.Standing.NOT_FOUND));
  }
  
  @POST
  public Response insert(closing Product product)
  {
    return Response.standing(Response.Standing.CREATED).entity(this.repository.save(product)).construct();
  }
  
  @DELETE
  @Path("{id}")
   public Response delete(@PathParam("id") closing lengthy id){
    this.repository.deleteById(id);
    return Response.standing(Response.Standing.NO_CONTENT).construct();
  }
  
}

That’s it! We are able to take a look at out the applying operating and examine the consequence. The mixing works like a allure. 

mvn clear bundle
java -jar goal/helidon-example.jar

curl --location --request POST 'http://localhost:8080/merchandise/' 
--header 'Content material-Sort: software/json' 
--data-raw '{"id": 1, "title": "banana", "description": "a fruit", "score": 5}'

curl --location --request POST 'http://localhost:8080/merchandise/' 
--header 'Content material-Sort: software/json' 
--data-raw '{"id": 2, "title": "watermelon", "description": "watermelon sugar ahh", "score": 4}'

We lastly have our integration between Helidon and Microstream working. This tutorial exhibits how each work collectively and offers you a brand new instrument to face persistence points: Microstream. Certainly Microstream and Helidon are nice allies while you need to create microservices to run it ultra-fast.

References and Assets



Source_link

Related

Share197Tweet123
Startupnews Writer

Startupnews Writer

We write full-time and bring you the best news for startups and enterprises. We are passionate about tech entrepreneurship & innovation. Here you will find also web security news and software architecture standards for your next project.

  • Trending
  • Comments
  • Latest
Why is RESTful API so widespread?

Why is RESTful API so widespread?

August 25, 2022
What do WhatsApp, Discord, and Fb Messenger have in frequent? (Episode 10)

What do WhatsApp, Discord, and Fb Messenger have in frequent? (Episode 10)

June 6, 2022
These local weather startups are nonetheless elevating cash regardless of Putin, inflation, markets – 24/7 Wall St.

These local weather startups are nonetheless elevating cash regardless of Putin, inflation, markets – 24/7 Wall St.

June 5, 2022
Acquisitions and investments within the funds trade: challenges and alternatives

A Standardized, Specification-Pushed API Lifecycle

June 5, 2022

Telematics Options Market Measurement to Surpass US$ 142.93

0
Acquisitions and investments within the funds trade: challenges and alternatives

Acquisitions and investments within the funds trade: challenges and alternatives

0
With Market Measurement Valued at $1.4 Billion by 2026, it`s a Wholesome Outlook for the World MEMS Oscillators Market

With Market Measurement Valued at $1.4 Billion by 2026, it`s a Wholesome Outlook for the World MEMS Oscillators Market

0
How Ukrainian startups are surviving the battle with Russia

How Ukrainian startups are surviving the battle with Russia

0
Lowering incident response time for OutSystems with AWS serverless know-how

Lowering incident response time for OutSystems with AWS serverless know-how

February 2, 2023
8 Knowledge Constructions That Energy Your Databases

8 Knowledge Constructions That Energy Your Databases

January 28, 2023
Let’s Architect! Architecting for governance and administration

Let’s Architect! Designing event-driven architectures

January 26, 2023
EP 42: Designing a chat utility

EP 42: Designing a chat utility

January 21, 2023
  • Home
  • About Us
  • Contact Us
  • Disclaimer
  • Privacy Policy
  • Terms & Conditions

Copyright © 2022.

No Result
View All Result
  • Home
  • Startups
  • Software & Development
  • Contact Us

Copyright © 2022.

Welcome Back!

Login to your account below

Forgotten Password?

Retrieve your password

Please enter your username or email address to reset your password.

Log In
What Are Cookies
We use cookies on our website to give you the most relevant experience by remembering your preferences and repeat visits. By clicking “Accept All”, you consent to the use of ALL the cookies. However, you may visit "Cookie Settings" to provide a controlled consent.
Cookie SettingsAccept All
Manage consent

Privacy Overview

This website uses cookies to improve your experience while you navigate through the website. Out of these, the cookies that are categorized as necessary are stored on your browser as they are essential for the working of basic functionalities of the website. We also use third-party cookies that help us analyze and understand how you use this website. These cookies will be stored in your browser only with your consent. You also have the option to opt-out of these cookies. But opting out of some of these cookies may affect your browsing experience.
Necessary
Always Enabled
Necessary cookies are absolutely essential for the website to function properly. These cookies ensure basic functionalities and security features of the website, anonymously.
CookieDurationDescription
cookielawinfo-checkbox-analytics11 monthsThis cookie is set by GDPR Cookie Consent plugin. The cookie is used to store the user consent for the cookies in the category "Analytics".
cookielawinfo-checkbox-functional11 monthsThe cookie is set by GDPR cookie consent to record the user consent for the cookies in the category "Functional".
cookielawinfo-checkbox-necessary11 monthsThis cookie is set by GDPR Cookie Consent plugin. The cookies is used to store the user consent for the cookies in the category "Necessary".
cookielawinfo-checkbox-others11 monthsThis cookie is set by GDPR Cookie Consent plugin. The cookie is used to store the user consent for the cookies in the category "Other.
cookielawinfo-checkbox-performance11 monthsThis cookie is set by GDPR Cookie Consent plugin. The cookie is used to store the user consent for the cookies in the category "Performance".
viewed_cookie_policy11 monthsThe cookie is set by the GDPR Cookie Consent plugin and is used to store whether or not user has consented to the use of cookies. It does not store any personal data.
Functional
Functional cookies help to perform certain functionalities like sharing the content of the website on social media platforms, collect feedbacks, and other third-party features.
Performance
Performance cookies are used to understand and analyze the key performance indexes of the website which helps in delivering a better user experience for the visitors.
Analytics
Analytical cookies are used to understand how visitors interact with the website. These cookies help provide information on metrics the number of visitors, bounce rate, traffic source, etc.
Advertisement
Advertisement cookies are used to provide visitors with relevant ads and marketing campaigns. These cookies track visitors across websites and collect information to provide customized ads.
Others
Other uncategorized cookies are those that are being analyzed and have not been classified into a category as yet.
SAVE & ACCEPT
Translate »