http://git-wip-us.apache.org/repos/asf/activemq-artemis/blob/b77cdaf7/examples/features/standard/ssl-enabled-dual-authentication/pom.xml ---------------------------------------------------------------------- diff --git a/examples/features/standard/ssl-enabled-dual-authentication/pom.xml b/examples/features/standard/ssl-enabled-dual-authentication/pom.xml index d106915..9984924 100644 --- a/examples/features/standard/ssl-enabled-dual-authentication/pom.xml +++ b/examples/features/standard/ssl-enabled-dual-authentication/pom.xml @@ -104,7 +104,23 @@ under the License. </dependency> </dependencies> </plugin> + <plugin> + <groupId>org.apache.maven.plugins</groupId> + <artifactId>maven-clean-plugin</artifactId> + </plugin> </plugins> </build> - -</project> + <profiles> + <profile> + <id>release</id> + <build> + <plugins> + <plugin> + <groupId>com.vladsch.flexmark</groupId> + <artifactId>markdown-page-generator-plugin</artifactId> + </plugin> + </plugins> + </build> + </profile> + </profiles> +</project> \ No newline at end of file
http://git-wip-us.apache.org/repos/asf/activemq-artemis/blob/b77cdaf7/examples/features/standard/ssl-enabled-dual-authentication/readme.html ---------------------------------------------------------------------- diff --git a/examples/features/standard/ssl-enabled-dual-authentication/readme.html b/examples/features/standard/ssl-enabled-dual-authentication/readme.html deleted file mode 100644 index 93d7c72..0000000 --- a/examples/features/standard/ssl-enabled-dual-authentication/readme.html +++ /dev/null @@ -1,75 +0,0 @@ -<!-- -Licensed to the Apache Software Foundation (ASF) under one -or more contributor license agreements. See the NOTICE file -distributed with this work for additional information -regarding copyright ownership. The ASF licenses this file -to you under the Apache License, Version 2.0 (the -"License"); you may not use this file except in compliance -with the License. You may obtain a copy of the License at - - http://www.apache.org/licenses/LICENSE-2.0 - -Unless required by applicable law or agreed to in writing, -software distributed under the License is distributed on an -"AS IS" BASIS, WITHOUT WARRANTIES OR CONDITIONS OF ANY -KIND, either express or implied. See the License for the -specific language governing permissions and limitations -under the License. ---> - -<html> - <head> - <title>ActiveMQ Artemis JMS SSL Example</title> - <link rel="stylesheet" type="text/css" href="../../../common/common.css" /> - <link rel="stylesheet" type="text/css" href="../../../common/prettify.css" /> - <script type="text/javascript" src="../../../common/prettify.js"></script> - </head> - <body onload="prettyPrint()"> - <h1>JMS SSL Dual Authentication Example</h1> - - <pre>To run the example, simply type <b>mvn verify</b> from this directory, <br>or <b>mvn -PnoServer verify</b> if you want to start and create the server manually.</pre> - - <p>This example shows you how to configure 2-way SSL along with 2 different authentications mechanisms so that SSL and non-SSL clients can send and consume messages to/from ActiveMQ Artemis. - The non-SSL authentication mechanism simply uses username and password. The SSL authentication mechanism uses the client's certificate.</p> - - <p>To configure 2-way SSL you need to configure the acceptor as follows:</p> - - <p> - <pre class="prettyprint"> - <code> - <!-- Acceptor --> - - <acceptor name="netty-ssl-acceptor">tcp://localhost:5500?sslEnabled=true;needClientAuth=true;keyStorePath=${data.dir}/../etc/server-side-keystore.jks;keyStorePassword=secureexample;trustStorePath=${data.dir}/../etc/server-side-truststore.jks;trustStorePassword=secureexample</acceptor> - </code> - </pre> - </p> - - <p>In the server-side URL, the server-side-keystore.jks is the key store file holding the server's certificate. The server-side-truststore.jks is the file holding the certificates which the server trusts. Notice also the "sslEnabled" and "needClientAuth" parameters which enable SSL and require clients to present their own certificate respectively. Here's the URL the client uses to connect over SSL:</p> - - <p> - <pre class="prettyprint"> - <code> - tcp://localhost:5500?sslEnabled=true&trustStorePath=activemq/server0/client-side-truststore.jks&trustStorePassword=secureexample&keyStorePath=activemq/server0/client-side-keystore.jks&keyStorePassword=secureexample - </code> - </pre> - </p> - - <p>In the client-side URL, the client-side-keystore.jks is the key store file holding the client's certificate. The client-side-truststore.jks is the file holding the certificates which the client trusts. The "sslEnabled" parameter is present here as well just as it is on the server.</p> - - <p>The various keystore files are generated using the following commands:</p> - - <p> - <pre class="prettyprint"> - <code> -keytool -genkey -keystore server-side-keystore.jks -storepass secureexample -keypass secureexample -dname "CN=ActiveMQ Artemis Server, OU=Artemis, O=ActiveMQ, L=AMQ, S=AMQ, C=AMQ" -keyalg RSA -keytool -export -keystore server-side-keystore.jks -file server-side-cert.cer -storepass secureexample -keytool -import -keystore client-side-truststore.jks -file server-side-cert.cer -storepass secureexample -keypass secureexample -noprompt -keytool -genkey -keystore client-side-keystore.jks -storepass secureexample -keypass secureexample -dname "CN=ActiveMQ Artemis Client, OU=Artemis, O=ActiveMQ, L=AMQ, S=AMQ, C=AMQ" -keyalg RSA -keytool -export -keystore client-side-keystore.jks -file client-side-cert.cer -storepass secureexample -keytool -import -keystore server-side-truststore.jks -file client-side-cert.cer -storepass secureexample -keypass secureexample -noprompt - </code> - </pre> - </p> - - </body> -</html> http://git-wip-us.apache.org/repos/asf/activemq-artemis/blob/b77cdaf7/examples/features/standard/ssl-enabled-dual-authentication/readme.md ---------------------------------------------------------------------- diff --git a/examples/features/standard/ssl-enabled-dual-authentication/readme.md b/examples/features/standard/ssl-enabled-dual-authentication/readme.md new file mode 100644 index 0000000..1fbe0da --- /dev/null +++ b/examples/features/standard/ssl-enabled-dual-authentication/readme.md @@ -0,0 +1,26 @@ +# JMS SSL Dual Authentication Example + +To run the example, simply type **mvn verify** from this directory, or **mvn -PnoServer verify** if you want to start and create the broker manually. + +This example shows you how to configure 2-way SSL along with 2 different authentications mechanisms so that SSL and non-SSL clients can send and consume messages to/from ActiveMQ Artemis. The non-SSL authentication mechanism simply uses username and password. The SSL authentication mechanism uses the client's certificate. + +To configure 2-way SSL you need to configure the acceptor as follows: + + <acceptor name="netty-ssl-acceptor">tcp://localhost:5500?sslEnabled=true;needClientAuth=true;keyStorePath=server-side-keystore.jks;keyStorePassword=secureexample;trustStorePath=server-side-truststore.jks;trustStorePassword=secureexample</acceptor> + +In the server-side URL, the `server-side-keystore.jks` is the key store file holding the server's certificate. The `server-side-truststore.jks` is the file holding the certificates which the broker trusts. Notice also the `sslEnabled` and `needClientAuth` parameters which enable SSL and require clients to present their own certificate respectively. + +Here's the URL the client uses to connect over SSL: + + tcp://localhost:5500?sslEnabled=true&trustStorePath=activemq/server0/client-side-truststore.jks&trustStorePassword=secureexample&keyStorePath=activemq/server0/client-side-keystore.jks&keyStorePassword=secureexample + +In the client-side URL, the `client-side-keystore.jks` is the key store file holding the client's certificate. The `client-side-truststore.jks` is the file holding the certificates which the client trusts. The `sslEnabled` parameter is present here as well just as it is on the server. + +The various keystore files are generated using the following commands: + +* `keytool -genkey -keystore server-side-keystore.jks -storepass secureexample -keypass secureexample -dname "CN=ActiveMQ Artemis Server, OU=Artemis, O=ActiveMQ, L=AMQ, S=AMQ, C=AMQ" -keyalg RSA` +* `keytool -export -keystore server-side-keystore.jks -file server-side-cert.cer -storepass secureexample` +* `keytool -import -keystore client-side-truststore.jks -file server-side-cert.cer -storepass secureexample -keypass secureexample -noprompt` +* `keytool -genkey -keystore client-side-keystore.jks -storepass secureexample -keypass secureexample -dname "CN=ActiveMQ Artemis Client, OU=Artemis, O=ActiveMQ, L=AMQ, S=AMQ, C=AMQ" -keyalg RSA` +* `keytool -export -keystore client-side-keystore.jks -file client-side-cert.cer -storepass secureexample` +* `keytool -import -keystore server-side-truststore.jks -file client-side-cert.cer -storepass secureexample -keypass secureexample -noprompt` http://git-wip-us.apache.org/repos/asf/activemq-artemis/blob/b77cdaf7/examples/features/standard/ssl-enabled-dual-authentication/src/main/resources/activemq/server0/broker.xml ---------------------------------------------------------------------- diff --git a/examples/features/standard/ssl-enabled-dual-authentication/src/main/resources/activemq/server0/broker.xml b/examples/features/standard/ssl-enabled-dual-authentication/src/main/resources/activemq/server0/broker.xml index 420fa74..1bba774 100644 --- a/examples/features/standard/ssl-enabled-dual-authentication/src/main/resources/activemq/server0/broker.xml +++ b/examples/features/standard/ssl-enabled-dual-authentication/src/main/resources/activemq/server0/broker.xml @@ -16,10 +16,8 @@ software distributed under the License is distributed on an KIND, either express or implied. See the License for the specific language governing permissions and limitations under the License. ---><configuration xmlns="urn:activemq" xmlns:xsi="http://www.w3.org/2001/XMLSchema-instance" xsi:schemaLocation="urn:activemq /schema/artemis-server.xsd"> - - - +--> +<configuration xmlns="urn:activemq" xmlns:xsi="http://www.w3.org/2001/XMLSchema-instance" xsi:schemaLocation="urn:activemq /schema/artemis-configuration.xsd"> <core xmlns="urn:activemq:core"> <bindings-directory>./data/messaging/bindings</bindings-directory> @@ -33,7 +31,7 @@ under the License. <!-- Acceptors --> <acceptors> <acceptor name="netty-acceptor">tcp://localhost:61616</acceptor> - <acceptor name="netty-ssl-acceptor">tcp://localhost:5500?sslEnabled=true;needClientAuth=true;keyStorePath=${data.dir}/../etc/server-side-keystore.jks;keyStorePassword=secureexample;trustStorePath=${data.dir}/../etc/server-side-truststore.jks;trustStorePassword=secureexample</acceptor> + <acceptor name="netty-ssl-acceptor">tcp://localhost:5500?sslEnabled=true;needClientAuth=true;keyStorePath=server-side-keystore.jks;keyStorePassword=secureexample;trustStorePath=server-side-truststore.jks;trustStorePassword=secureexample</acceptor> </acceptors> <!-- Other config --> @@ -46,7 +44,7 @@ under the License. </security-setting> </security-settings> - <addresses> + <addresses> <address name="exampleQueue"> <anycast> <queue name="exampleQueue"/> http://git-wip-us.apache.org/repos/asf/activemq-artemis/blob/b77cdaf7/examples/features/standard/ssl-enabled/pom.xml ---------------------------------------------------------------------- diff --git a/examples/features/standard/ssl-enabled/pom.xml b/examples/features/standard/ssl-enabled/pom.xml index 7bcc83a..bcfe9dd 100644 --- a/examples/features/standard/ssl-enabled/pom.xml +++ b/examples/features/standard/ssl-enabled/pom.xml @@ -102,7 +102,23 @@ under the License. </dependency> </dependencies> </plugin> + <plugin> + <groupId>org.apache.maven.plugins</groupId> + <artifactId>maven-clean-plugin</artifactId> + </plugin> </plugins> </build> - -</project> + <profiles> + <profile> + <id>release</id> + <build> + <plugins> + <plugin> + <groupId>com.vladsch.flexmark</groupId> + <artifactId>markdown-page-generator-plugin</artifactId> + </plugin> + </plugins> + </build> + </profile> + </profiles> +</project> \ No newline at end of file http://git-wip-us.apache.org/repos/asf/activemq-artemis/blob/b77cdaf7/examples/features/standard/ssl-enabled/readme.html ---------------------------------------------------------------------- diff --git a/examples/features/standard/ssl-enabled/readme.html b/examples/features/standard/ssl-enabled/readme.html deleted file mode 100644 index bb5e724..0000000 --- a/examples/features/standard/ssl-enabled/readme.html +++ /dev/null @@ -1,56 +0,0 @@ -<!-- -Licensed to the Apache Software Foundation (ASF) under one -or more contributor license agreements. See the NOTICE file -distributed with this work for additional information -regarding copyright ownership. The ASF licenses this file -to you under the Apache License, Version 2.0 (the -"License"); you may not use this file except in compliance -with the License. You may obtain a copy of the License at - - http://www.apache.org/licenses/LICENSE-2.0 - -Unless required by applicable law or agreed to in writing, -software distributed under the License is distributed on an -"AS IS" BASIS, WITHOUT WARRANTIES OR CONDITIONS OF ANY -KIND, either express or implied. See the License for the -specific language governing permissions and limitations -under the License. ---> - -<html> - <head> - <title>ActiveMQ Artemis JMS SSL Example</title> - <link rel="stylesheet" type="text/css" href="../../../common/common.css" /> - <link rel="stylesheet" type="text/css" href="../../../common/prettify.css" /> - <script type="text/javascript" src="../../../common/prettify.js"></script> - </head> - <body onload="prettyPrint()"> - <h1>JMS SSL Example</h1> - - <pre>To run the example, simply type <b>mvn verify</b> from this directory, <br>or <b>mvn -PnoServer verify</b> if you want to start and create the server manually.</pre> - - - <p>This example shows you how to configure SSL with ActiveMQ Artemis to send and receive message. </p> - - <p>Using SSL can make your messaging applications interact with ActiveMQ Artemis securely. An application can - be secured transparently without extra coding effort. To secure your messaging application with SSL, you need to configure connector and acceptor as follows:</p> - - <p> - <pre class="prettyprint"> - <code> - <!-- Connector --> - - <connector name="netty-ssl-connector">tcp://localhost:5500?sslEnabled=true;keyStorePath=activemq/server0/activemq.example.keystore;keyStorePassword=activemqexample</connector> - - <!-- Acceptor --> - - <acceptor name="netty-ssl-acceptor">tcp://localhost:5500?sslEnabled=true;keyStorePath=activemq/server0/activemq.example.keystore;keyStorePassword=activemqexample</acceptor> - - </code> - </pre> - </p> - - <p>In the configuration, the activemq.example.keystore is the key store file holding the server's certificate. The activemq.example.truststore - is the file holding the certificates which the client trusts (i.e. the server's certificate exported from activemq.example.keystore). They are pre-generated for illustration purpose<a id="fnr1" href="readme.html#fn1"><sup>1</sup></a>.</p> - </body> -</html> http://git-wip-us.apache.org/repos/asf/activemq-artemis/blob/b77cdaf7/examples/features/standard/ssl-enabled/readme.md ---------------------------------------------------------------------- diff --git a/examples/features/standard/ssl-enabled/readme.md b/examples/features/standard/ssl-enabled/readme.md new file mode 100644 index 0000000..6038f6d --- /dev/null +++ b/examples/features/standard/ssl-enabled/readme.md @@ -0,0 +1,15 @@ +# JMS SSL Example + +To run the example, simply type **mvn verify** from this directory, or **mvn -PnoServer verify** if you want to start and create the broker manually. + +This example shows you how to configure SSL with ActiveMQ Artemis to send and receive message. + +Using SSL can make your messaging applications interact with ActiveMQ Artemis securely. An application can be secured transparently without extra coding effort. To secure your messaging application with SSL, you need to configure connector and acceptor as follows: + + <acceptor name="netty-ssl-acceptor">tcp://localhost:5500?sslEnabled=true;keyStorePath=activemq.example.keystore;keyStorePassword=activemqexample</acceptor> + +In the configuration, the `activemq.example.keystore` is the key store file holding the server's certificate. The `activemq.example.truststore` is the file holding the certificates which the client trusts (i.e. the server's certificate exported from activemq.example.keystore). They are generated via the following commands: + +* `keytool -genkey -keystore activemq.example.keystore -storepass activemqexample -keypass activemqexample -dname "CN=ActiveMQ Artemis Server, OU=Artemis, O=ActiveMQ, L=AMQ, S=AMQ, C=AMQ" -keyalg RSA` +* `keytool -export -keystore activemq.example.keystore -file server-side-cert.cer -storepass activemqexample` +* `keytool -import -keystore activemq.example.truststore -file server-side-cert.cer -storepass activemqexample -keypass activemqexample -noprompt` \ No newline at end of file http://git-wip-us.apache.org/repos/asf/activemq-artemis/blob/b77cdaf7/examples/features/standard/ssl-enabled/src/main/resources/activemq/server0/activemq.example.keystore ---------------------------------------------------------------------- diff --git a/examples/features/standard/ssl-enabled/src/main/resources/activemq/server0/activemq.example.keystore b/examples/features/standard/ssl-enabled/src/main/resources/activemq/server0/activemq.example.keystore index 50de681..4ed2413 100644 Binary files a/examples/features/standard/ssl-enabled/src/main/resources/activemq/server0/activemq.example.keystore and b/examples/features/standard/ssl-enabled/src/main/resources/activemq/server0/activemq.example.keystore differ http://git-wip-us.apache.org/repos/asf/activemq-artemis/blob/b77cdaf7/examples/features/standard/ssl-enabled/src/main/resources/activemq/server0/activemq.example.truststore ---------------------------------------------------------------------- diff --git a/examples/features/standard/ssl-enabled/src/main/resources/activemq/server0/activemq.example.truststore b/examples/features/standard/ssl-enabled/src/main/resources/activemq/server0/activemq.example.truststore index 129391a..45ab086 100644 Binary files a/examples/features/standard/ssl-enabled/src/main/resources/activemq/server0/activemq.example.truststore and b/examples/features/standard/ssl-enabled/src/main/resources/activemq/server0/activemq.example.truststore differ http://git-wip-us.apache.org/repos/asf/activemq-artemis/blob/b77cdaf7/examples/features/standard/ssl-enabled/src/main/resources/activemq/server0/broker.xml ---------------------------------------------------------------------- diff --git a/examples/features/standard/ssl-enabled/src/main/resources/activemq/server0/broker.xml b/examples/features/standard/ssl-enabled/src/main/resources/activemq/server0/broker.xml index 11f6c3d..04bcec5 100644 --- a/examples/features/standard/ssl-enabled/src/main/resources/activemq/server0/broker.xml +++ b/examples/features/standard/ssl-enabled/src/main/resources/activemq/server0/broker.xml @@ -16,10 +16,8 @@ software distributed under the License is distributed on an KIND, either express or implied. See the License for the specific language governing permissions and limitations under the License. ---><configuration xmlns="urn:activemq" xmlns:xsi="http://www.w3.org/2001/XMLSchema-instance" xsi:schemaLocation="urn:activemq /schema/artemis-server.xsd"> - - - +--> +<configuration xmlns="urn:activemq" xmlns:xsi="http://www.w3.org/2001/XMLSchema-instance" xsi:schemaLocation="urn:activemq /schema/artemis-configuration.xsd"> <core xmlns="urn:activemq:core"> <bindings-directory>./data/messaging/bindings</bindings-directory> @@ -32,7 +30,8 @@ under the License. <!-- Acceptors --> <acceptors> - <acceptor name="netty-ssl-acceptor">tcp://localhost:5500?sslEnabled=true;keyStorePath=${data.dir}/../etc/activemq.example.keystore;keyStorePassword=activemqexample</acceptor> + <!-- keystores will be found automatically if they are on the classpath --> + <acceptor name="netty-ssl-acceptor">tcp://localhost:5500?sslEnabled=true;keyStorePath=activemq.example.keystore;keyStorePassword=activemqexample</acceptor> </acceptors> <!-- Other config --> @@ -49,7 +48,7 @@ under the License. </security-setting> </security-settings> - <addresses> + <addresses> <address name="exampleQueue"> <anycast> <queue name="exampleQueue"/> http://git-wip-us.apache.org/repos/asf/activemq-artemis/blob/b77cdaf7/examples/features/standard/static-selector/pom.xml ---------------------------------------------------------------------- diff --git a/examples/features/standard/static-selector/pom.xml b/examples/features/standard/static-selector/pom.xml index 513ecad..9e73c75 100644 --- a/examples/features/standard/static-selector/pom.xml +++ b/examples/features/standard/static-selector/pom.xml @@ -102,7 +102,23 @@ under the License. </dependency> </dependencies> </plugin> + <plugin> + <groupId>org.apache.maven.plugins</groupId> + <artifactId>maven-clean-plugin</artifactId> + </plugin> </plugins> </build> - -</project> + <profiles> + <profile> + <id>release</id> + <build> + <plugins> + <plugin> + <groupId>com.vladsch.flexmark</groupId> + <artifactId>markdown-page-generator-plugin</artifactId> + </plugin> + </plugins> + </build> + </profile> + </profiles> +</project> \ No newline at end of file http://git-wip-us.apache.org/repos/asf/activemq-artemis/blob/b77cdaf7/examples/features/standard/static-selector/readme.html ---------------------------------------------------------------------- diff --git a/examples/features/standard/static-selector/readme.html b/examples/features/standard/static-selector/readme.html deleted file mode 100644 index 0dca49f..0000000 --- a/examples/features/standard/static-selector/readme.html +++ /dev/null @@ -1,60 +0,0 @@ -<!-- -Licensed to the Apache Software Foundation (ASF) under one -or more contributor license agreements. See the NOTICE file -distributed with this work for additional information -regarding copyright ownership. The ASF licenses this file -to you under the Apache License, Version 2.0 (the -"License"); you may not use this file except in compliance -with the License. You may obtain a copy of the License at - - http://www.apache.org/licenses/LICENSE-2.0 - -Unless required by applicable law or agreed to in writing, -software distributed under the License is distributed on an -"AS IS" BASIS, WITHOUT WARRANTIES OR CONDITIONS OF ANY -KIND, either express or implied. See the License for the -specific language governing permissions and limitations -under the License. ---> - -<html> - <head> - <title>ActiveMQ Artemis Static Message Selector Example</title> - <link rel="stylesheet" type="text/css" href="../../../common/common.css" /> - <link rel="stylesheet" type="text/css" href="../../../common/prettify.css" /> - <script type="text/javascript" src="../../../common/prettify.js"></script> - </head> - <body onload="prettyPrint()"> - <h1>Static Message Selector Example</h1> - - <pre>To run the example, simply type <b>mvn verify</b> from this directory, <br>or <b>mvn -PnoServer verify</b> if you want to start and create the server manually.</pre> - - - <p>This example shows you how to configure a ActiveMQ Artemis queue with static message selectors (filters) - (to configure a static selector directly on a <em>JMS</em> queue, please see the - <a href="../static-selector-jms/readme.html">static-selector-jms example</a>).</p> - - <p>Static message selectors are ActiveMQ's extension to message selectors as defined in JMS spec 1.1. - Rather than specifying the selector in the application code, static message selectors are defined in one of - ActiveMQ's configuration files, broker.xml, as an element called 'filter' inside each queue - definition, like</p> - - <pre class="prettyprint"><code> - <queues> - <queue name="jms.queue.selectorQueue"> - <address>jms.queue.selectorQueue</address> - <filter string="color='red'"/> - </queue> - </queues> - </code></pre> - - <p>Once configured the queue 'selectorQueue' only delivers messages that are selected against the filter, i.e., - only the messages whose 'color' properties are of 'red' values can be received by its consumers. Those that don't match - the filter will be dropped by the queue and therefore will never be delivered to any of its consumers.</p> - - <p>In the example code, five messages with different 'color' property values are sent to queue 'selectorQueue'. One consumer - is created to receive messages from the queue. Of the five sent messages, two are of 'red' color properties, one is 'blue', - one is 'green' and one has not the 'color' property at all. The result is that the consumer only gets the two 'red' messages.</p> - - </body> -</html> http://git-wip-us.apache.org/repos/asf/activemq-artemis/blob/b77cdaf7/examples/features/standard/static-selector/readme.md ---------------------------------------------------------------------- diff --git a/examples/features/standard/static-selector/readme.md b/examples/features/standard/static-selector/readme.md new file mode 100644 index 0000000..0890840 --- /dev/null +++ b/examples/features/standard/static-selector/readme.md @@ -0,0 +1,11 @@ +# Static Message Selector Example + +To run the example, simply type **mvn verify** from this directory, or **mvn -PnoServer verify** if you want to start and create the broker manually. + +This example shows you how to configure a ActiveMQ Artemis queue with static message selectors (filters). + +Static message selectors are ActiveMQ's extension to message selectors as defined in JMS spec 1.1. Rather than specifying the selector in the application code, static message selectors are defined in one of ActiveMQ's configuration files, broker.xml, as an element called `filter` inside each queue definition, like + +Once configured the queue `selectorQueue` only delivers messages that are selected against the filter, i.e., only the messages whose `color` properties are of `red` values can be received by its consumers. Those that don't match the filter will be dropped by the queue and therefore will never be delivered to any of its consumers. + +In the example code, five messages with different `color` property values are sent to queue `selectorQueue`. One consumer is created to receive messages from the queue. Of the five sent messages, two are of `red` color properties, one is `blue`, one is `green` and one has not the `color` property at all. The result is that the consumer only gets the two `red` messages. \ No newline at end of file http://git-wip-us.apache.org/repos/asf/activemq-artemis/blob/b77cdaf7/examples/features/standard/static-selector/src/main/resources/activemq/server0/broker.xml ---------------------------------------------------------------------- diff --git a/examples/features/standard/static-selector/src/main/resources/activemq/server0/broker.xml b/examples/features/standard/static-selector/src/main/resources/activemq/server0/broker.xml index fa99879..b6bda09 100644 --- a/examples/features/standard/static-selector/src/main/resources/activemq/server0/broker.xml +++ b/examples/features/standard/static-selector/src/main/resources/activemq/server0/broker.xml @@ -16,10 +16,8 @@ software distributed under the License is distributed on an KIND, either express or implied. See the License for the specific language governing permissions and limitations under the License. ---><configuration xmlns="urn:activemq" xmlns:xsi="http://www.w3.org/2001/XMLSchema-instance" xsi:schemaLocation="urn:activemq /schema/artemis-server.xsd"> - - <core xmlns="urn:activemq:core"> - +--> +<configuration xmlns="urn:activemq" xmlns:xsi="http://www.w3.org/2001/XMLSchema-instance" xsi:schemaLocation="urn:activemq /schema/artemis-configuration.xsd"> <bindings-directory>./data/messaging/bindings</bindings-directory> <journal-directory>./data/messaging/journal</journal-directory> @@ -49,7 +47,7 @@ under the License. </security-setting> </security-settings> - <addresses> + <addresses> <address name="exampleQueue"> <multicast> <queue name="exampleQueue"> http://git-wip-us.apache.org/repos/asf/activemq-artemis/blob/b77cdaf7/examples/features/standard/temp-queue/pom.xml ---------------------------------------------------------------------- diff --git a/examples/features/standard/temp-queue/pom.xml b/examples/features/standard/temp-queue/pom.xml index eb89b02..729f6d7 100644 --- a/examples/features/standard/temp-queue/pom.xml +++ b/examples/features/standard/temp-queue/pom.xml @@ -102,7 +102,23 @@ under the License. </dependency> </dependencies> </plugin> + <plugin> + <groupId>org.apache.maven.plugins</groupId> + <artifactId>maven-clean-plugin</artifactId> + </plugin> </plugins> </build> - + <profiles> + <profile> + <id>release</id> + <build> + <plugins> + <plugin> + <groupId>com.vladsch.flexmark</groupId> + <artifactId>markdown-page-generator-plugin</artifactId> + </plugin> + </plugins> + </build> + </profile> + </profiles> </project> http://git-wip-us.apache.org/repos/asf/activemq-artemis/blob/b77cdaf7/examples/features/standard/temp-queue/readme.html ---------------------------------------------------------------------- diff --git a/examples/features/standard/temp-queue/readme.html b/examples/features/standard/temp-queue/readme.html deleted file mode 100644 index 4b4d5c8..0000000 --- a/examples/features/standard/temp-queue/readme.html +++ /dev/null @@ -1,40 +0,0 @@ -<!-- -Licensed to the Apache Software Foundation (ASF) under one -or more contributor license agreements. See the NOTICE file -distributed with this work for additional information -regarding copyright ownership. The ASF licenses this file -to you under the Apache License, Version 2.0 (the -"License"); you may not use this file except in compliance -with the License. You may obtain a copy of the License at - - http://www.apache.org/licenses/LICENSE-2.0 - -Unless required by applicable law or agreed to in writing, -software distributed under the License is distributed on an -"AS IS" BASIS, WITHOUT WARRANTIES OR CONDITIONS OF ANY -KIND, either express or implied. See the License for the -specific language governing permissions and limitations -under the License. ---> - -<html> - <head> - <title>ActiveMQ Artemis JMS Temporary Queue Example</title> - <link rel="stylesheet" type="text/css" href="../../../common/common.css" /> - <link rel="stylesheet" type="text/css" href="../../../common/prettify.css" /> - <script type="text/javascript" src="../../../common/prettify.js"></script> - </head> - <body onload="prettyPrint()"> - <h1>JMS Temporary Queue Example</h1> - - <pre>To run the example, simply type <b>mvn verify</b> from this directory, <br>or <b>mvn -PnoServer verify</b> if you want to start and create the server manually.</pre> - - - <p>This example shows you how to use a TemporaryQueue with ActiveMQ Artemis. First a temporary queue is created to send and receive a message and then deleted. - Then another temporary queue is created and used after its connection is closed to illustrate its scope.</p> - <p>A TemporaryQueue is a JMS queue that exists only within the lifetime of its connection. It is often used in request-reply - type messaging where the reply is sent through a temporary destination. The temporary queue is often created as - a server resource, so after using, the user should call delete() method to release the resources. - Please consult the JMS 1.1 specification for full details.</p> - </body> -</html> http://git-wip-us.apache.org/repos/asf/activemq-artemis/blob/b77cdaf7/examples/features/standard/temp-queue/readme.md ---------------------------------------------------------------------- diff --git a/examples/features/standard/temp-queue/readme.md b/examples/features/standard/temp-queue/readme.md new file mode 100644 index 0000000..8f06354 --- /dev/null +++ b/examples/features/standard/temp-queue/readme.md @@ -0,0 +1,7 @@ +# JMS Temporary Queue Example + +To run the example, simply type **mvn verify** from this directory, or **mvn -PnoServer verify** if you want to start and create the broker manually. + +This example shows you how to use a TemporaryQueue with ActiveMQ Artemis. First a temporary queue is created to send and receive a message and then deleted. Then another temporary queue is created and used after its connection is closed to illustrate its scope. + +A TemporaryQueue is a JMS queue that exists only within the lifetime of its connection. It is often used in request-reply type messaging where the reply is sent through a temporary destination. The temporary queue is often created as a broker resource, so after using, the user should call delete() method to release the resources. Please consult the JMS 1.1 specification for full details. \ No newline at end of file http://git-wip-us.apache.org/repos/asf/activemq-artemis/blob/b77cdaf7/examples/features/standard/temp-queue/src/main/resources/activemq/server0/broker.xml ---------------------------------------------------------------------- diff --git a/examples/features/standard/temp-queue/src/main/resources/activemq/server0/broker.xml b/examples/features/standard/temp-queue/src/main/resources/activemq/server0/broker.xml index bd62a0e..a987728 100644 --- a/examples/features/standard/temp-queue/src/main/resources/activemq/server0/broker.xml +++ b/examples/features/standard/temp-queue/src/main/resources/activemq/server0/broker.xml @@ -16,10 +16,8 @@ software distributed under the License is distributed on an KIND, either express or implied. See the License for the specific language governing permissions and limitations under the License. ---><configuration xmlns="urn:activemq" xmlns:xsi="http://www.w3.org/2001/XMLSchema-instance" xsi:schemaLocation="urn:activemq /schema/artemis-server.xsd"> - - - +--> +<configuration xmlns="urn:activemq" xmlns:xsi="http://www.w3.org/2001/XMLSchema-instance" xsi:schemaLocation="urn:activemq /schema/artemis-configuration.xsd"> <core xmlns="urn:activemq:core"> <bindings-directory>./data/bindings</bindings-directory> @@ -54,7 +52,7 @@ under the License. <permission roles="guest" type="send"/> </security-setting> </security-settings> - <addresses> + <addresses> <address name="exampleQueue"> <anycast> <queue name="jms.queue.exampleQueue"/> http://git-wip-us.apache.org/repos/asf/activemq-artemis/blob/b77cdaf7/examples/features/standard/topic-hierarchies/pom.xml ---------------------------------------------------------------------- diff --git a/examples/features/standard/topic-hierarchies/pom.xml b/examples/features/standard/topic-hierarchies/pom.xml index e02a86c..61ffb4b 100644 --- a/examples/features/standard/topic-hierarchies/pom.xml +++ b/examples/features/standard/topic-hierarchies/pom.xml @@ -106,7 +106,23 @@ under the License. </dependency> </dependencies> </plugin> + <plugin> + <groupId>org.apache.maven.plugins</groupId> + <artifactId>maven-clean-plugin</artifactId> + </plugin> </plugins> </build> - -</project> + <profiles> + <profile> + <id>release</id> + <build> + <plugins> + <plugin> + <groupId>com.vladsch.flexmark</groupId> + <artifactId>markdown-page-generator-plugin</artifactId> + </plugin> + </plugins> + </build> + </profile> + </profiles> +</project> \ No newline at end of file http://git-wip-us.apache.org/repos/asf/activemq-artemis/blob/b77cdaf7/examples/features/standard/topic-hierarchies/readme.html ---------------------------------------------------------------------- diff --git a/examples/features/standard/topic-hierarchies/readme.html b/examples/features/standard/topic-hierarchies/readme.html deleted file mode 100644 index 0aa16ca..0000000 --- a/examples/features/standard/topic-hierarchies/readme.html +++ /dev/null @@ -1,42 +0,0 @@ -<!-- -Licensed to the Apache Software Foundation (ASF) under one -or more contributor license agreements. See the NOTICE file -distributed with this work for additional information -regarding copyright ownership. The ASF licenses this file -to you under the Apache License, Version 2.0 (the -"License"); you may not use this file except in compliance -with the License. You may obtain a copy of the License at - - http://www.apache.org/licenses/LICENSE-2.0 - -Unless required by applicable law or agreed to in writing, -software distributed under the License is distributed on an -"AS IS" BASIS, WITHOUT WARRANTIES OR CONDITIONS OF ANY -KIND, either express or implied. See the License for the -specific language governing permissions and limitations -under the License. ---> - -<html> - <head> - <title>ActiveMQ Artemis Topic Hierarchy Example</title> - <link rel="stylesheet" type="text/css" href="../../../common/common.css" /> - <link rel="stylesheet" type="text/css" href="../../../common/prettify.css" /> - <script type="text/javascript" src="../../../common/prettify.js"></script> - </head> - <body onload="prettyPrint()"> - <h1>Topic Hierarchy Example</h1> - - <pre>To run the example, simply type <b>mvn verify</b> from this directory, <br>or <b>mvn -PnoServer verify</b> if you want to start and create the server manually.</pre> - - - <p>ActiveMQ Artemis supports topic hierarchies. With a topic hierarchy you can register a subscriber with a wild-card - and that subscriber will receive any messages routed to an address that match the wildcard.</p> - <p>ActiveMQ Artemis wild-cards can use the character '#' which means "match any number of words", and - the character '*' which means "match a single word". Words are delimited by the character "."</p> - <p>For example if I subscribe using the wild-card "news.europe.#", then that would match messages sent to the addresses - "news.europe", "news.europe.sport" and "news.europe.entertainment", but it does not match messages sent to the - address "news.usa.wrestling"</p> - <p>For more information on the wild-card syntax please consult the user manual.</p> - </body> -</html> http://git-wip-us.apache.org/repos/asf/activemq-artemis/blob/b77cdaf7/examples/features/standard/topic-hierarchies/readme.md ---------------------------------------------------------------------- diff --git a/examples/features/standard/topic-hierarchies/readme.md b/examples/features/standard/topic-hierarchies/readme.md new file mode 100644 index 0000000..2f70bc7 --- /dev/null +++ b/examples/features/standard/topic-hierarchies/readme.md @@ -0,0 +1,11 @@ +# Topic Hierarchy Example + +To run the example, simply type **mvn verify** from this directory, or **mvn -PnoServer verify** if you want to start and create the broker manually. + +ActiveMQ Artemis supports topic hierarchies. With a topic hierarchy you can register a subscriber with a wild-card and that subscriber will receive any messages routed to an address that match the wildcard. + +ActiveMQ Artemis wild-cards can use the character `#` which means "match any number of words", and the character `*` which means "match a single word". Words are delimited by the character `.`. + +For example if I subscribe using the wild-card `news.europe.#`, then that would match messages sent to the addresses `news.europe`, `news.europe.sport` and `news.europe.entertainment`, but it does not match messages sent to the address `news.usa.wrestling`. + +For more information on the wild-card syntax please consult the user manual. \ No newline at end of file http://git-wip-us.apache.org/repos/asf/activemq-artemis/blob/b77cdaf7/examples/features/standard/topic-hierarchies/src/main/java/org/apache/activemq/artemis/jms/example/TopicHierarchyExample.java ---------------------------------------------------------------------- diff --git a/examples/features/standard/topic-hierarchies/src/main/java/org/apache/activemq/artemis/jms/example/TopicHierarchyExample.java b/examples/features/standard/topic-hierarchies/src/main/java/org/apache/activemq/artemis/jms/example/TopicHierarchyExample.java index 41bda55..e5fadf3 100644 --- a/examples/features/standard/topic-hierarchies/src/main/java/org/apache/activemq/artemis/jms/example/TopicHierarchyExample.java +++ b/examples/features/standard/topic-hierarchies/src/main/java/org/apache/activemq/artemis/jms/example/TopicHierarchyExample.java @@ -31,7 +31,7 @@ import org.apache.activemq.artemis.jms.client.ActiveMQConnectionFactory; /** * This example demonstrates how a JMS TopicSubscriber can be created to subscribe to a wild-card Topic. * - * For more information please see the readme.html + * For more information please see the readme */ public class TopicHierarchyExample { http://git-wip-us.apache.org/repos/asf/activemq-artemis/blob/b77cdaf7/examples/features/standard/topic-selector-example1/pom.xml ---------------------------------------------------------------------- diff --git a/examples/features/standard/topic-selector-example1/pom.xml b/examples/features/standard/topic-selector-example1/pom.xml index 232b152..4384afa 100644 --- a/examples/features/standard/topic-selector-example1/pom.xml +++ b/examples/features/standard/topic-selector-example1/pom.xml @@ -102,7 +102,23 @@ under the License. </dependency> </dependencies> </plugin> + <plugin> + <groupId>org.apache.maven.plugins</groupId> + <artifactId>maven-clean-plugin</artifactId> + </plugin> </plugins> </build> - -</project> + <profiles> + <profile> + <id>release</id> + <build> + <plugins> + <plugin> + <groupId>com.vladsch.flexmark</groupId> + <artifactId>markdown-page-generator-plugin</artifactId> + </plugin> + </plugins> + </build> + </profile> + </profiles> +</project> \ No newline at end of file http://git-wip-us.apache.org/repos/asf/activemq-artemis/blob/b77cdaf7/examples/features/standard/topic-selector-example1/readme.html ---------------------------------------------------------------------- diff --git a/examples/features/standard/topic-selector-example1/readme.html b/examples/features/standard/topic-selector-example1/readme.html deleted file mode 100644 index f03f4f5..0000000 --- a/examples/features/standard/topic-selector-example1/readme.html +++ /dev/null @@ -1,38 +0,0 @@ -<!-- -Licensed to the Apache Software Foundation (ASF) under one -or more contributor license agreements. See the NOTICE file -distributed with this work for additional information -regarding copyright ownership. The ASF licenses this file -to you under the Apache License, Version 2.0 (the -"License"); you may not use this file except in compliance -with the License. You may obtain a copy of the License at - - http://www.apache.org/licenses/LICENSE-2.0 - -Unless required by applicable law or agreed to in writing, -software distributed under the License is distributed on an -"AS IS" BASIS, WITHOUT WARRANTIES OR CONDITIONS OF ANY -KIND, either express or implied. See the License for the -specific language governing permissions and limitations -under the License. ---> - -<html> - <head> - <title>ActiveMQ Artemis JMS Topic Selector Example 1</title> - <link rel="stylesheet" type="text/css" href="../../../common/common.css" /> - <link rel="stylesheet" type="text/css" href="../../../common/prettify.css" /> - <script type="text/javascript" src="../../../common/prettify.js"></script> - </head> - <body onload="prettyPrint()"> - <h1>JMS Topic Selector Example 1</h1> - - <pre>To run the example, simply type <b>mvn verify</b> from this directory, <br>or <b>mvn -PnoServer verify</b> if you want to start and create the server manually.</pre> - - - <p>This example shows how messages can be consumed from a topic using Message Selectors.</p> - <p>Consumers (or Subscribers) will only consume messages routed to a topic that match the provided selector</p> - <p>Topics and selectors are a standard part of JMS, please consult the JMS 1.1 specification for full details.</p> - - </body> -</html> http://git-wip-us.apache.org/repos/asf/activemq-artemis/blob/b77cdaf7/examples/features/standard/topic-selector-example1/readme.md ---------------------------------------------------------------------- diff --git a/examples/features/standard/topic-selector-example1/readme.md b/examples/features/standard/topic-selector-example1/readme.md new file mode 100644 index 0000000..b0a5559 --- /dev/null +++ b/examples/features/standard/topic-selector-example1/readme.md @@ -0,0 +1,9 @@ +# JMS Topic Selector Example 1 + +To run the example, simply type **mvn verify** from this directory, or **mvn -PnoServer verify** if you want to start and create the broker manually. + +This example shows how messages can be consumed from a topic using Message Selectors. + +Consumers (or Subscribers) will only consume messages routed to a topic that match the provided selector + +Topics and selectors are a standard part of JMS, please consult the JMS 1.1 specification for full details. \ No newline at end of file http://git-wip-us.apache.org/repos/asf/activemq-artemis/blob/b77cdaf7/examples/features/standard/topic-selector-example1/src/main/resources/activemq/server0/broker.xml ---------------------------------------------------------------------- diff --git a/examples/features/standard/topic-selector-example1/src/main/resources/activemq/server0/broker.xml b/examples/features/standard/topic-selector-example1/src/main/resources/activemq/server0/broker.xml index 85c6a0b..42c38cb 100644 --- a/examples/features/standard/topic-selector-example1/src/main/resources/activemq/server0/broker.xml +++ b/examples/features/standard/topic-selector-example1/src/main/resources/activemq/server0/broker.xml @@ -16,10 +16,8 @@ software distributed under the License is distributed on an KIND, either express or implied. See the License for the specific language governing permissions and limitations under the License. ---><configuration xmlns="urn:activemq" xmlns:xsi="http://www.w3.org/2001/XMLSchema-instance" xsi:schemaLocation="urn:activemq /schema/artemis-server.xsd"> - - - +--> +<configuration xmlns="urn:activemq" xmlns:xsi="http://www.w3.org/2001/XMLSchema-instance" xsi:schemaLocation="urn:activemq /schema/artemis-configuration.xsd"> <core xmlns="urn:activemq:core"> <bindings-directory>./data/bindings</bindings-directory> @@ -49,7 +47,7 @@ under the License. </security-setting> </security-settings> - <addresses> + <addresses> <address name="exampleTopic"> <multicast/> </address> http://git-wip-us.apache.org/repos/asf/activemq-artemis/blob/b77cdaf7/examples/features/standard/topic-selector-example2/pom.xml ---------------------------------------------------------------------- diff --git a/examples/features/standard/topic-selector-example2/pom.xml b/examples/features/standard/topic-selector-example2/pom.xml index f70d59f..7a9fccd 100644 --- a/examples/features/standard/topic-selector-example2/pom.xml +++ b/examples/features/standard/topic-selector-example2/pom.xml @@ -102,7 +102,23 @@ under the License. </dependency> </dependencies> </plugin> + <plugin> + <groupId>org.apache.maven.plugins</groupId> + <artifactId>maven-clean-plugin</artifactId> + </plugin> </plugins> </build> - -</project> + <profiles> + <profile> + <id>release</id> + <build> + <plugins> + <plugin> + <groupId>com.vladsch.flexmark</groupId> + <artifactId>markdown-page-generator-plugin</artifactId> + </plugin> + </plugins> + </build> + </profile> + </profiles> +</project> \ No newline at end of file http://git-wip-us.apache.org/repos/asf/activemq-artemis/blob/b77cdaf7/examples/features/standard/topic-selector-example2/readme.html ---------------------------------------------------------------------- diff --git a/examples/features/standard/topic-selector-example2/readme.html b/examples/features/standard/topic-selector-example2/readme.html deleted file mode 100644 index 608e3d8..0000000 --- a/examples/features/standard/topic-selector-example2/readme.html +++ /dev/null @@ -1,47 +0,0 @@ -<!-- -Licensed to the Apache Software Foundation (ASF) under one -or more contributor license agreements. See the NOTICE file -distributed with this work for additional information -regarding copyright ownership. The ASF licenses this file -to you under the Apache License, Version 2.0 (the -"License"); you may not use this file except in compliance -with the License. You may obtain a copy of the License at - - http://www.apache.org/licenses/LICENSE-2.0 - -Unless required by applicable law or agreed to in writing, -software distributed under the License is distributed on an -"AS IS" BASIS, WITHOUT WARRANTIES OR CONDITIONS OF ANY -KIND, either express or implied. See the License for the -specific language governing permissions and limitations -under the License. ---> - -<html> - <head> - <title>ActiveMQ Artemis JMS Topic Selector Example 2</title> - <link rel="stylesheet" type="text/css" href="../../../common/common.css" /> - <link rel="stylesheet" type="text/css" href="../../../common/prettify.css" /> - <script type="text/javascript" src="../../../common/prettify.js"></script> - </head> - <body onload="prettyPrint()"> - <h1>JMS Topic Selector Example 2</h1> - - <pre>To run the example, simply type <b>mvn verify</b> from this directory, <br>or <b>mvn -PnoServer verify</b> if you want to start and create the server manually.</pre> - - - <p>This example shows you how to selectively consume messages using message selectors with topic consumers.</p> - - <p>Message selectors are strings with special syntax that can be used in creating consumers. Message consumers - that are thus created only receive messages that match its selector. On message delivering, the ActiveMQ - Server evaluates the corresponding message headers of the messages against each selector, if any, and then delivers - the 'matched' messages to its consumer. Please consult the JMS 1.1 specification for full details.</p> - - <p>In this example, three message consumers are created on a topic. The first consumer is created with selector - <code>'color=red'</code>, it only receives messages that - have a 'color' string property of 'red' value; the second is created with selector <code>'color=green'</code>, it - only receives messages who have a 'color' string property of - 'green' value; and the third without a selector, which means it receives all messages. To illustrate, three messages - with different 'color' property values are created and sent.</p> - </body> -</html> http://git-wip-us.apache.org/repos/asf/activemq-artemis/blob/b77cdaf7/examples/features/standard/topic-selector-example2/readme.md ---------------------------------------------------------------------- diff --git a/examples/features/standard/topic-selector-example2/readme.md b/examples/features/standard/topic-selector-example2/readme.md new file mode 100644 index 0000000..01b7e6a --- /dev/null +++ b/examples/features/standard/topic-selector-example2/readme.md @@ -0,0 +1,9 @@ +# JMS Topic Selector Example 2 + +To run the example, simply type **mvn verify** from this directory, or **mvn -PnoServer verify** if you want to start and create the broker manually. + +This example shows you how to selectively consume messages using message selectors with topic consumers. + +Message selectors are strings with special syntax that can be used in creating consumers. Message consumers that are thus created only receive messages that match its selector. On message delivering, the ActiveMQ Server evaluates the corresponding message headers of the messages against each selector, if any, and then delivers the 'matched' messages to its consumer. Please consult the JMS 1.1 specification for full details. + +In this example, three message consumers are created on a topic. The first consumer is created with selector `'color=red'`, it only receives messages that have a 'color' string property of 'red' value; the second is created with selector `'color=green'`, it only receives messages who have a 'color' string property of 'green' value; and the third without a selector, which means it receives all messages. To illustrate, three messages with different 'color' property values are created and sent. \ No newline at end of file http://git-wip-us.apache.org/repos/asf/activemq-artemis/blob/b77cdaf7/examples/features/standard/topic-selector-example2/src/main/resources/activemq/server0/broker.xml ---------------------------------------------------------------------- diff --git a/examples/features/standard/topic-selector-example2/src/main/resources/activemq/server0/broker.xml b/examples/features/standard/topic-selector-example2/src/main/resources/activemq/server0/broker.xml index 85c6a0b..42c38cb 100644 --- a/examples/features/standard/topic-selector-example2/src/main/resources/activemq/server0/broker.xml +++ b/examples/features/standard/topic-selector-example2/src/main/resources/activemq/server0/broker.xml @@ -16,10 +16,8 @@ software distributed under the License is distributed on an KIND, either express or implied. See the License for the specific language governing permissions and limitations under the License. ---><configuration xmlns="urn:activemq" xmlns:xsi="http://www.w3.org/2001/XMLSchema-instance" xsi:schemaLocation="urn:activemq /schema/artemis-server.xsd"> - - - +--> +<configuration xmlns="urn:activemq" xmlns:xsi="http://www.w3.org/2001/XMLSchema-instance" xsi:schemaLocation="urn:activemq /schema/artemis-configuration.xsd"> <core xmlns="urn:activemq:core"> <bindings-directory>./data/bindings</bindings-directory> @@ -49,7 +47,7 @@ under the License. </security-setting> </security-settings> - <addresses> + <addresses> <address name="exampleTopic"> <multicast/> </address> http://git-wip-us.apache.org/repos/asf/activemq-artemis/blob/b77cdaf7/examples/features/standard/topic/pom.xml ---------------------------------------------------------------------- diff --git a/examples/features/standard/topic/pom.xml b/examples/features/standard/topic/pom.xml index 103a8ea..d39b737 100644 --- a/examples/features/standard/topic/pom.xml +++ b/examples/features/standard/topic/pom.xml @@ -102,6 +102,23 @@ under the License. </dependency> </dependencies> </plugin> + <plugin> + <groupId>org.apache.maven.plugins</groupId> + <artifactId>maven-clean-plugin</artifactId> + </plugin> </plugins> </build> -</project> + <profiles> + <profile> + <id>release</id> + <build> + <plugins> + <plugin> + <groupId>com.vladsch.flexmark</groupId> + <artifactId>markdown-page-generator-plugin</artifactId> + </plugin> + </plugins> + </build> + </profile> + </profiles> +</project> \ No newline at end of file http://git-wip-us.apache.org/repos/asf/activemq-artemis/blob/b77cdaf7/examples/features/standard/topic/readme.html ---------------------------------------------------------------------- diff --git a/examples/features/standard/topic/readme.html b/examples/features/standard/topic/readme.html deleted file mode 100644 index 8bfa903..0000000 --- a/examples/features/standard/topic/readme.html +++ /dev/null @@ -1,36 +0,0 @@ -<!-- -Licensed to the Apache Software Foundation (ASF) under one -or more contributor license agreements. See the NOTICE file -distributed with this work for additional information -regarding copyright ownership. The ASF licenses this file -to you under the Apache License, Version 2.0 (the -"License"); you may not use this file except in compliance -with the License. You may obtain a copy of the License at - - http://www.apache.org/licenses/LICENSE-2.0 - -Unless required by applicable law or agreed to in writing, -software distributed under the License is distributed on an -"AS IS" BASIS, WITHOUT WARRANTIES OR CONDITIONS OF ANY -KIND, either express or implied. See the License for the -specific language governing permissions and limitations -under the License. ---> - -<html> - <head> - <title>ActiveMQ Artemis JMS Topic Example</title> - <link rel="stylesheet" type="text/css" href="../../../common/common.css" /> - <link rel="stylesheet" type="text/css" href="../../../common/prettify.css" /> - <script type="text/javascript" src="../../../common/prettify.js"></script> - </head> - <body onload="prettyPrint()"> - <h1>JMS Topic Example</h1> - - <pre>To run the example, simply type <b>mvn verify</b> from this directory, <br>or <b>mvn -PnoServer verify</b> if you want to start and create the server manually.</pre> - - <p>This example shows you how to send and receive a message to a JMS Topic with ActiveMQ Artemis.</p> - <p>Topics are a standard part of JMS, please consult the JMS 1.1 specification for full details.</p> - <p>A Topic is used to send messages using the publish-subscribe model, from a producer to 1 or more consumers.</p> - </body> -</html> http://git-wip-us.apache.org/repos/asf/activemq-artemis/blob/b77cdaf7/examples/features/standard/topic/readme.md ---------------------------------------------------------------------- diff --git a/examples/features/standard/topic/readme.md b/examples/features/standard/topic/readme.md new file mode 100644 index 0000000..ecdb65f --- /dev/null +++ b/examples/features/standard/topic/readme.md @@ -0,0 +1,9 @@ +# JMS Topic Example + +To run the example, simply type **mvn verify** from this directory, or **mvn -PnoServer verify** if you want to start and create the broker manually. + +This example shows you how to send and receive a message to a JMS Topic with ActiveMQ Artemis. + +Topics are a standard part of JMS, please consult the JMS 1.1 specification for full details. + +A Topic is used to send messages using the publish-subscribe model, from a producer to 1 or more consumers. \ No newline at end of file http://git-wip-us.apache.org/repos/asf/activemq-artemis/blob/b77cdaf7/examples/features/standard/topic/src/main/resources/activemq/server0/broker.xml ---------------------------------------------------------------------- diff --git a/examples/features/standard/topic/src/main/resources/activemq/server0/broker.xml b/examples/features/standard/topic/src/main/resources/activemq/server0/broker.xml index 10d3280..cc1be04 100644 --- a/examples/features/standard/topic/src/main/resources/activemq/server0/broker.xml +++ b/examples/features/standard/topic/src/main/resources/activemq/server0/broker.xml @@ -16,10 +16,8 @@ software distributed under the License is distributed on an KIND, either express or implied. See the License for the specific language governing permissions and limitations under the License. ---><configuration xmlns="urn:activemq" xmlns:xsi="http://www.w3.org/2001/XMLSchema-instance" xsi:schemaLocation="urn:activemq /schema/artemis-server.xsd"> - - - +--> +<configuration xmlns="urn:activemq" xmlns:xsi="http://www.w3.org/2001/XMLSchema-instance" xsi:schemaLocation="urn:activemq /schema/artemis-configuration.xsd"> <core xmlns="urn:activemq:core"> <bindings-directory>./data/bindings</bindings-directory> @@ -50,7 +48,7 @@ under the License. </security-setting> </security-settings> - <addresses> + <addresses> <address name="exampleTopic"> <multicast/> </address> http://git-wip-us.apache.org/repos/asf/activemq-artemis/blob/b77cdaf7/examples/features/standard/transactional/pom.xml ---------------------------------------------------------------------- diff --git a/examples/features/standard/transactional/pom.xml b/examples/features/standard/transactional/pom.xml index 22d7415..867c395 100644 --- a/examples/features/standard/transactional/pom.xml +++ b/examples/features/standard/transactional/pom.xml @@ -102,7 +102,23 @@ under the License. </dependency> </dependencies> </plugin> + <plugin> + <groupId>org.apache.maven.plugins</groupId> + <artifactId>maven-clean-plugin</artifactId> + </plugin> </plugins> </build> - -</project> + <profiles> + <profile> + <id>release</id> + <build> + <plugins> + <plugin> + <groupId>com.vladsch.flexmark</groupId> + <artifactId>markdown-page-generator-plugin</artifactId> + </plugin> + </plugins> + </build> + </profile> + </profiles> +</project> \ No newline at end of file http://git-wip-us.apache.org/repos/asf/activemq-artemis/blob/b77cdaf7/examples/features/standard/transactional/readme.html ---------------------------------------------------------------------- diff --git a/examples/features/standard/transactional/readme.html b/examples/features/standard/transactional/readme.html deleted file mode 100644 index b171c0a..0000000 --- a/examples/features/standard/transactional/readme.html +++ /dev/null @@ -1,40 +0,0 @@ -<!-- -Licensed to the Apache Software Foundation (ASF) under one -or more contributor license agreements. See the NOTICE file -distributed with this work for additional information -regarding copyright ownership. The ASF licenses this file -to you under the Apache License, Version 2.0 (the -"License"); you may not use this file except in compliance -with the License. You may obtain a copy of the License at - - http://www.apache.org/licenses/LICENSE-2.0 - -Unless required by applicable law or agreed to in writing, -software distributed under the License is distributed on an -"AS IS" BASIS, WITHOUT WARRANTIES OR CONDITIONS OF ANY -KIND, either express or implied. See the License for the -specific language governing permissions and limitations -under the License. ---> - -<html> - <head> - <title>ActiveMQ Artemis JMS Transactional Session Example</title> - <link rel="stylesheet" type="text/css" href="../../../common/common.css" /> - <link rel="stylesheet" type="text/css" href="../../../common/prettify.css" /> - <script type="text/javascript" src="../../../common/prettify.js"></script> - </head> - <body onload="prettyPrint()"> - <h1>JMS Transactional Session Example</h1> - - <pre>To run the example, simply type <b>mvn verify</b> from this directory, <br>or <b>mvn -PnoServer verify</b> if you want to start and create the server manually.</pre> - - - <p>This example shows you how to use a transacted Session with ActiveMQ Artemis.</p> - <p>Firstly 2 messages are sent via the transacted sending session before being committed. This ensures that both message - are sent</p> - <p>Secondly the receiving session receives the messages firstly demonstrating a message being redelivered after the session - being rolled back and then acknowledging receipt of the messages via the commit method.</p> - - </body> -</html> http://git-wip-us.apache.org/repos/asf/activemq-artemis/blob/b77cdaf7/examples/features/standard/transactional/readme.md ---------------------------------------------------------------------- diff --git a/examples/features/standard/transactional/readme.md b/examples/features/standard/transactional/readme.md new file mode 100644 index 0000000..a256f3f --- /dev/null +++ b/examples/features/standard/transactional/readme.md @@ -0,0 +1,9 @@ +# JMS Transactional Session Example + +To run the example, simply type **mvn verify** from this directory, or **mvn -PnoServer verify** if you want to start and create the broker manually. + +This example shows you how to use a transacted Session with ActiveMQ Artemis. + +Firstly 2 messages are sent via the transacted sending session before being committed. This ensures that both message are sent + +Secondly the receiving session receives the messages firstly demonstrating a message being redelivered after the session being rolled back and then acknowledging receipt of the messages via the commit method. \ No newline at end of file http://git-wip-us.apache.org/repos/asf/activemq-artemis/blob/b77cdaf7/examples/features/standard/xa-heuristic/pom.xml ---------------------------------------------------------------------- diff --git a/examples/features/standard/xa-heuristic/pom.xml b/examples/features/standard/xa-heuristic/pom.xml index 661a693..a28a0f5 100644 --- a/examples/features/standard/xa-heuristic/pom.xml +++ b/examples/features/standard/xa-heuristic/pom.xml @@ -104,7 +104,23 @@ under the License. </dependency> </dependencies> </plugin> + <plugin> + <groupId>org.apache.maven.plugins</groupId> + <artifactId>maven-clean-plugin</artifactId> + </plugin> </plugins> </build> - -</project> + <profiles> + <profile> + <id>release</id> + <build> + <plugins> + <plugin> + <groupId>com.vladsch.flexmark</groupId> + <artifactId>markdown-page-generator-plugin</artifactId> + </plugin> + </plugins> + </build> + </profile> + </profiles> +</project> \ No newline at end of file http://git-wip-us.apache.org/repos/asf/activemq-artemis/blob/b77cdaf7/examples/features/standard/xa-heuristic/readme.html ---------------------------------------------------------------------- diff --git a/examples/features/standard/xa-heuristic/readme.html b/examples/features/standard/xa-heuristic/readme.html deleted file mode 100644 index bf44937..0000000 --- a/examples/features/standard/xa-heuristic/readme.html +++ /dev/null @@ -1,48 +0,0 @@ -<!-- -Licensed to the Apache Software Foundation (ASF) under one -or more contributor license agreements. See the NOTICE file -distributed with this work for additional information -regarding copyright ownership. The ASF licenses this file -to you under the Apache License, Version 2.0 (the -"License"); you may not use this file except in compliance -with the License. You may obtain a copy of the License at - - http://www.apache.org/licenses/LICENSE-2.0 - -Unless required by applicable law or agreed to in writing, -software distributed under the License is distributed on an -"AS IS" BASIS, WITHOUT WARRANTIES OR CONDITIONS OF ANY -KIND, either express or implied. See the License for the -specific language governing permissions and limitations -under the License. ---> - -<html> - <head> - <title>ActiveMQ Artemis JMS XA Heuristic Example</title> - <link rel="stylesheet" type="text/css" href="../../../common/common.css" /> - <link rel="stylesheet" type="text/css" href="../../../common/prettify.css" /> - <script type="text/javascript" src="../../../common/prettify.js"></script> - </head> - <body onload="prettyPrint()"> - <h1>JMS XA Heuristic Example</h1> - - <pre>To run the example, simply type <b>mvn verify</b> from this directory, <br>or <b>mvn -PnoServer verify</b> if you want to start and create the server manually.</pre> - - <p>This example shows you how to make an XA heuristic decision through the ActiveMQ Artemis Management Interface.</p> - - <p>A heuristic decision is a unilateral decision to commit or rollback an XA transaction branch after it has - been prepared. </p> - - <p>In this example we simulate a transaction manager to control the transactions. First we create an XASession - and enlist it in a transaction through its XAResource. We then send a text message, 'hello' and end/prepare the transaction - on the XAResource, but neither commit nor roll back the transaction. Another transaction is created and - associated with the same XAResource, and a second message, 'world' is sent on behalf of the second transaction. Again we leave - the second transaction in prepare state. - Then we get the MBeanServerConnection object to manipulate the prepared transactions. To illustrate, we roll back the first - transaction but commit the second. This will result in that only the message 'world' is received. </p> - - <p>This example uses JMX to manipulate transactions in a ActiveMQ Artemis Server. For details on JMX facilities with ActiveMQ Artemis, - please look at the JMX Example.</p> - </body> -</html> http://git-wip-us.apache.org/repos/asf/activemq-artemis/blob/b77cdaf7/examples/features/standard/xa-heuristic/readme.md ---------------------------------------------------------------------- diff --git a/examples/features/standard/xa-heuristic/readme.md b/examples/features/standard/xa-heuristic/readme.md new file mode 100644 index 0000000..1b91133 --- /dev/null +++ b/examples/features/standard/xa-heuristic/readme.md @@ -0,0 +1,11 @@ +# JMS XA Heuristic Example + +To run the example, simply type **mvn verify** from this directory, or **mvn -PnoServer verify** if you want to start and create the broker manually. + +This example shows you how to make an XA heuristic decision through the ActiveMQ Artemis Management Interface. + +A heuristic decision is a unilateral decision to commit or rollback an XA transaction branch after it has been prepared. + +In this example we simulate a transaction manager to control the transactions. First we create an XASession and enlist it in a transaction through its XAResource. We then send a text message, 'hello' and end/prepare the transaction on the XAResource, but neither commit nor roll back the transaction. Another transaction is created and associated with the same XAResource, and a second message, 'world' is sent on behalf of the second transaction. Again we leave the second transaction in prepare state. Then we get the MBeanServerConnection object to manipulate the prepared transactions. To illustrate, we roll back the first transaction but commit the second. This will result in that only the message 'world' is received. + +This example uses JMX to manipulate transactions in a ActiveMQ Artemis Server. For details on JMX facilities with ActiveMQ Artemis, please look at the JMX Example. \ No newline at end of file http://git-wip-us.apache.org/repos/asf/activemq-artemis/blob/b77cdaf7/examples/features/standard/xa-receive/pom.xml ---------------------------------------------------------------------- diff --git a/examples/features/standard/xa-receive/pom.xml b/examples/features/standard/xa-receive/pom.xml index fedd2f7..457ff2a 100644 --- a/examples/features/standard/xa-receive/pom.xml +++ b/examples/features/standard/xa-receive/pom.xml @@ -102,7 +102,23 @@ under the License. </dependency> </dependencies> </plugin> + <plugin> + <groupId>org.apache.maven.plugins</groupId> + <artifactId>maven-clean-plugin</artifactId> + </plugin> </plugins> </build> - -</project> + <profiles> + <profile> + <id>release</id> + <build> + <plugins> + <plugin> + <groupId>com.vladsch.flexmark</groupId> + <artifactId>markdown-page-generator-plugin</artifactId> + </plugin> + </plugins> + </build> + </profile> + </profiles> +</project> \ No newline at end of file http://git-wip-us.apache.org/repos/asf/activemq-artemis/blob/b77cdaf7/examples/features/standard/xa-receive/readme.html ---------------------------------------------------------------------- diff --git a/examples/features/standard/xa-receive/readme.html b/examples/features/standard/xa-receive/readme.html deleted file mode 100644 index ab6d7d7..0000000 --- a/examples/features/standard/xa-receive/readme.html +++ /dev/null @@ -1,48 +0,0 @@ -<!-- -Licensed to the Apache Software Foundation (ASF) under one -or more contributor license agreements. See the NOTICE file -distributed with this work for additional information -regarding copyright ownership. The ASF licenses this file -to you under the Apache License, Version 2.0 (the -"License"); you may not use this file except in compliance -with the License. You may obtain a copy of the License at - - http://www.apache.org/licenses/LICENSE-2.0 - -Unless required by applicable law or agreed to in writing, -software distributed under the License is distributed on an -"AS IS" BASIS, WITHOUT WARRANTIES OR CONDITIONS OF ANY -KIND, either express or implied. See the License for the -specific language governing permissions and limitations -under the License. ---> - -<html> - <head> - <title>ActiveMQ Artemis JMS XA Receive Example</title> - <link rel="stylesheet" type="text/css" href="../../../common/common.css" /> - <link rel="stylesheet" type="text/css" href="../../../common/prettify.css" /> - <script type="text/javascript" src="../../../common/prettify.js"></script> - </head> - <body onload="prettyPrint()"> - <h1>JMS XA Receive Example</h1> - - <pre>To run the example, simply type <b>mvn verify</b> from this directory, <br>or <b>mvn -PnoServer verify</b> if you want to start and create the server manually.</pre> - - - <p>This example demonstrates receiving a message within the scope of an XA transaction. When using an XA transaction - the message will only be acknowledged and removed from the queue when the transaction is committed. - If the transaction is not committed the message maybe redelivered after rollback or during XA recovery.</p> - - <p>ActiveMQ Artemis is JTA aware, meaning you can use ActiveMQ Artemis in an XA transactional environment - and participate in XA transactions. It provides the javax.transaction.xa.XAResource interface for that - purpose. Users can get a XAConnectionFactory to create XAConnections and XASessions.</p> - - <p>In this example we simulate a transaction manager to control the transactions. First we create an XASession - for receiving and a normal session for sending. Then we start a new xa transaction and enlist the receiving - XASession through its XAResource. We then send two words, 'hello' and 'world', receive them, and let the - transaction roll back. The received messages are cancelled back to the queue. Next we start - a new transaction with the same XAResource enlisted, but this time we commit the transaction after receiving the - messages. Then we check that no more messages are to be received.</p> - </body> -</html> http://git-wip-us.apache.org/repos/asf/activemq-artemis/blob/b77cdaf7/examples/features/standard/xa-receive/readme.md ---------------------------------------------------------------------- diff --git a/examples/features/standard/xa-receive/readme.md b/examples/features/standard/xa-receive/readme.md new file mode 100644 index 0000000..5c41053 --- /dev/null +++ b/examples/features/standard/xa-receive/readme.md @@ -0,0 +1,9 @@ +# JMS XA Receive Example + +To run the example, simply type **mvn verify** from this directory, or **mvn -PnoServer verify** if you want to start and create the broker manually. + +This example demonstrates receiving a message within the scope of an XA transaction. When using an XA transaction the message will only be acknowledged and removed from the queue when the transaction is committed. If the transaction is not committed the message maybe redelivered after rollback or during XA recovery. + +ActiveMQ Artemis is JTA aware, meaning you can use ActiveMQ Artemis in an XA transactional environment and participate in XA transactions. It provides the javax.transaction.xa.XAResource interface for that purpose. Users can get a XAConnectionFactory to create XAConnections and XASessions. + +In this example we simulate a transaction manager to control the transactions. First we create an XASession for receiving and a normal session for sending. Then we start a new xa transaction and enlist the receiving XASession through its XAResource. We then send two words, 'hello' and 'world', receive them, and let the transaction roll back. The received messages are cancelled back to the queue. Next we start a new transaction with the same XAResource enlisted, but this time we commit the transaction after receiving the messages. Then we check that no more messages are to be received. \ No newline at end of file http://git-wip-us.apache.org/repos/asf/activemq-artemis/blob/b77cdaf7/examples/features/standard/xa-send/pom.xml ---------------------------------------------------------------------- diff --git a/examples/features/standard/xa-send/pom.xml b/examples/features/standard/xa-send/pom.xml index fac358c..a5a245f 100644 --- a/examples/features/standard/xa-send/pom.xml +++ b/examples/features/standard/xa-send/pom.xml @@ -102,7 +102,23 @@ under the License. </dependency> </dependencies> </plugin> + <plugin> + <groupId>org.apache.maven.plugins</groupId> + <artifactId>maven-clean-plugin</artifactId> + </plugin> </plugins> </build> - -</project> + <profiles> + <profile> + <id>release</id> + <build> + <plugins> + <plugin> + <groupId>com.vladsch.flexmark</groupId> + <artifactId>markdown-page-generator-plugin</artifactId> + </plugin> + </plugins> + </build> + </profile> + </profiles> +</project> \ No newline at end of file http://git-wip-us.apache.org/repos/asf/activemq-artemis/blob/b77cdaf7/examples/features/standard/xa-send/readme.html ---------------------------------------------------------------------- diff --git a/examples/features/standard/xa-send/readme.html b/examples/features/standard/xa-send/readme.html deleted file mode 100644 index fb3db4c..0000000 --- a/examples/features/standard/xa-send/readme.html +++ /dev/null @@ -1,215 +0,0 @@ -<!-- -Licensed to the Apache Software Foundation (ASF) under one -or more contributor license agreements. See the NOTICE file -distributed with this work for additional information -regarding copyright ownership. The ASF licenses this file -to you under the Apache License, Version 2.0 (the -"License"); you may not use this file except in compliance -with the License. You may obtain a copy of the License at - - http://www.apache.org/licenses/LICENSE-2.0 - -Unless required by applicable law or agreed to in writing, -software distributed under the License is distributed on an -"AS IS" BASIS, WITHOUT WARRANTIES OR CONDITIONS OF ANY -KIND, either express or implied. See the License for the -specific language governing permissions and limitations -under the License. ---> - -<html> - <head> - <title>ActiveMQ Artemis JMS XA Send Example</title> - <link rel="stylesheet" type="text/css" href="../../../common/common.css" /> - <link rel="stylesheet" type="text/css" href="../../../common/prettify.css" /> - <script type="text/javascript" src="../../../common/prettify.js"></script> - </head> - <body onload="prettyPrint()"> - <h1>JMS XA Send Example</h1> - <p>This example shows you how message sending behaves in an XA transaction in ActiveMQ Artemis. When a message is sent within - the scope of an XA transaction, it will only reach the queue once the transaction is committed. - If the transaction is rolled back the sent messages will be discarded by the server.</p> - - <p>ActiveMQ Artemis is JTA aware, meaning you can use ActiveMQ Artemis in a XA transactional environment - and participate in XA transactions. It provides the javax.transaction.xa.XAResource interface for that - purpose. Users can get a XAConnectionFactory to create XAConnections and XASessions.</p> - - <p>In this example we simulate a transaction manager to control the transactions. First we create an XASession - and enlist it in a transaction through its XAResource. We then send two words, 'hello' and 'world', with - the session, let the transaction roll back. The messages are discarded and never be received. Next we start - a new transaction with the same XAResource, but this time we commit the transaction. Both messages are received.</p> - - <h2>Example step-by-step</h2> - <p><i>To run the example, simply type <code>mvn verify -Pexample</code> from this directory</i></p> - - <ol> - <li>First we need to get an initial context so we can look-up the JMS connection factory and destination objects from JNDI. This initial context will get it's properties from the <code>client-jndi.properties</code> file in the directory <code>../common/config</code></li> - <pre class="prettyprint"> - <code>InitialContext initialContext = getContext(0);</code> - </pre> - - <li>We look-up the JMS queue object from JNDI</li> - <pre class="prettyprint"> - <code>Queue queue = (Queue) initialContext.lookup("/queue/exampleQueue");</code> - </pre> - - <li>We perform a lookup on the XA Connection Factory</li> - <pre class="prettyprint"> - <code>XAConnectionFactory cf = (XAConnectionFactory) initialContext.lookup("/XAConnectionFactory");</code> - </pre> - - <li>We create a JMS XAConnection</li> - <pre class="prettyprint"> - <code>connection = cf.createXAConnection();</code> - </pre> - - <li>We Start the connection</li> - <pre class="prettyprint"> - <code>connection.start();</code> - </pre> - - <li>We create a JMS XASession</li> - <pre class="prettyprint"> - <code>XASession xaSession = connection.createXASession();</code> - </pre> - - <li>We create a normal session</li> - <pre class="prettyprint"> - <code>Session normalSession = connection.createSession(false, Session.AUTO_ACKNOWLEDGE);</code> - </pre> - - <li>We create a normal Message Consumer</li> - <pre class="prettyprint"> - <code> - MessageConsumer normalConsumer = normalSession.createConsumer(queue); - normalConsumer.setMessageListener(new SimpleMessageListener()); - </code> - </pre> - - <li>We get the JMS Session</li> - <pre class="prettyprint"> - <code>Session session = xaSession.getSession();</code> - </pre> - - <li>We create a message producer</li> - <pre class="prettyprint"> - <code>MessageProducer producer = session.createProducer(queue);</code> - </pre> - - <li>We create two Text Messages</li> - <pre class="prettyprint"> - <code> - TextMessage helloMessage = session.createTextMessage("hello"); - TextMessage worldMessage = session.createTextMessage("world"); - </code> - </pre> - - <li>We create a transaction</li> - <pre class="prettyprint"> - <code>Xid xid1 = new XidImpl("xa-example1".getBytes(), 1, UUIDGenerator.getInstance().generateStringUUID().getBytes());</code> - </pre> - - <li>We get the JMS XAResource</li> - <pre class="prettyprint"> - <code>XAResource xaRes = xaSession.getXAResource();</code> - </pre> - - <li>We begin the Transaction work</li> - <pre class="prettyprint"> - <code>xaRes.start(xid1, XAResource.TMNOFLAGS);</code> - </pre> - - <li>We do work, sending two messages.</li> - <pre class="prettyprint"> - <code> - producer.send(helloMessage); - producer.send(worldMessage); - </code> - </pre> - - <li>We check the result, it should receive none!</li> - <pre class="prettyprint"> - <code>checkNoMessageReceived();</code> - </pre> - - <li>We stop the work</li> - <pre class="prettyprint"> - <code>xaRes.end(xid1, XAResource.TMSUCCESS);</code> - </pre> - - <li>We prepare</li> - <pre class="prettyprint"> - <code>xaRes.prepare(xid1);</code> - </pre> - - <li>We roll back the transaction </li> - <pre class="prettyprint"> - <code>xaRes.rollback(xid1);</code> - </pre> - - <li>We check no messages should be received! </li> - <pre class="prettyprint"> - <code>checkNoMessageReceived();</code> - </pre> - - <li>We create another transaction</li> - <pre class="prettyprint"> - <code>Xid xid2 = new XidImpl("xa-example2".getBytes(), 1, UUIDGenerator.getInstance().generateStringUUID().getBytes());</code> - </pre> - - <li>We start the transaction</li> - <pre class="prettyprint"> - <code>xaRes.start(xid2, XAResource.TMNOFLAGS);</code> - </pre> - - <li>We re-send those messages</li> - <pre class="prettyprint"> - <code> - producer.send(helloMessage); - producer.send(worldMessage); - </code> - </pre> - - <li>We stop the work</li> - <pre class="prettyprint"> - <code>xaRes.end(xid2, XAResource.TMSUCCESS);</code> - </pre> - - <li>We prepare</li> - <pre class="prettyprint"> - <code>xaRes.prepare(xid2);</code> - </pre> - - <li>We check that no messages should be received at this moment</li> - <pre class="prettyprint"> - <code>checkNoMessageReceived();</code> - </pre> - - <li>We commit!</li> - <pre class="prettyprint"> - <code>xaRes.commit(xid2, false);</code> - </pre> - - <li>We check that all messages are received.</li> - <pre class="prettyprint"> - <code>checkAllMessageReceived();</code> - </pre> - - <li>And finally, <b>always</b> remember to close your JMS connections and resources after use, in a <code>finally</code> block. Closing a JMS connection will automatically close all of its sessions, consumers, producer and browser objects</li> - - <pre class="prettyprint"> - <code>finally - { - if (initialContext != null) - { - initialContext.close(); - } - if (connection != null) - { - connection.close(); - } - }</code> - </pre> - </ol> - </body> -</html>