quarkus

Multiple Datasource with Micronautor or Quarkus

匆匆过客 提交于 2020-05-16 05:54:31
问题 I want to migrate to Micronaut or Quarkus from Spring Boot, but in Spring boot there is one feature as AbstractRoutingDataSource, which in runtime change datasouce. Is there anything similar or any mechanism in micronaut or quarkus which gives opportunity to work with multiple datasources in runtime?? Spring-boot feature for reference https://medium.com/innomizetech/dynamic-multi-database-application-with-spring-boot-7c61a743e914 回答1: You can define multiple data sources in properties. And

GraalVM Quarkus Locale in native mode

假如想象 提交于 2020-05-16 05:53:06
问题 I have an unexpected behavior with available locales when native build. I have only one locale available in native mode. My application is very simple : @ApplicationPath("/api") public class ApplicationPathConfiguration extends Application { } @Path("/locales") public class LocaleController { @GET @Produces(MediaType.APPLICATION_JSON) public Locale[] get() { return Locale.getAvailableLocales(); } } After checkout if I launch the application in dev mode : mvn quarkus:dev You can call the

Programmatic scheduling - what is the best approach?

≡放荡痞女 提交于 2020-04-18 07:10:29
问题 I need to start multiple independent periodic tasks based on some configuration data - the total number is not known upfront. For example, I would like to check the content of different directories with different intervals and different parameters, where the list and parameters are read from the configuration. It seems to me that the quarkus-scheduler can schedule just the fixed, upfront-known methods. What is the best approach to do the scheduling dynamically/programmatically? Is vertx

How do I use mocks in some cases but not others in QuarkusTest?

喜欢而已 提交于 2020-04-18 06:57:07
问题 I have two classes in a Quarkus application, let’s call them Service A and Service B. Service B is a dependency of A. When I test ServiceA, I want to mock ServiceB. When I test ServiceB, I want to test the real Service B. I've created a MockServiceB class following this guide on quarkus.io. If I put it in my /test directory, my ServiceATest will properly grab the mock. But so will my ServiceBTest class. How can I selectively inject mocks to different classes? Better yet, can I selectively use

How to execute JPA Entity manager operations inside Quarkus-Kafka consumer method

生来就可爱ヽ(ⅴ<●) 提交于 2020-04-18 06:55:10
问题 Dears, I want to update my domain entities according to message being received by Kafka topic. I am using Quarkus latest and Smallrye reactive messaging with Kafka. Pub-sub model is working fine with me, but in consumer method I am unable to update my entities using entityManager or HibernatePanache. Whenever I try to use entityManager code inside consumer message, an exception is being thrown and handled silently. Here is my consumer code : @Transactional @Incoming("new-payment") public

Is there a way to enable trace to display the sequence of decisions executed for a DMN in Kogito?

我只是一个虾纸丫 提交于 2020-03-25 18:37:05
问题 I finally got my sample dmn-quarkus example running. Is there a property that enables the trace, such a way it prints the sequence of decisions executed? I noticed that when I provide a incorrect JSON for my DMN model, Kogito responds with a detail response, telling me which decision failed. This is awesome! Is there a property to turn on to get the details in each response? 回答1: Kogito is based on a domain-model first approach to code generation Kogito ergo domain Kogito adopts to your

Is there any function in Quarkus to send message to Kafka

天涯浪子 提交于 2020-03-25 03:30:31
问题 I'm new to kafka and quarkus, i want to send message to kafka topic when a user request has processed. I have gone through kafka example provided in quarkus-quickstart. I have tried with KafkaMessage // when GET called send message to topic @GET @Produces(MediaType.TEXT_PLAIN) public String hello() { generateSingle(); return "hello"; } @Outgoing("single-stations") public KafkaMessage<Integer, String> generateSingle() { return KafkaMessage.of(1, "value"); }; But i got a result that sending

Quarkus框架入门之二:依赖注入

 ̄綄美尐妖づ 提交于 2020-03-13 00:39:23
