avano commented on code in PR #165:
URL: 
https://github.com/apache/camel-quarkus-examples/pull/165#discussion_r1360671391


##########
message-bridge/README.adoc:
##########
@@ -0,0 +1,206 @@
+= Message Bridge: A Camel Quarkus example
+:cq-example-description: An example that shows how to configure AMQ and IBM MQ 
clients to use the connection pooling and XA transactions.
+
+{cq-description}
+
+TIP: Check the 
https://camel.apache.org/camel-quarkus/latest/first-steps.html[Camel Quarkus 
User guide] for prerequisites
+and other general information.
+
+== Overview
+
+In this example, a basic REST endpoint is provided for users to dispatch a 
message to the IBM MQ queue. Subsequently, all messages from the IBM MQ are 
relayed to an ActiveMQ queue within an XA transaction. To showcase the 
transaction functionality, a message containing the keyword "rollback" will 
initiate a transaction rollback. To demonstrate the process of a transaction 
recovery after a crash, send a message with they keyword "crash".
+
+Details regarding client configurations can be located in the 
`src/main/resources/application.properties` file.
+
+== Prerequisites
+
+First start the ActiveMQ broker:
+----
+docker run \
+  -d \
+  -e AMQ_USER=admin \
+  -e AMQ_PASSWORD=admin \
+  -p 61616:61616 \
+  quay.io/artemiscloud/activemq-artemis-broker
+----
+
+Then start the IBM MQ broker:
+----
+docker run \
+  -d \
+  -e LICENSE=accept \
+  -e MQ_QMGR_NAME=QM1 \
+  -e MQ_APP_PASSWORD=passw0rd \
+  -p 1414:1414 \
+  icr.io/ibm-messaging/mq:9.3.2.1-r1
+----
+
+== Start in the Development mode
+
+[source,shell]
+----
+$ mvn clean compile quarkus:dev
+----
+
+The above command compiles the project, starts the application and lets the 
Quarkus tooling watch for changes in your
+workspace. Any modifications in your project will automatically take effect in 
the running application.
+
+TIP: Please refer to the Development mode section of
+https://camel.apache.org/camel-quarkus/latest/first-steps.html#_development_mode[Camel
 Quarkus User guide] for more details.
+
+After the application is started, you can send messages to the IBMMQ queue 
using the rest endpoint `/message`:
+
+----
+curl -X POST -H "Content-Type: text/plain" http://localhost:8080/message -d 
'Hello World'
+----
+
+In the application logs you will see:
+
+----
+2023-10-11 08:10:52,782 INFO  [ibmmq] (executor-thread-1) Sending message to 
IBMMQ: Hello World
+2023-10-11 08:10:52,903 INFO  [ibmmq-amq] (Camel (camel-4) thread #7 - 
JmsConsumer[DEV.QUEUE.1]) Sending message from IBMMQ to ActiveMQ: Hello World
+2023-10-11 08:10:52,927 INFO  [amq] (Camel (camel-4) thread #8 - 
JmsConsumer[in]) ActiveMQ received: Hello World
+----
+
+The message is initially dispatched to an IBMMQ queue, then relayed to an 
ActiveMQ queue, and ultimately retrieved from the ActiveMQ queue and printed to 
the log without any issues.
+
+=== Transaction rollback
+
+If you wish to illustrate a rollback, simply send a message containing the 
`rollback` keyword.
+
+----
+curl -X POST -H "Content-Type: text/plain" http://localhost:8080/message -d 
'Hello rollback'
+----
+The log could be divided into two segments. In this demonstration, the IBMMQ 
to ActiveMQ route is configured to simulate a transaction rollback following 
the dispatch of a message to the ActiveMQ queue. Due to the rollback, you'll 
notice that the message isn't fetched from the ActiveMQ queue and isn't logged:
+
+----
+2023-10-11 08:12:46,314 INFO  [ibmmq] (executor-thread-1) Sending message to 
IBMMQ: Hello rollback
+2023-10-11 08:12:46,453 INFO  [ibmmq-amq] (Camel (camel-4) thread #7 - 
JmsConsumer[DEV.QUEUE.1]) Sending message from IBMMQ to ActiveMQ: Hello rollback
+2023-10-11 08:12:46,457 WARN  [org.apa.cam.jta.TransactionErrorHandler] (Camel 
(camel-4) thread #7 - JmsConsumer[DEV.QUEUE.1]) Transaction rollback 
(0xea2b886) redelivered(false) for (MessageId: 
ID:414d5120514d312020202020202020206437266503e30040 on ExchangeId: 
01C264F444F3A96-0000000000000003) caught: Simulated rollback
+2023-10-11 08:12:46,458 ERROR [org.apa.cam.jta.TransactionErrorHandler] (Camel 
(camel-4) thread #7 - JmsConsumer[DEV.QUEUE.1]) Failed delivery for (MessageId: 
ID:414d5120514d312020202020202020206437266503e30040 on ExchangeId: 
01C264F444F3A96-0000000000000003). Exhausted after delivery attempt: 1 caught: 
java.lang.RuntimeException: Simulated rollback
+...
+<truncated exception from the simulated rollback>
+----
+
+Because the transaction was rolled back, the message wasn't successfully 
processed and it is returned to the IBMMQ queue and subsequently redelivered. 
In this instance, the delivery is successful and logged accordingly:
+
+----
+2023-10-11 08:12:46,561 INFO  [ibmmq-amq] (Camel (camel-4) thread #7 - 
JmsConsumer[DEV.QUEUE.1]) Redelivering message after rollback to ActiveMQ: 
Hello rollback
+2023-10-11 08:12:46,567 INFO  [org.apa.cam.jta.TransactionErrorHandler] (Camel 
(camel-4) thread #7 - JmsConsumer[DEV.QUEUE.1]) Transaction commit (0xea2b886) 
redelivered(true) for (MessageId: 
ID:414d5120514d312020202020202020206437266503e30040 on ExchangeId: 
01C264F444F3A96-0000000000000004))
+2023-10-11 08:12:46,585 INFO  [amq] (Camel (camel-4) thread #8 - 
JmsConsumer[in]) ActiveMQ received: Hello rollback
+----
+
+In this example, a local file transaction storage is used, which is set up 
through the `quarkus.transaction-manager.object-store.directory` property. If 
you prefer to utilize a database for configuring the storage, please refer to 
the Quarkus transactions guide available at 
https://quarkus.io/guides/transaction#jdbcstore.
+
+=== Transaction recovery
+
+To trigger a JVM crash during the transaction, send a message containing the 
word `crash`.
+
+----
+curl -X POST -H "Content-Type: text/plain" http://localhost:8080/message -d 
'Hello rollback'

Review Comment:
   thanks, copy-paste error



-- 
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: [email protected]

For queries about this service, please contact Infrastructure at:
[email protected]

Reply via email to