How to use Quarkus within a Java jar/nar?

142 views
Skip to first unread message

David Hoffer

unread,
Jun 29, 2021, 2:44:35 PM6/29/21
to Quarkus Development mailing list
We have developed several internally shared components/libraries that are used in Quarkus applications.

The components do have Quarkus dependencies as they often are things like shared ORM entities, HTTP/JAX-RS extensions, etc.  

These all work fine in our various Quarkus apps.

Now we have a use case where we need to use one of the components in a non-Quarkus application.  Specifically this would be used in a custom NiFi processor in a NAR package.

So my question is how can I embed Quarkus in that package?  Actually I already have the Maven build building the Quarkus fat jar which is put into a NAR but how can I tell Quarkus to start?  Is this possible?  E.g. I want to run Quarkus embedded in a NAR.

Note in this case we just need the basics of Quarkus, e.g. the component uses CDI & ORM/Hibernate/EntityManager so that is about all it needs to support (no Web/HTTP).

Thanks,
-Dave

Stuart Douglas

unread,
Jun 29, 2021, 5:48:57 PM6/29/21
to David Hoffer, Quarkus Development mailing list
Just calling Quarkus.run() should work I think, although this is not really something we test.

Stuart
 

Thanks,
-Dave

--
You received this message because you are subscribed to the Google Groups "Quarkus Development mailing list" group.
To unsubscribe from this group and stop receiving emails from it, send an email to quarkus-dev...@googlegroups.com.
To view this discussion on the web visit https://groups.google.com/d/msgid/quarkus-dev/87087678-a159-48d5-b641-67ff03541872n%40googlegroups.com.

David Hoffer

unread,
Jul 7, 2021, 2:32:20 PM7/7/21
to Quarkus Development mailing list
In case it helps anyone...  That worked great.  I put that in the startup of the NiFi custom processor.  We now have custom NiFi processors using Quarkus within the NiFi nar(s).

Only had two issues:
1. The Maven Nar build step will instantiate the NiFi service so you have to decouple it from running Quarkus (unless your CI build environment supports running Quarkus).  We fixed this by just checking if our DB host was resolvable and if not skip starting Quarkus.
2. Our Quarkus build generates a fat/uber jar but so does the nar...so done twice, but it's completely harmless apart from the larger nar size.

-Dave
Reply all
Reply to author
Forward
0 new messages