<p>We are creating a Mule application which will be running in a container on Kubernetes and will be in a replica set that will be connecting to JMS 2.0 Red Hat AMQ 7 (based on ActiveMQ Artemis).</p>

<p>The pom.xml has been configured to get the jms client:</p>

<pre class="lang-xml prettyprint-override"><code>&lt;dependency&gt;
  &lt;groupId&gt;org.apache.activemq&lt;/groupId&gt;
  &lt;artifactId&gt;artemis-jms-client-all&lt;/artifactId&gt;
  &lt;version&gt;2.10.1&lt;/version&gt;
&lt;/dependency&gt;
</code></pre>

<p>And the JMS config is configured as:</p>

<pre class="lang-xml prettyprint-override"><code>&lt;jms:config name="JMS_Config" doc:name="JMS Config" doc:id="8621b07d-b203-463e-bbbe-76eb03741a61" &gt;
    &lt;jms:generic-connection specification="JMS_2_0" username="${mq.user}" password="${mq.password}" clientId="${mq.client.id}"&gt;
        &lt;reconnection &gt;
            &lt;reconnect-forever frequency="${mq.reconnection.frequency}" /&gt;
        &lt;/reconnection&gt;
        &lt;jms:connection-factory &gt;
            &lt;jms:jndi-connection-factory connectionFactoryJndiName="ConnectionFactory" &gt;
                &lt;jms:name-resolver-builder jndiInitialContextFactory="org.apache.activemq.artemis.jndi.ActiveMQInitialContextFactory" jndiProviderUrl="${mq.brokerurl}"/&gt;
            &lt;/jms:jndi-connection-factory&gt;
        &lt;/jms:connection-factory&gt;
    &lt;/jms:generic-connection&gt;
    &lt;jms:consumer-config&gt;
        &lt;jms:consumer-type &gt;
            &lt;jms:topic-consumer shared="true" durable="true"/&gt;
        &lt;/jms:consumer-type&gt;
    &lt;/jms:consumer-config&gt;
    &lt;jms:producer-config persistentDelivery="true"/&gt;
&lt;/jms:config&gt;
</code></pre>

<p>Then in the JMS listener component:</p>

<pre class="lang-xml prettyprint-override"><code>&lt;jms:listener doc:name="EMS JMS Listener" doc:id="318b4f08-daf6-41f4-944b-3ec1420d5c12" config-ref="JMS_Config" destination="${mq.incoming.queue}" ackMode="AUTO" &gt;
    &lt;jms:consumer-type &gt;
        &lt;jms:topic-consumer shared="true" subscriptionName="${mq.sub.name}" durable="true"/&gt;
    &lt;/jms:consumer-type&gt;
    &lt;jms:response sendCorrelationId="ALWAYS" /&gt;
&lt;/jms:listener&gt;
</code></pre>

<p>The variables are set as:</p>

<pre><code>mq.client.id=client-id-135a9514-d4d5-4f52-b01c-f6ca34a76b40
mq.sub.name=my-sub
mq.incoming.queue=my-queue
</code></pre>

<p>Is this the best way to configure the client? As we have seen errors in the logs when deployed to K8s regarding connections to the AMQ server:</p>

<pre><code>javax.jms.InvalidClientIDException: client-id-135a9514-d4d5-4f52-b01c-f6ca34a76b40 was already set into another connection 
</code></pre>

Steve
<p>In JMS 2.0 you don't <em>have</em> to set the client identifier when creating a shared durable subscription. However, if you do set the client identifier then it must be unique per connection. For whatever reason (e.g. due to Mule or perhaps K8s) multiple connections are being created and since each connection is using the same client identifier you're receiving the <code>javax.jms.InvalidClientIDException</code>.</p>

<p>Remove <code>clientId="${mq.client.id}"</code> from your configuration and the <code>javax.jms.InvalidClientIDException</code> should go away.</p>
