zhfeng commented on code in PR #5317:
URL: https://github.com/apache/camel-quarkus/pull/5317#discussion_r1330895130


##########
extensions/jms/runtime/src/main/doc/usage.adoc:
##########
@@ -24,28 +24,93 @@ quarkus.pooled-jms.max-connections = 8
 endif::[]
 
 You can use the `quarkus-pooled-jms` extension to get pooling and XA support 
for JMS connections. Refer to the 
https://quarkiverse.github.io/quarkiverse-docs/quarkus-pooled-jms/dev/index.html[quarkus-pooled-jms]
 extension documentation for more information.
-Currently, it only works with `quarkus-artemis-jms` extension. Just add these 
two dependencies to your `pom.xml`:
+Currently, it can work with `quarkus-artemis-jms`, `quarkus-qpid-jms` and 
`ibmmq-client`. Just add the dependency to your `pom.xml`:
 [source,xml]
 ----
 <dependency>
     <groupId>io.quarkiverse.messaginghub</groupId>
     <artifactId>quarkus-pooled-jms</artifactId>
 </dependency>
+----
+
+Pooling is enabled by default.
+[NOTE]
+====
+`clientID` and `durableSubscriptionName` are not supported in pooling 
connections. If `setClientID` is called on a `reused` connection from the pool, 
an `IllegalStateException` will be thrown. You will get some error messages 
such like `Cause: setClientID can only be called directly after the connection 
is created`
+====
+
+To enable XA, you need to add `quarkus-narayana-jta` extension:
+[source,xml]
+----
 <dependency>
-    <groupId>io.quarkiverse.artemis</groupId>
-    <artifactId>quarkus-artemis-jms</artifactId>
+    <groupId>io.quarkus</groupId>
+    <artifactId>quarkus-narayana-jta</artifactId>
 </dependency>
 ----
+and add the following configuration to your `application.properties`:
+[source,properties]
+----
+quarkus.pooled-jms.transaction=xa
+quarkus.transaction-manager.enable-recovery=true
+----
 
-Note that pooling is enabled by default.
+XA support is only available with `quarkus-artemis-jms` and `ibmmq-client`. 
Also We highly recommend to enable transaction recovery.
 
-To enable XA, you need to add the following configuration to your 
`application.properties`:
-[source,properties]
+Since there is no quarkus extension for `ibmmq-client` currently, you need to 
create a custom `ConnectionFactory` and wrap it by yourself. Here is an example:
+[source,java]
 ----
-quarkus.pooled-jms.xa.enabled=true
+@Produces
+public ConnectionFactory createXAConnectionFactory(PooledJmsWrapper wrapper) {
+    MQXAConnectionFactory mq = new MQXAConnectionFactory();
+    try {
+        mq.setHostName(ConfigProvider.getConfig().getValue("ibm.mq.host", 
String.class));
+        mq.setPort(ConfigProvider.getConfig().getValue("ibm.mq.port", 
Integer.class));
+        mq.setChannel(ConfigProvider.getConfig().getValue("ibm.mq.channel", 
String.class));
+        
mq.setQueueManager(ConfigProvider.getConfig().getValue("ibm.mq.queueManagerName",
 String.class));
+        mq.setTransportType(WMQConstants.WMQ_CM_CLIENT);
+        mq.setStringProperty(WMQConstants.USERID,
+            ConfigProvider.getConfig().getValue("ibm.mq.user", String.class));
+        mq.setStringProperty(WMQConstants.PASSWORD,
+            ConfigProvider.getConfig().getValue("ibm.mq.password", 
String.class));
+    } catch (Exception e) {
+        throw new RuntimeException("Unable to create new IBM MQ connection 
factory", e);
+    }
+    return wrapper.wrapConnectionFactory(mq);
+}
 ----
 
 [NOTE]
 ====
-`clientID` and `durableSubscriptionName` are not supported in pooling 
connections. If `setClientID` is called on a `reused` connection from the pool, 
an `IllegalStateException` will be thrown. You will get some error messages 
such like `Cause: setClientID can only be called directly after the connection 
is created`
+If you use `ibmmq-client` to consumer messages and enable XA, you needs to 
config `TransactionManager` in the camel router like this:
+[source,java]
+----
+@Inject
+TransactionManager transactionManager;
+
+@Override
+public void configure() throws Exception {
+    from("jms:queue:DEV.QUEUE.XA?transactionManager=#jtaTransactionManager");
+}
+
+@BindToRegistry("jtaTransactionManager")

Review Comment:
   It should be good to use `@Named`.



-- 
This is an automated message from the Apache Git Service.
To respond to the message, please log on to GitHub and use the
URL above to go to the specific comment.

To unsubscribe, e-mail: commits-unsubscr...@camel.apache.org

For queries about this service, please contact Infrastructure at:
us...@infra.apache.org

Reply via email to