Search icon CANCEL
Arrow left icon
Explore Products
Best Sellers
New Releases
Books
Videos
Audiobooks
Learning Hub
Conferences
Free Learning
Arrow right icon
Arrow up icon
GO TO TOP
Hands-On Cloud-Native Applications with Java and Quarkus

You're reading from   Hands-On Cloud-Native Applications with Java and Quarkus Build high performance, Kubernetes-native Java serverless applications

Arrow left icon
Product type Paperback
Published in Dec 2019
Publisher Packt
ISBN-13 9781838821470
Length 314 pages
Edition 1st Edition
Languages
Arrow right icon
Author (1):
Arrow left icon
Francesco Marchioni Francesco Marchioni
Author Profile Icon Francesco Marchioni
Francesco Marchioni
Arrow right icon
View More author details
Toc

Table of Contents (15) Chapters Close

Preface 1. Section 1: Getting Started with Quarkus FREE CHAPTER
2. Introduction to Quarkus Core Concepts 3. Developing Your First Application with Quarkus 4. Creating a Container Image of Your Application 5. Section 2: Building Applications with Quarkus
6. Adding Web Interfaces to Quarkus Services 7. Managing Data Persistence with Quarkus 8. Building Applications Using the MicroProfile API 9. Securing Applications 10. Section 3: Advanced Development Tactics
11. Advanced Application Development 12. Unifying Imperative and Reactive with Vert.x 13. Reactive Messaging with Quarkus 14. Other Books You May Enjoy

Firing events with the Quarkus scheduler

Quarkus includes an extension called scheduler, which can be used to schedule tasks for single or repeated execution. We can use the cron format to specify the number of times the scheduler fires the event.

The source code for the following example is located in the Chapter08/scheduler folder of this book's GitHub repository. If you check the pom.xml file, you will notice that the following extension has been added to it:

<dependency>
<groupId>io.quarkus</groupId>
<artifactId>quarkus-scheduler</artifactId>
</dependency>

Our sample project generates a random token (for the sake of simplicity, a random string is used) every 30 seconds. The class that's in charge of generating random tokens is the following TokenGenerator class:

@ApplicationScoped
public class TokenGenerator {

private...
lock icon The rest of the chapter is locked
Register for a free Packt account to unlock a world of extra content!
A free Packt account unlocks extra newsletters, articles, discounted offers, and much more. Start advancing your knowledge today.
Unlock this book and the full library FREE for 7 days
Get unlimited access to 7000+ expert-authored eBooks and videos courses covering every tech area you can think of
Renews at €18.99/month. Cancel anytime