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

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

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

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

  • Practical Use of Weak Symbols
  • Build a REST API With Just 2 Classes in Java and Quarkus
  • Building a Simple RAG Application With Java and Quarkus
  • Generate Unit Tests With AI Using Ollama and Spring Boot

Trending

  • A Complete Guide to Modern AI Developer Tools
  • Mastering Advanced Traffic Management in Multi-Cloud Kubernetes: Scaling With Multiple Istio Ingress Gateways
  • The Human Side of Logs: What Unstructured Data Is Trying to Tell You
  • How the Go Runtime Preempts Goroutines for Efficient Concurrency
  1. DZone
  2. Coding
  3. Java
  4. Get Started With Cloud-Native Decision Automation on Quarkus

Get Started With Cloud-Native Decision Automation on Quarkus

Learn how to automate decisions using Quarkus and Kogito.

By 
Karina Varela user avatar
Karina Varela
·
Updated May. 26, 22 · Tutorial
Likes (1)
Comment
Save
Tweet
Share
6.7K Views

Join the DZone community and get the full member experience.

Join For Free

This article will guide you through creating a decision application based on Quarkus and trying out the business modeling in VSCode. You will experience hot reload of business assets during development and validate your decisions. 

Development of decision automation solutions has never been easier thanks to DMN (Decision Model and Notation), Kogito, and Quarkus. Kogito is designed from the ground up to run on cloud infrastructure at scale. If you think about business automation, think about the cloud — as this is where your business logic lives these days. By taking advantage of the latest technologies (Quarkus, KNative, and so on), you get amazingly fast boot times and instant scaling on orchestration platforms like OpenShift.

INFO: This article is part of a larger workshop. In case you're interested in learning more, check out the open and free guided workshop. The workshop includes guides on event-driven decision services, serverless decisions, and more.

Get Started With Decision Services

The best way to learn is to exercise. You can follow the steps below to experience the start of a new decision service, experience the flow during development time, and test your service using unit testing and the automatically generated REST endpoints. 

Feel free to go through the exercise while following the explanation:


Prerequisites

  1. Install Visual Studio Code IDE.

  2. Install VSCode Language Support for Java and Red Hat Business Automation Bundle in VSCode.

  3. You will need JDK 11.

  4. You will also need Maven.

Create a New Decision Project With Quarkus and Kogito

In order to create a new decision project based on Quarkus, we can use a Maven archetype to generate the Quarkus based project with the required dependencies for our decision application.

  • Navigate to a folder of your preference, and run the following command. Maven will create a new project with the name decision-lab01.
mvn io.quarkus.platform:quarkus-maven-plugin:2.8.2.Final:create \
-DprojectGroupId=org.acme \
-DprojectArtifactId=decision-lab01 \
-Dextensions="kogito-quarkus-decisions,quarkus-smallrye-openapi,quarkus-resteasy-jackson"

Examine the Project and Decision

Let’s open the project so we can look at its structure and files. In your terminal, you can open the project using the VScode. (You can use the code command in your CLI, as in code decision-lab01. 

In your project, you will find: 

  •  A DMN sample, pricing.dmn. This decision determines a base price quotation based on criterias like age and occurrence of previous incidents.
  • jUnit test PricingTest.java. This jUnit tests the REST endpoint that is generated automatically by Kogito. Further on the lab, we will work with the Test Scenario, a graphical tool that allows users to unit test the decision model.

Running the Project

It’s time to try out this project. To make things easier, you can use the Integrated Terminal feature in VSCode.

  • Open the integrated terminal in VSCode by pressing cmd+shift+p or ctrl+shift+p.

  • Then, search for New Terminal and select it. See below:

In the recently opened integrated terminal, you can start the application.

  • Start the application in dev mode:

    mvn quarkus:dev
  • Open your browser and access http://localhost:8080/q/swagger-ui/
  • You should see three REST endpoints that were automatically generated by Kogito.

  • Select the POST request for pricing and click on the Try it out button.

  • You can use the following JSON as the Request Input to validate the decision about whether the driver should be suspended or not:

{ "Age": 47, "Previous incidents?": false }

The output should show the final decision Base Price but also the values of the input nodes. If there were more decisions made in this processing, the outputs would also be outputted as a result.

Updating the Decision

When using the Kogito extension with Quarkus, you can also take advantage of the hot reload features during the development of your decision. Let’s give it a try.

  • Still with the server running go back to the decision project in VSCode.

  • Open the pricing.dmn decision file, and select the Base Price node. Click on the edit button.

Now, let’s change our business rule where the base price for people over 21 and without previous incidents should cost 400 instead of 500.

  •  On the literal expression, change the number to 400.

  • Save the DMN file.

  • Go back to your browser and click on "Execute" to execute the exact same request.

  • Check the response and confirm that — different from the first decision — the cost for the insurance is now 400.

Remember to also update the unit test src/test/java/org/acme/PricingTest.java to match the new value of 400, or to revert the value back to 500 so it matches the unit tests.

Awesome! You've implemented our first DMN decision service in Kogito, used the hot/live reload capabilities of Quarkus, and seen how these changes are immediately reflected in the service endpoint. Finally, you've sent a RESTful request to our DMN decision microservice and saw cloud-native decisioning with DMN in action.

Conclusion

This is a nice first exercise where developers can get a feel for the dev experience when using Quarkus plus decision automation extensions. This technology set gives users the best of Quarkus capabilities like ultra-lightweight applications, fast startup time, native compilation (using Mandrel or GraalVM), and increased developer productivity — including hot reload features for business assets. 

Quarkus unit test

Opinions expressed by DZone contributors are their own.

Related

  • Practical Use of Weak Symbols
  • Build a REST API With Just 2 Classes in Java and Quarkus
  • Building a Simple RAG Application With Java and Quarkus
  • Generate Unit Tests With AI Using Ollama and Spring Boot

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!