5/30/2024

Podman commands

Podman is an open-source, daemonless, and rootless container engine for developing, managing, and running OCI Containers on Linux, Windows and Mac. It can be used to support the container functionality and Dev Services on Quarkus.


Usefull Podman commands:

podman machine set --rootful=true

podman machine start

podman run -ti --rm --volume access-data:/var/lib/postgresql/data -e POSTGRES_DB=postDB -e POSTGRES_USER=postUser -e POSTGRES_PASSWORD=postPass -p 5432:5432 -d postgres 


podman run -ti --rm -e PGADMIN_DEFAULT_EMAIL=admin@adminman.com -e PGADMIN_DEFAULT_PASSWORD=postPass -e PGADMIN_LISTEN_PORT=8080 -p 8081:8080 -d docker.io/dpage/pgadmin4 


podman network inspect podman















Useful links:

Podman

Using Podman with Quarkus - Quarkus

10 Podman guides to do more with containers in 2022 | Enable Sysadmin (redhat.com)

How To Run PostgreSQL 16,15,14,13 in Podman Container - TechViewLeo 

Run PostgreSQL with Podman as Docker Container | by PAWAN SHARMA | Medium

Run PostgreSQL + PGAdmin in pods using podman - DEV Community

Run a Spring Boot and Postgres Application on Podman (howtodoinjava.com)


Quarkus FLYWAY


Quarkus FLYWAY 


Official sites : 

- https://quarkus.io/extensions/io.quarkus/quarkus-flyway/

- https://flywaydb.org/

- https://documentation.red-gate.com/fd/database-development-using-flyway-138346953.html

Why database migrations - Flyway - Product Documentation (red-gate.com) 


Other links:

- https://sonataflow.org/serverlessworkflow/latest/persistence/postgresql-flyway-migration.html

- https://www.mastertheboss.com/various-stuff/flyway/performing-a-flyway-migration-with-quarkus-and-thorntail/


Videoclips:

- https://www.youtube.com/watch?v=Kz_mcVuKIXs

- https://www.youtube.com/watch?v=ccvLc_06ijo

- https://www.youtube.com/watch?v=qsacSRcHCCs

- https://blog.sebastian-daschner.com/entries/flyway-migrate-databases-quarkus



5/26/2024

Phind.com. AI -

 I have found a AI site  https://www.phind.com/ where i give the following question: 

java code in quarkus and kafka to produce "working" class using avro with topic "working" using cronos expression from 30 seconds interval , also create client to listen if the message was send to the topic


ANSWER | PHIND INSTANT MODEL

To achieve your goal of producing a "working" class using Avro in Quarkus with Kafka, targeting a topic named "working", and setting up a consumer to listen for messages sent to this topic with a cron schedule every 30 seconds, follow these steps:

Step 1: Add Dependencies

First, ensure you have the necessary dependencies in your pom.xml file for Quarkus, Kafka, and Avro support.

<dependencies> <dependency> <groupId>io.quarkus</groupId> <artifactId>quarkus-kafka</artifactId> </dependency> <dependency> <groupId>org.apache.avro</groupId> <artifactId>avro</artifactId> </dependency> <!-- Include other necessary Quarkus extensions --> </dependencies>

Step 2: Define Your Avro Schema

Create an Avro schema for your "working" class. This example assumes a simple class structure; adjust according to your needs.

// Working.avsc { "namespace": "com.example", "type": "record", "name": "Working", "fields": [ {"name": "id", "type": "string"}, {"name": "status", "type": "string"} ] }

Generate Java classes from this schema using Avro tools or a plugin like maven-avro-plugin.

Step 3: Produce Messages

Implement a producer that sends messages to the "working" topic. Use a cron schedule to control the frequency of message production.

import io.smallrye.reactive.messaging.kafka.Record; import org.apache.avro.generic.GenericRecord; import javax.enterprise.context.ApplicationScoped; import javax.inject.Inject; import javax.ws.rs.POST; import javax.ws.rs.Path; import javax.ws.rs.Produces; import javax.ws.rs.core.MediaType; import java.time.Duration; import java.util.concurrent.TimeUnit; @Path("/produce") @ApplicationScoped public class Producer { @Inject @KafkaClient("kafka-client") Channel<KStream<String, GenericRecord>> channel; public void start() { // Schedule the producer to run every 30 seconds Timer.scheduleAtFixedRate(this::sendMessages, Duration.ofSeconds(30), Duration.ofSeconds(30)); } private void sendMessages() { try { var working = new Working(); working.setId("123"); working.setStatus("working"); Record<String, GenericRecord> record = Record.of("key", working); channel.send(record).await().indefinitely(); System.out.println("Message sent successfully."); } catch (Exception e) { e.printStackTrace(); } } }

Step 4: Consume Messages

Set up a consumer to listen for messages on the "working" topic. Use a cron schedule to trigger consumption every 30 seconds.

import io.smallrye.reactive.messaging.annotations.Blocking; import io.smallrye.reactive.messaging.annotations.Channel; import io.smallrye.reactive.messaging.annotations.Consumer; import io.smallrye.reactive.messaging.annotations.OnPartitionOffset; import org.apache.avro.generic.GenericRecord; import javax.enterprise.context.ApplicationScoped; @ApplicationScoped public class Consumer { @Channel("kafka-client") @Consumer(blocking = Blocking.BLOCK_IF_NO_MESSAGES) KStream<String, GenericRecord> stream; @OnPartitionOffset void consume(String partition, Long offset) { System.out.println("Consumed message from partition " + partition + " at offset " + offset); } }

Step 5: Configure Quarkus Application Properties

Configure your application.properties file to set up Kafka clients and topics.

# Kafka configuration quarkus.kubernetes.deployment.enabled=true quarkus.kafka.bootstrap.servers=localhost:9092 quarkus.kafka.clients.producer.topic=working quarkus.kafka.clients.consumer.topic=working quarkus.kafka.clients.consumer.group-id=my-group # Cron scheduling quarkus.scheduler.cron-expressions=0/30 * * * *

This setup uses Quarkus' reactive messaging capabilities to produce and consume messages with Avro serialization. Adjust configurations and code as needed for your specific requirements.











QUARKUS & GraphQL

 QUARKUS & GraphQL https://www.geeksforgeeks.org/graphql-tutorial/ https://quarkus.io/guides/smallrye-graphql-client https://www.mastert...