You are viewing a plain text version of this content. The canonical link for it is here.
Posted to issues@activemq.apache.org by "Jean-Baptiste Onofré (Jira)" <ji...@apache.org> on 2022/10/30 16:25:00 UTC

[jira] [Assigned] (AMQ-9077) IdGenerator broken when used in Quarkus native executable

     [ https://issues.apache.org/jira/browse/AMQ-9077?page=com.atlassian.jira.plugin.system.issuetabpanels:all-tabpanel ]

Jean-Baptiste Onofré reassigned AMQ-9077:
-----------------------------------------

    Assignee: Jean-Baptiste Onofré

> IdGenerator broken when used in Quarkus native executable
> ---------------------------------------------------------
>
>                 Key: AMQ-9077
>                 URL: https://issues.apache.org/jira/browse/AMQ-9077
>             Project: ActiveMQ
>          Issue Type: Bug
>          Components: AMQP
>    Affects Versions: 5.17.2
>            Reporter: Ales Nosek
>            Assignee: Jean-Baptiste Onofré
>            Priority: Major
>
> In a Quarkus-based application, we make use of the activemq-client library. We built our application using:
> {code:java}
> $ mvn -Pnative package
> {code}
> which creates a native executable. After that, we start several instances of this executable. After these instances connect to the AMQ broker, we can see that the connection clientId which is supposed to be unique per running instance is the same for all instances.
> We examined the [code of IdGenerator|https://github.com/apache/activemq/blob/activemq-5.17.2/activemq-client/src/main/java/org/apache/activemq/util/IdGenerator.java] that generates the clientId.
> IdGenerator creates a random part of clientId by calling System.currentTimeMillis() within a static initialization block. Unfortunately, by default Quarkus runs the static initialization block only once in build time (not in runtime). This causes all instances of our application to use the exact same clientId.
> We corrected this issue by configuring Quarkus to [postpone the initialization to runtime|https://quarkus.io/guides/writing-native-applications-tips#delay-class-init-in-your-app]. In particular, adding the following configuration to the pom.xml fixed the issue:
> {code:java}
> <project ...>
>   <properties>
>     ...
>     <quarkus.native.additional-build-args>--initialize-at-run-time=org.apache.activemq.util.IdGenerator</quarkus.native.additional-build-args>
>     ...
>   </properties>
>   ...
> </project>
> {code}
> Would it make sense to modify the code of IdGenerator to make it work with Quarkus right away? The IdGenerator on Quarkus is silently broken, there is no clear indication that there is something wrong with the application until one day ...



--
This message was sent by Atlassian Jira
(v8.20.10#820010)