前言 Spring框架最开始被我熟知就是AOP和IOC,其中IOC在开发过程中更是被广泛使用,如果切换到一个新的框架没有了依赖注入和控制反转,那么可以说一夜回到解放前了。那么,Quarkus框架中有没有对应的功能呢? 当然也有,Quarkus基于CDI规范提供了依赖注入的相关功能,本文将进行简单介绍。 CDI-Contexts and Dependency Injection 简单介绍 CDI(Contexts and Dependency Injection),即上下文依赖注入,是J2EE6发布的一个标准规范,用于对上下文依赖注入的标准规范化,思想应该是来源于Spring的IOC,存在的年头已经挺久远。但是之前一直没怎么关注这个规范,都是用Spring Framework打天下。 以前以为只能在J2EE中使用,但是在写这篇文章的时候,发现在J2SE8.0已经可以使用CDI了,只需要明确引导CDI容器即可。 简单使用示例(J2SE) 以下以在一个简单的Java项目中使用weld实现依赖注入进行简单示例,依赖包如下: <dependency> <groupId>org.jboss.weld.se</groupId> <artifactId>weld-se-core</artifactId> <version>3.1.0.Final</version> </dependency> 首先

使用Quarkus在Openshift上构建微服务的快速指南

て烟熏妆下的殇ゞ 提交于 2020-03-13 00:38:57
在我的博客上,您有机会阅读了许多关于使用Spring Boot或Micronaut之类框架构建微服务的文章。这里将介绍另一个非常有趣的框架专门用于微服务体系结构,它越来越受到大家的关注– Quarkus 。它是作为下一代Kubernetes/Openshift原生Java框架引入的。它构建在著名的Java标准之上,如CDI、JAX-RS和Eclipse MicroProfile,这些标准将它与Spring Boot区别开来。 其他一些可能说服您使用Quarkus的特性包括非常快的启动时间、为在容器中运行而优化的最小内存占用,以及较短的首次请求时间。此外,尽管它是一个相对较新的框架(当前版本是0.21),但它有很多扩展,包括Hibernate、Kafka、RabbitMQ、Openapi和Vert.x等等。 在本文中,我将指导您使用Quarkus构建微服务,并在OpenShift(通过Minishift)上运行它们。我们将讨论以下主题: 构建基于rest的且包含输入校验的应用程序 微服务与RestClient之间的通信 开放健康检查(liveness, readiness) 开放OpenAPI /Swagger 文档 使用Quarkus Maven插件在本地机器上运行应用程序 使用JUnit和RestAssured进行测试 使用source

Quarkus框架入门之三:Quarkus与Spring Boot启动性能对比

谁说我不能喝 提交于 2020-03-13 00:37:10
开篇 为什么要从安逸的Spring全家桶切换到Quarkus框架呢?Quarkus有什么优势?除了能够编译成Native Application外,还有什么值得我们使用它的吗? Spring启动优化是个大难题,有专门出书写Spring启动优化的,特别是启动是的Bean扫描,当应用达到一定规模后,启动非常慢,一般开发人员又不太敢屏蔽一些Bean的初始化(谁知道会导致什么未知问题)。 Quarkus的一大优势就是快速启动,本文通过一个简单的应用对比以下传统Spring Boot项目与Quarkus项目的应用启动速度。 启动对比 首先,本文是对应一个简单的Restful服务进行启动时间对比,并不是实际真实项目,数据仅供参考。 对比应用概况 项目 Spring Boot Quarkus API 10个 10个 Service 10个 10个 Service Implement 10个 10个 打包方式 Jar Native 对比数据 Spring Boot Quarkus 第一次 3.664s 0.015s 第二次 3.655s 0.007s 第三次 3.338s 0.009s 平均 3.552s 0.010s 总结 通过以上简单对比,Quarkus打包成Native应用后启动速度对比传统Spring Boot的Jar部署方式,启动速度有很明显的提升。个人感觉这个是Quarkus的最大优势