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

Jean-Baptiste Onofré updated AMQ-9077:
--------------------------------------
    Fix Version/s: 6.3.0
                       (was: 6.2.0)

> IdGenerator broken when used in Quarkus native executable
> ---------------------------------------------------------
>
>                 Key: AMQ-9077
>                 URL: https://issues.apache.org/jira/browse/AMQ-9077
>             Project: ActiveMQ Classic
>          Issue Type: Bug
>          Components: AMQP
>    Affects Versions: 5.17.2
>            Reporter: Ales Nosek
>            Assignee: Jean-Baptiste Onofré
>            Priority: Major
>             Fix For: 6.3.0
>
>
> 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)

---------------------------------------------------------------------
To unsubscribe, e-mail: [email protected]
For additional commands, e-mail: [email protected]
For further information, visit: https://activemq.apache.org/contact


Reply via email to