#Need help for a Quarkus app startup

1 messages · Page 1 of 1 (latest)

turbid sand
#

Hello, I'm developping a scarping app using Quarkus and Selenium, everything works "fine" but I ain't sure about the app startup.
Right now I'm using a AppBean class with the @ApplicationScoped annotation and a init method with the @Startup annotation.
The issue is that my app runs but it does before the last quarkus startup logs and I don't think that it's clean ?
How could I set this up so that Quarkus starts then my app executes ?
I'll only need my app to be run with the jar so there's no user interaction, is there conventions for app like these ? Maybe make a Quarkus CLI app instead ? Maybe use the @QuarkusMain annotation ? (tried this one but couldn't do what I wanted either)
Thanks !

obtuse sageBOT
#

<@&987246452180930620> please have a look, thanks.

#

Here is an AI assisted attempt to answer your question 🤖. Maybe it helps! In any case, a human is on the way 👍. To continue talking to the AI, you can use </chatgpt:1108714622413963314>.

#
TJ-Bot
Hello, I'm developping a scarping app using Quarkus and Selenium, everything works "fine" but I ain't sure about the app startup. Right now I'm using a `AppBean` class with the `@ApplicationScoped` annotation and a `init` method with the `@Startup` annotat

ass with a startApp method that initializes the Selenium driver, opens the browser, and starts scraping. However, I'm not sure if this is the best approach for app startup in Quarkus.

For Quarkus applications, it is recommended to use CDI beans for managing application startup. You can create a CDI bean that implements the ApplicationScoped interface to ensure it is only instantiated once during the application's lifecycle. In this bean, you can have a method annotated with @PostConstruct to perform any initialization tasks when the bean is created.

In your case, you can create a ScrapingService CDI bean with a method annotated with @PostConstruct to initialize the Selenium driver and start scraping. This way, the scraping process will be automatically triggered when the application starts up.

Additionally, you can leverage Quarkus extensions for Selenium integration to simplify your code and improve performance. The Quarkus Selenium extension provides easy integration with Selenium WebDriver and allows you to configure browser options directly in your application properties.

By following these best practices for app startup in Quarkus and utilizing its extensions effectively, you can ensure a smoother and more efficient scraping process in your application.