You are viewing a plain text version of this content. The canonical link for it is here.
Posted to commits@activemq.apache.org by cl...@apache.org on 2015/08/13 06:13:44 UTC
[26/48] activemq-artemis git commit: renaming broker-features ->
features on examples
http://git-wip-us.apache.org/repos/asf/activemq-artemis/blob/6b17d966/examples/broker-features/standard/topic-selector-example2/readme.html
----------------------------------------------------------------------
diff --git a/examples/broker-features/standard/topic-selector-example2/readme.html b/examples/broker-features/standard/topic-selector-example2/readme.html
deleted file mode 100644
index 608e3d8..0000000
--- a/examples/broker-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/6b17d966/examples/broker-features/standard/topic-selector-example2/src/main/java/org/apache/activemq/artemis/jms/example/TopicSelectorExample2.java
----------------------------------------------------------------------
diff --git a/examples/broker-features/standard/topic-selector-example2/src/main/java/org/apache/activemq/artemis/jms/example/TopicSelectorExample2.java b/examples/broker-features/standard/topic-selector-example2/src/main/java/org/apache/activemq/artemis/jms/example/TopicSelectorExample2.java
deleted file mode 100644
index 464b21b..0000000
--- a/examples/broker-features/standard/topic-selector-example2/src/main/java/org/apache/activemq/artemis/jms/example/TopicSelectorExample2.java
+++ /dev/null
@@ -1,145 +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.
- */
-package org.apache.activemq.artemis.jms.example;
-
-import javax.jms.Connection;
-import javax.jms.ConnectionFactory;
-import javax.jms.JMSException;
-import javax.jms.Message;
-import javax.jms.MessageConsumer;
-import javax.jms.MessageListener;
-import javax.jms.MessageProducer;
-import javax.jms.Session;
-import javax.jms.TextMessage;
-import javax.jms.Topic;
-import javax.naming.InitialContext;
-import java.util.concurrent.atomic.AtomicBoolean;
-
-/**
- * A simple JMS example that consumes messages using selectors.
- */
-public class TopicSelectorExample2 {
-
- public static void main(final String[] args) throws Exception {
- AtomicBoolean result = new AtomicBoolean(true);
- Connection connection = null;
- InitialContext initialContext = null;
- try {
- // /Step 1. Create an initial context to perform the JNDI lookup.
- initialContext = new InitialContext();
-
- // Step 2. perform a lookup on the topic
- Topic topic = (Topic) initialContext.lookup("topic/exampleTopic");
-
- // Step 3. perform a lookup on the Connection Factory
- ConnectionFactory cf = (ConnectionFactory) initialContext.lookup("ConnectionFactory");
-
- // Step 4. Create a JMS Connection
- connection = cf.createConnection();
-
- // Step 5. Start the Connection
- connection.start();
-
- // Step 6. Create a JMS Session
- Session producerSession = connection.createSession(false, Session.AUTO_ACKNOWLEDGE);
-
- // Step 7. Create a Message Producer
- MessageProducer producer = producerSession.createProducer(topic);
-
- // Step 8. Prepare two selectors
- String redSelector = "color='red'";
- String greenSelector = "color='green'";
-
- // Step 9. Create a JMS Message Consumer that receives 'red' messages
- Session redSession = connection.createSession(false, Session.AUTO_ACKNOWLEDGE);
- MessageConsumer redConsumer = redSession.createConsumer(topic, redSelector);
- redConsumer.setMessageListener(new SimpleMessageListener("red", result));
-
- // Step 10. Create a second JMS message consumer that receives 'green' messages
- Session greenSession = connection.createSession(false, Session.AUTO_ACKNOWLEDGE);
- MessageConsumer greenConsumer = greenSession.createConsumer(topic, greenSelector);
- greenConsumer.setMessageListener(new SimpleMessageListener("green", result));
-
- // Step 11. Create another JMS message consumer that receives all messages.
- Session allSession = connection.createSession(false, Session.AUTO_ACKNOWLEDGE);
- MessageConsumer allConsumer = allSession.createConsumer(topic);
- allConsumer.setMessageListener(new SimpleMessageListener("all", result));
-
- // Step 12. Create three messages, each has a color property
- TextMessage redMessage = producerSession.createTextMessage("Red");
- redMessage.setStringProperty("color", "red");
- TextMessage greenMessage = producerSession.createTextMessage("Green");
- greenMessage.setStringProperty("color", "green");
- TextMessage blueMessage = producerSession.createTextMessage("Blue");
- blueMessage.setStringProperty("color", "blue");
-
- // Step 13. Send the Messages
- producer.send(redMessage);
- System.out.println("Message sent: " + redMessage.getText());
- producer.send(greenMessage);
- System.out.println("Message sent: " + greenMessage.getText());
- producer.send(blueMessage);
- System.out.println("Message sent: " + blueMessage.getText());
-
- Thread.sleep(5000);
-
- if (!result.get())
- throw new IllegalStateException();
- }
- finally {
- // Step 14. Be sure to close our JMS resources!
- if (connection != null) {
- connection.close();
- }
-
- // Also the initialContext
- if (initialContext != null) {
- initialContext.close();
- }
- }
- }
-}
-
-class SimpleMessageListener implements MessageListener {
-
- private final String name;
- AtomicBoolean result;
-
- public SimpleMessageListener(final String listener, AtomicBoolean result) {
- name = listener;
- this.result = result;
- }
-
- public void onMessage(final Message msg) {
- TextMessage textMessage = (TextMessage) msg;
- try {
- String colorProp = msg.getStringProperty("color");
- System.out.println("Receiver " + name +
- " receives message [" +
- textMessage.getText() +
- "] with color property: " +
- colorProp);
- if (!colorProp.equals(name) && !name.equals("all")) {
- result.set(false);
- }
- }
- catch (JMSException e) {
- e.printStackTrace();
- result.set(false);
- }
- }
-}
\ No newline at end of file
http://git-wip-us.apache.org/repos/asf/activemq-artemis/blob/6b17d966/examples/broker-features/standard/topic-selector-example2/src/main/resources/activemq/server0/broker.xml
----------------------------------------------------------------------
diff --git a/examples/broker-features/standard/topic-selector-example2/src/main/resources/activemq/server0/broker.xml b/examples/broker-features/standard/topic-selector-example2/src/main/resources/activemq/server0/broker.xml
deleted file mode 100644
index d45eb5d..0000000
--- a/examples/broker-features/standard/topic-selector-example2/src/main/resources/activemq/server0/broker.xml
+++ /dev/null
@@ -1,60 +0,0 @@
-<?xml version='1.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.
--->
-
-<configuration xmlns:xsi="http://www.w3.org/2001/XMLSchema-instance"
- xmlns="urn:activemq"
- xsi:schemaLocation="urn:activemq /schema/artemis-server.xsd">
-
- <jms xmlns="urn:activemq:jms">
- <!--the topic used by the example-->
- <topic name="exampleTopic"/>
- </jms>
-
- <core xmlns="urn:activemq:core">
-
- <bindings-directory>./data/bindings</bindings-directory>
-
- <journal-directory>./data/journal</journal-directory>
-
- <large-messages-directory>./data/largemessages</large-messages-directory>
-
- <paging-directory>./data/paging</paging-directory>
-
- <!-- Acceptors -->
- <acceptors>
- <acceptor name="netty-acceptor">tcp://localhost:61616</acceptor>
- </acceptors>
-
- <!-- Other config -->
-
- <security-settings>
- <!--security for example topic-->
- <security-setting match="jms.topic.exampleTopic">
- <permission type="createDurableQueue" roles="guest"/>
- <permission type="deleteDurableQueue" roles="guest"/>
- <permission type="createNonDurableQueue" roles="guest"/>
- <permission type="deleteNonDurableQueue" roles="guest"/>
- <permission type="consume" roles="guest"/>
- <permission type="send" roles="guest"/>
- </security-setting>
- </security-settings>
-
- </core>
-</configuration>
http://git-wip-us.apache.org/repos/asf/activemq-artemis/blob/6b17d966/examples/broker-features/standard/topic-selector-example2/src/main/resources/jndi.properties
----------------------------------------------------------------------
diff --git a/examples/broker-features/standard/topic-selector-example2/src/main/resources/jndi.properties b/examples/broker-features/standard/topic-selector-example2/src/main/resources/jndi.properties
deleted file mode 100644
index 54bed6d..0000000
--- a/examples/broker-features/standard/topic-selector-example2/src/main/resources/jndi.properties
+++ /dev/null
@@ -1,20 +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.
-
-java.naming.factory.initial=org.apache.activemq.artemis.jndi.ActiveMQInitialContextFactory
-connectionFactory.ConnectionFactory=tcp://localhost:61616
-topic.topic/exampleTopic=exampleTopic
http://git-wip-us.apache.org/repos/asf/activemq-artemis/blob/6b17d966/examples/broker-features/standard/topic/pom.xml
----------------------------------------------------------------------
diff --git a/examples/broker-features/standard/topic/pom.xml b/examples/broker-features/standard/topic/pom.xml
deleted file mode 100644
index 7cc643e..0000000
--- a/examples/broker-features/standard/topic/pom.xml
+++ /dev/null
@@ -1,108 +0,0 @@
-<?xml version='1.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.
--->
-
-<project xmlns="http://maven.apache.org/POM/4.0.0" xmlns:xsi="http://www.w3.org/2001/XMLSchema-instance"
- xsi:schemaLocation="http://maven.apache.org/POM/4.0.0 http://maven.apache.org/maven-v4_0_0.xsd">
- <modelVersion>4.0.0</modelVersion>
-
- <parent>
- <groupId>org.apache.activemq.examples.broker</groupId>
- <artifactId>jms-examples</artifactId>
- <version>1.0.1-SNAPSHOT</version>
- </parent>
-
- <artifactId>topic</artifactId>
- <packaging>jar</packaging>
- <name>ActiveMQ Artemis JMS Topic Example</name>
-
- <properties>
- <activemq.basedir>${project.basedir}/../../../..</activemq.basedir>
- </properties>
-
- <dependencies>
- <dependency>
- <groupId>org.apache.activemq</groupId>
- <artifactId>artemis-jms-client</artifactId>
- <version>${project.version}</version>
- </dependency>
- </dependencies>
-
- <build>
- <plugins>
- <plugin>
- <groupId>org.apache.activemq</groupId>
- <artifactId>artemis-maven-plugin</artifactId>
- <executions>
- <execution>
- <id>create</id>
- <goals>
- <goal>create</goal>
- </goals>
- <configuration>
- <ignore>${noServer}</ignore>
- </configuration>
- </execution>
- <execution>
- <id>start</id>
- <goals>
- <goal>cli</goal>
- </goals>
- <configuration>
- <ignore>${noServer}</ignore>
- <spawn>true</spawn>
- <testURI>tcp://localhost:61616</testURI>
- <args>
- <param>run</param>
- </args>
- </configuration>
- </execution>
- <execution>
- <id>runClient</id>
- <goals>
- <goal>runClient</goal>
- </goals>
- <configuration>
- <clientClass>org.apache.activemq.artemis.jms.example.TopicExample</clientClass>
- </configuration>
- </execution>
- <execution>
- <id>stop</id>
- <goals>
- <goal>cli</goal>
- </goals>
- <configuration>
- <ignore>${noServer}</ignore>
- <args>
- <param>stop</param>
- </args>
- </configuration>
- </execution>
- </executions>
- <dependencies>
- <dependency>
- <groupId>org.apache.activemq.examples.broker</groupId>
- <artifactId>topic</artifactId>
- <version>${project.version}</version>
- </dependency>
- </dependencies>
- </plugin>
- </plugins>
- </build>
-</project>
http://git-wip-us.apache.org/repos/asf/activemq-artemis/blob/6b17d966/examples/broker-features/standard/topic/readme.html
----------------------------------------------------------------------
diff --git a/examples/broker-features/standard/topic/readme.html b/examples/broker-features/standard/topic/readme.html
deleted file mode 100644
index 8bfa903..0000000
--- a/examples/broker-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/6b17d966/examples/broker-features/standard/topic/src/main/java/org/apache/activemq/artemis/jms/example/TopicExample.java
----------------------------------------------------------------------
diff --git a/examples/broker-features/standard/topic/src/main/java/org/apache/activemq/artemis/jms/example/TopicExample.java b/examples/broker-features/standard/topic/src/main/java/org/apache/activemq/artemis/jms/example/TopicExample.java
deleted file mode 100644
index 1c8695b..0000000
--- a/examples/broker-features/standard/topic/src/main/java/org/apache/activemq/artemis/jms/example/TopicExample.java
+++ /dev/null
@@ -1,94 +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.
- */
-package org.apache.activemq.artemis.jms.example;
-
-import javax.jms.Connection;
-import javax.jms.ConnectionFactory;
-import javax.jms.MessageConsumer;
-import javax.jms.MessageProducer;
-import javax.jms.Session;
-import javax.jms.TextMessage;
-import javax.jms.Topic;
-import javax.naming.InitialContext;
-
-/**
- * A simple JMS Topic example that creates a producer and consumer on a queue and sends and receives a message.
- */
-public class TopicExample {
-
- public static void main(final String[] args) throws Exception {
- Connection connection = null;
- InitialContext initialContext = null;
- try {
- // /Step 1. Create an initial context to perform the JNDI lookup.
- initialContext = new InitialContext();
-
- // Step 2. perform a lookup on the topic
- Topic topic = (Topic) initialContext.lookup("topic/exampleTopic");
-
- // Step 3. perform a lookup on the Connection Factory
- ConnectionFactory cf = (ConnectionFactory) initialContext.lookup("ConnectionFactory");
-
- // Step 4. Create a JMS Connection
- connection = cf.createConnection();
-
- // Step 5. Create a JMS Session
- Session session = connection.createSession(false, Session.AUTO_ACKNOWLEDGE);
-
- // Step 6. Create a Message Producer
- MessageProducer producer = session.createProducer(topic);
-
- // Step 7. Create a JMS Message Consumer
- MessageConsumer messageConsumer1 = session.createConsumer(topic);
-
- // Step 8. Create a JMS Message Consumer
- MessageConsumer messageConsumer2 = session.createConsumer(topic);
-
- // Step 9. Create a Text Message
- TextMessage message = session.createTextMessage("This is a text message");
-
- System.out.println("Sent message: " + message.getText());
-
- // Step 10. Send the Message
- producer.send(message);
-
- // Step 11. Start the Connection
- connection.start();
-
- // Step 12. Receive the message
- TextMessage messageReceived = (TextMessage) messageConsumer1.receive();
-
- System.out.println("Consumer 1 Received message: " + messageReceived.getText());
-
- // Step 13. Receive the message
- messageReceived = (TextMessage) messageConsumer2.receive();
-
- System.out.println("Consumer 2 Received message: " + messageReceived.getText());
- }
- finally {
- // Step 14. Be sure to close our JMS resources!
- if (connection != null) {
- connection.close();
- }
-
- // Also the initialContext
- if (initialContext != null) {
- initialContext.close();
- }
- }
- }
-}
http://git-wip-us.apache.org/repos/asf/activemq-artemis/blob/6b17d966/examples/broker-features/standard/topic/src/main/resources/activemq/server0/broker.xml
----------------------------------------------------------------------
diff --git a/examples/broker-features/standard/topic/src/main/resources/activemq/server0/broker.xml b/examples/broker-features/standard/topic/src/main/resources/activemq/server0/broker.xml
deleted file mode 100644
index fd6671c..0000000
--- a/examples/broker-features/standard/topic/src/main/resources/activemq/server0/broker.xml
+++ /dev/null
@@ -1,59 +0,0 @@
-<?xml version='1.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.
--->
-
-<configuration xmlns:xsi="http://www.w3.org/2001/XMLSchema-instance"
- xmlns="urn:activemq"
- xsi:schemaLocation="urn:activemq /schema/artemis-server.xsd">
-
- <jms xmlns="urn:activemq:jms">
- <!--the topic used by the example-->
- <topic name="exampleTopic"/>
- </jms>
-
- <core xmlns="urn:activemq:core">
-
- <bindings-directory>./data/bindings</bindings-directory>
-
- <journal-directory>./data/journal</journal-directory>
-
- <large-messages-directory>./data/largemessages</large-messages-directory>
-
- <paging-directory>./data/paging</paging-directory>
-
- <!-- Acceptors -->
- <acceptors>
- <acceptor name="netty-acceptor">tcp://localhost:61616</acceptor>
- </acceptors>
-
- <!-- Other config -->
- <security-settings>
- <!--security for example topic-->
- <security-setting match="jms.topic.exampleTopic">
- <permission type="createDurableQueue" roles="guest"/>
- <permission type="deleteDurableQueue" roles="guest"/>
- <permission type="createNonDurableQueue" roles="guest"/>
- <permission type="deleteNonDurableQueue" roles="guest"/>
- <permission type="consume" roles="guest"/>
- <permission type="send" roles="guest"/>
- </security-setting>
- </security-settings>
-
- </core>
-</configuration>
http://git-wip-us.apache.org/repos/asf/activemq-artemis/blob/6b17d966/examples/broker-features/standard/topic/src/main/resources/jndi.properties
----------------------------------------------------------------------
diff --git a/examples/broker-features/standard/topic/src/main/resources/jndi.properties b/examples/broker-features/standard/topic/src/main/resources/jndi.properties
deleted file mode 100644
index 54bed6d..0000000
--- a/examples/broker-features/standard/topic/src/main/resources/jndi.properties
+++ /dev/null
@@ -1,20 +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.
-
-java.naming.factory.initial=org.apache.activemq.artemis.jndi.ActiveMQInitialContextFactory
-connectionFactory.ConnectionFactory=tcp://localhost:61616
-topic.topic/exampleTopic=exampleTopic
http://git-wip-us.apache.org/repos/asf/activemq-artemis/blob/6b17d966/examples/broker-features/standard/transactional/pom.xml
----------------------------------------------------------------------
diff --git a/examples/broker-features/standard/transactional/pom.xml b/examples/broker-features/standard/transactional/pom.xml
deleted file mode 100644
index 660d262..0000000
--- a/examples/broker-features/standard/transactional/pom.xml
+++ /dev/null
@@ -1,109 +0,0 @@
-<?xml version='1.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.
--->
-
-<project xmlns="http://maven.apache.org/POM/4.0.0" xmlns:xsi="http://www.w3.org/2001/XMLSchema-instance"
- xsi:schemaLocation="http://maven.apache.org/POM/4.0.0 http://maven.apache.org/maven-v4_0_0.xsd">
- <modelVersion>4.0.0</modelVersion>
-
- <parent>
- <groupId>org.apache.activemq.examples.broker</groupId>
- <artifactId>jms-examples</artifactId>
- <version>1.0.1-SNAPSHOT</version>
- </parent>
-
- <artifactId>transactional</artifactId>
- <packaging>jar</packaging>
- <name>ActiveMQ Artemis JMS Transactional Example</name>
-
- <properties>
- <activemq.basedir>${project.basedir}/../../../..</activemq.basedir>
- </properties>
-
- <dependencies>
- <dependency>
- <groupId>org.apache.activemq</groupId>
- <artifactId>artemis-jms-client</artifactId>
- <version>${project.version}</version>
- </dependency>
- </dependencies>
-
- <build>
- <plugins>
- <plugin>
- <groupId>org.apache.activemq</groupId>
- <artifactId>artemis-maven-plugin</artifactId>
- <executions>
- <execution>
- <id>create</id>
- <goals>
- <goal>create</goal>
- </goals>
- <configuration>
- <ignore>${noServer}</ignore>
- </configuration>
- </execution>
- <execution>
- <id>start</id>
- <goals>
- <goal>cli</goal>
- </goals>
- <configuration>
- <ignore>${noServer}</ignore>
- <spawn>true</spawn>
- <testURI>tcp://localhost:61616</testURI>
- <args>
- <param>run</param>
- </args>
- </configuration>
- </execution>
- <execution>
- <id>runClient</id>
- <goals>
- <goal>runClient</goal>
- </goals>
- <configuration>
- <clientClass>org.apache.activemq.artemis.jms.example.TransactionalExample</clientClass>
- </configuration>
- </execution>
- <execution>
- <id>stop</id>
- <goals>
- <goal>cli</goal>
- </goals>
- <configuration>
- <ignore>${noServer}</ignore>
- <args>
- <param>stop</param>
- </args>
- </configuration>
- </execution>
- </executions>
- <dependencies>
- <dependency>
- <groupId>org.apache.activemq.examples.broker</groupId>
- <artifactId>transactional</artifactId>
- <version>${project.version}</version>
- </dependency>
- </dependencies>
- </plugin>
- </plugins>
- </build>
-
-</project>
http://git-wip-us.apache.org/repos/asf/activemq-artemis/blob/6b17d966/examples/broker-features/standard/transactional/readme.html
----------------------------------------------------------------------
diff --git a/examples/broker-features/standard/transactional/readme.html b/examples/broker-features/standard/transactional/readme.html
deleted file mode 100644
index b171c0a..0000000
--- a/examples/broker-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/6b17d966/examples/broker-features/standard/transactional/src/main/java/org/apache/activemq/artemis/jms/example/TransactionalExample.java
----------------------------------------------------------------------
diff --git a/examples/broker-features/standard/transactional/src/main/java/org/apache/activemq/artemis/jms/example/TransactionalExample.java b/examples/broker-features/standard/transactional/src/main/java/org/apache/activemq/artemis/jms/example/TransactionalExample.java
deleted file mode 100644
index 09c2a3d..0000000
--- a/examples/broker-features/standard/transactional/src/main/java/org/apache/activemq/artemis/jms/example/TransactionalExample.java
+++ /dev/null
@@ -1,126 +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.
- */
-package org.apache.activemq.artemis.jms.example;
-
-import javax.jms.Connection;
-import javax.jms.ConnectionFactory;
-import javax.jms.MessageConsumer;
-import javax.jms.MessageProducer;
-import javax.jms.Queue;
-import javax.jms.Session;
-import javax.jms.TextMessage;
-import javax.naming.InitialContext;
-
-/**
- * A simple JMS example that sends and consume message transactionally.
- */
-public class TransactionalExample {
-
- public static void main(final String[] args) throws Exception {
- Connection connection = null;
- InitialContext initialContext = null;
- try {
- // Step 1. Create an initial context to perform the JNDI lookup.
- initialContext = new InitialContext();
-
- // Step 2. Look-up the JMS topic
- Queue queue = (Queue) initialContext.lookup("queue/exampleQueue");
-
- // Step 3. Look-up the JMS connection factory
- ConnectionFactory cf = (ConnectionFactory) initialContext.lookup("ConnectionFactory");
-
- // Step 4. Create a JMS connection
- connection = cf.createConnection();
-
- // Step 5. Start the connection
- connection.start();
-
- // Step 6. Create a transactional JMS session
- Session session = connection.createSession(true, Session.SESSION_TRANSACTED);
-
- // Step 7. Create a JMS message producer
- MessageProducer messageProducer = session.createProducer(queue);
-
- // Step 8. Create a message consumer
- MessageConsumer messageConsumer = session.createConsumer(queue);
-
- // Step 9. Create 2 text messages
- TextMessage message1 = session.createTextMessage("This is a text message1");
- TextMessage message2 = session.createTextMessage("This is a text message2");
-
- // Step 10. Send the text messages to the queue
- messageProducer.send(message1);
- messageProducer.send(message2);
-
- System.out.println("Sent message: " + message1.getText());
- System.out.println("Sent message: " + message2.getText());
-
- // Step 11. Receive the message, it will return null as the transaction is not committed.
- TextMessage receivedMessage = (TextMessage) messageConsumer.receive(5000);
-
- System.out.println("Message received before send commit: " + receivedMessage);
-
- // Step 12. Commit the session
- session.commit();
-
- // Step 13. Receive the messages again
- receivedMessage = (TextMessage) messageConsumer.receive(5000);
-
- System.out.println("Message received after send commit: " + receivedMessage.getText());
-
- // Step 14. Roll back the session, this will cause the received message canceled and redelivered again.
- session.rollback();
-
- // Step 15. Receive the message again, we will get two messages
- receivedMessage = (TextMessage) messageConsumer.receive(5000);
-
- System.out.println("Message1 received after receive rollback: " + receivedMessage.getText());
-
- receivedMessage = (TextMessage) messageConsumer.receive(5000);
-
- System.out.println("Message2 received after receive rollback: " + receivedMessage.getText());
-
- receivedMessage = (TextMessage) messageConsumer.receive(5000);
-
- System.out.println("Message3 received after receive rollback: " + receivedMessage);
-
- // Step 16. Commit the session
- session.commit();
-
- // Step 17. Receive the message again. Nothing should be received.
- receivedMessage = (TextMessage) messageConsumer.receive(5000);
-
- if (receivedMessage != null) {
- // This was not supposed to happen
- throw new IllegalStateException("Message is not null.");
- }
-
- System.out.println("Message received after receive commit: " + receivedMessage);
-
- }
- finally {
- if (connection != null) {
- // Step 18. Be sure to close our JMS resources!
- connection.close();
- }
- if (initialContext != null) {
- // Step 19. Also close initial context!
- initialContext.close();
- }
- }
- }
-}
http://git-wip-us.apache.org/repos/asf/activemq-artemis/blob/6b17d966/examples/broker-features/standard/transactional/src/main/resources/jndi.properties
----------------------------------------------------------------------
diff --git a/examples/broker-features/standard/transactional/src/main/resources/jndi.properties b/examples/broker-features/standard/transactional/src/main/resources/jndi.properties
deleted file mode 100644
index 93537c4..0000000
--- a/examples/broker-features/standard/transactional/src/main/resources/jndi.properties
+++ /dev/null
@@ -1,20 +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.
-
-java.naming.factory.initial=org.apache.activemq.artemis.jndi.ActiveMQInitialContextFactory
-connectionFactory.ConnectionFactory=tcp://localhost:61616
-queue.queue/exampleQueue=exampleQueue
http://git-wip-us.apache.org/repos/asf/activemq-artemis/blob/6b17d966/examples/broker-features/standard/xa-heuristic/pom.xml
----------------------------------------------------------------------
diff --git a/examples/broker-features/standard/xa-heuristic/pom.xml b/examples/broker-features/standard/xa-heuristic/pom.xml
deleted file mode 100644
index 6f4025b..0000000
--- a/examples/broker-features/standard/xa-heuristic/pom.xml
+++ /dev/null
@@ -1,111 +0,0 @@
-<?xml version='1.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.
--->
-
-<project xmlns="http://maven.apache.org/POM/4.0.0" xmlns:xsi="http://www.w3.org/2001/XMLSchema-instance"
- xsi:schemaLocation="http://maven.apache.org/POM/4.0.0 http://maven.apache.org/maven-v4_0_0.xsd">
- <modelVersion>4.0.0</modelVersion>
-
- <parent>
- <groupId>org.apache.activemq.examples.broker</groupId>
- <artifactId>jms-examples</artifactId>
- <version>1.0.1-SNAPSHOT</version>
- </parent>
-
- <artifactId>xa-heuristic</artifactId>
- <packaging>jar</packaging>
- <name>ActiveMQ Artemis JMS XAHeuristicExample Example</name>
-
- <properties>
- <activemq.basedir>${project.basedir}/../../../..</activemq.basedir>
- </properties>
-
- <dependencies>
- <dependency>
- <groupId>org.apache.activemq</groupId>
- <artifactId>artemis-jms-client</artifactId>
- <version>${project.version}</version>
- </dependency>
- </dependencies>
-
- <build>
- <plugins>
- <plugin>
- <groupId>org.apache.activemq</groupId>
- <artifactId>artemis-maven-plugin</artifactId>
- <executions>
- <execution>
- <id>create</id>
- <goals>
- <goal>create</goal>
- </goals>
- <configuration>
- <javaOptions>-Dcom.sun.management.jmxremote -Dcom.sun.management.jmxremote.port=3001 -Dcom.sun.management.jmxremote.ssl=false -Dcom.sun.management.jmxremote.authenticate=false
- </javaOptions>
- <ignore>${noServer}</ignore>
- </configuration>
- </execution>
- <execution>
- <id>start</id>
- <goals>
- <goal>cli</goal>
- </goals>
- <configuration>
- <ignore>${noServer}</ignore>
- <spawn>true</spawn>
- <testURI>tcp://localhost:61616</testURI>
- <args>
- <param>run</param>
- </args>
- </configuration>
- </execution>
- <execution>
- <id>runClient</id>
- <goals>
- <goal>runClient</goal>
- </goals>
- <configuration>
- <clientClass>org.apache.activemq.artemis.jms.example.XAHeuristicExample</clientClass>
- </configuration>
- </execution>
- <execution>
- <id>stop</id>
- <goals>
- <goal>cli</goal>
- </goals>
- <configuration>
- <ignore>${noServer}</ignore>
- <args>
- <param>stop</param>
- </args>
- </configuration>
- </execution>
- </executions>
- <dependencies>
- <dependency>
- <groupId>org.apache.activemq.examples.broker</groupId>
- <artifactId>xa-heuristic</artifactId>
- <version>${project.version}</version>
- </dependency>
- </dependencies>
- </plugin>
- </plugins>
- </build>
-
-</project>
http://git-wip-us.apache.org/repos/asf/activemq-artemis/blob/6b17d966/examples/broker-features/standard/xa-heuristic/readme.html
----------------------------------------------------------------------
diff --git a/examples/broker-features/standard/xa-heuristic/readme.html b/examples/broker-features/standard/xa-heuristic/readme.html
deleted file mode 100644
index bf44937..0000000
--- a/examples/broker-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/6b17d966/examples/broker-features/standard/xa-heuristic/src/main/java/org/apache/activemq/artemis/jms/example/DummyXid.java
----------------------------------------------------------------------
diff --git a/examples/broker-features/standard/xa-heuristic/src/main/java/org/apache/activemq/artemis/jms/example/DummyXid.java b/examples/broker-features/standard/xa-heuristic/src/main/java/org/apache/activemq/artemis/jms/example/DummyXid.java
deleted file mode 100644
index 8b6be80..0000000
--- a/examples/broker-features/standard/xa-heuristic/src/main/java/org/apache/activemq/artemis/jms/example/DummyXid.java
+++ /dev/null
@@ -1,184 +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.
- */
-package org.apache.activemq.artemis.jms.example;
-
-import javax.transaction.xa.Xid;
-
-import org.apache.activemq.artemis.utils.Base64;
-
-public class DummyXid implements Xid {
-
- private static final long serialVersionUID = 407053232840068514L;
-
- private final byte[] branchQualifier;
-
- private final int formatId;
-
- private final byte[] globalTransactionId;
-
- private int hash;
-
- private boolean hashCalculated;
-
- // Static --------------------------------------------------------
-
- public static String toBase64String(final Xid xid) {
- return Base64.encodeBytes(DummyXid.toByteArray(xid));
- }
-
- private static byte[] toByteArray(final Xid xid) {
- byte[] branchQualifier = xid.getBranchQualifier();
- byte[] globalTransactionId = xid.getGlobalTransactionId();
- int formatId = xid.getFormatId();
-
- byte[] hashBytes = new byte[branchQualifier.length + globalTransactionId.length + 4];
- System.arraycopy(branchQualifier, 0, hashBytes, 0, branchQualifier.length);
- System.arraycopy(globalTransactionId, 0, hashBytes, branchQualifier.length, globalTransactionId.length);
- byte[] intBytes = new byte[4];
- for (int i = 0; i < 4; i++) {
- intBytes[i] = (byte) ((formatId >> i * 8) % 0xFF);
- }
- System.arraycopy(intBytes, 0, hashBytes, branchQualifier.length + globalTransactionId.length, 4);
- return hashBytes;
- }
-
- // Constructors --------------------------------------------------
-
- /**
- * Standard constructor
- *
- * @param branchQualifier
- * @param formatId
- * @param globalTransactionId
- */
- public DummyXid(final byte[] branchQualifier, final int formatId, final byte[] globalTransactionId) {
- this.branchQualifier = branchQualifier;
- this.formatId = formatId;
- this.globalTransactionId = globalTransactionId;
- }
-
- /**
- * Copy constructor
- *
- * @param other
- */
- public DummyXid(final Xid other) {
- branchQualifier = copyBytes(other.getBranchQualifier());
- formatId = other.getFormatId();
- globalTransactionId = copyBytes(other.getGlobalTransactionId());
- }
-
- // Xid implementation ------------------------------------------------------------------
-
- public byte[] getBranchQualifier() {
- return branchQualifier;
- }
-
- public int getFormatId() {
- return formatId;
- }
-
- public byte[] getGlobalTransactionId() {
- return globalTransactionId;
- }
-
- // Public -------------------------------------------------------------------------------
-
- @Override
- public int hashCode() {
- if (!hashCalculated) {
- calcHash();
- }
- return hash;
- }
-
- @Override
- public boolean equals(final Object other) {
- if (this == other) {
- return true;
- }
- if (!(other instanceof Xid)) {
- return false;
- }
- Xid xother = (Xid) other;
- if (xother.getFormatId() != formatId) {
- return false;
- }
- if (xother.getBranchQualifier().length != branchQualifier.length) {
- return false;
- }
- if (xother.getGlobalTransactionId().length != globalTransactionId.length) {
- return false;
- }
- for (int i = 0; i < branchQualifier.length; i++) {
- byte[] otherBQ = xother.getBranchQualifier();
- if (branchQualifier[i] != otherBQ[i]) {
- return false;
- }
- }
- for (int i = 0; i < globalTransactionId.length; i++) {
- byte[] otherGtx = xother.getGlobalTransactionId();
- if (globalTransactionId[i] != otherGtx[i]) {
- return false;
- }
- }
- return true;
- }
-
- @Override
- public String toString() {
- return "XidImpl (" + System.identityHashCode(this) +
- " bq:" +
- stringRep(branchQualifier) +
- " formatID:" +
- formatId +
- " gtxid:" +
- stringRep(globalTransactionId);
- }
-
- // Private -------------------------------------------------------------------------------
-
- private String stringRep(final byte[] bytes) {
- StringBuilder buff = new StringBuilder();
- for (int i = 0; i < bytes.length; i++) {
- byte b = bytes[i];
-
- buff.append(b);
-
- if (i != bytes.length - 1) {
- buff.append('.');
- }
- }
-
- return buff.toString();
- }
-
- private void calcHash() {
- byte[] hashBytes = org.apache.activemq.artemis.jms.example.DummyXid.toByteArray(this);
- String s = new String(hashBytes);
- hash = s.hashCode();
- hashCalculated = true;
- }
-
- private byte[] copyBytes(final byte[] other) {
- byte[] bytes = new byte[other.length];
-
- System.arraycopy(other, 0, bytes, 0, other.length);
-
- return bytes;
- }
-}
http://git-wip-us.apache.org/repos/asf/activemq-artemis/blob/6b17d966/examples/broker-features/standard/xa-heuristic/src/main/java/org/apache/activemq/artemis/jms/example/XAHeuristicExample.java
----------------------------------------------------------------------
diff --git a/examples/broker-features/standard/xa-heuristic/src/main/java/org/apache/activemq/artemis/jms/example/XAHeuristicExample.java b/examples/broker-features/standard/xa-heuristic/src/main/java/org/apache/activemq/artemis/jms/example/XAHeuristicExample.java
deleted file mode 100644
index d233731..0000000
--- a/examples/broker-features/standard/xa-heuristic/src/main/java/org/apache/activemq/artemis/jms/example/XAHeuristicExample.java
+++ /dev/null
@@ -1,219 +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.
- */
-package org.apache.activemq.artemis.jms.example;
-
-import javax.jms.JMSException;
-import javax.jms.Message;
-import javax.jms.MessageConsumer;
-import javax.jms.MessageListener;
-import javax.jms.MessageProducer;
-import javax.jms.Queue;
-import javax.jms.Session;
-import javax.jms.TextMessage;
-import javax.jms.XAConnection;
-import javax.jms.XAConnectionFactory;
-import javax.jms.XASession;
-import javax.management.MBeanServerConnection;
-import javax.management.ObjectName;
-import javax.management.remote.JMXConnector;
-import javax.management.remote.JMXConnectorFactory;
-import javax.management.remote.JMXServiceURL;
-import javax.naming.InitialContext;
-import javax.transaction.xa.XAResource;
-import javax.transaction.xa.Xid;
-import java.nio.charset.StandardCharsets;
-import java.util.ArrayList;
-import java.util.HashMap;
-
-import org.apache.activemq.artemis.api.core.management.ObjectNameBuilder;
-import org.apache.activemq.artemis.utils.UUIDGenerator;
-
-/**
- * A simple JMS example showing how to administer un-finished transactions.
- */
-public class XAHeuristicExample {
-
- private static final String JMX_URL = "service:jmx:rmi:///jndi/rmi://localhost:3001/jmxrmi";
-
- public static void main(final String[] args) throws Exception {
- Boolean result = true;
- final ArrayList<String> receiveHolder = new ArrayList<String>();
- XAConnection connection = null;
- InitialContext initialContext = null;
- try {
- // Step 1. Create an initial context to perform the JNDI lookup.
- initialContext = new InitialContext();
-
- // Step 2. Lookup on the queue
- Queue queue = (Queue) initialContext.lookup("queue/exampleQueue");
-
- // Step 3. Perform a lookup on the XA Connection Factory
- XAConnectionFactory cf = (XAConnectionFactory) initialContext.lookup("XAConnectionFactory");
-
- // Step 4.Create a JMS XAConnection
- connection = cf.createXAConnection();
-
- // Step 5. Start the connection
- connection.start();
-
- // Step 6. Create a JMS XASession
- XASession xaSession = connection.createXASession();
-
- // Step 7. Create a normal session
- Session normalSession = connection.createSession(false, Session.AUTO_ACKNOWLEDGE);
-
- // Step 8. Create a normal Message Consumer
- MessageConsumer normalConsumer = normalSession.createConsumer(queue);
- normalConsumer.setMessageListener(new SimpleMessageListener(receiveHolder, result));
-
- // Step 9. Get the JMS Session
- Session session = xaSession.getSession();
-
- // Step 10. Create a message producer
- MessageProducer producer = session.createProducer(queue);
-
- // Step 11. Create two Text Messages
- TextMessage helloMessage = session.createTextMessage("hello");
- TextMessage worldMessage = session.createTextMessage("world");
-
- // Step 12. create a transaction
- Xid xid1 = new DummyXid("xa-example1".getBytes(StandardCharsets.ISO_8859_1), 1, UUIDGenerator.getInstance().generateStringUUID().getBytes());
-
- // Step 13. Get the JMS XAResource
- XAResource xaRes = xaSession.getXAResource();
-
- // Step 14. Begin the Transaction work
- xaRes.start(xid1, XAResource.TMNOFLAGS);
-
- // Step 15. do work, sending hello message.
- producer.send(helloMessage);
-
- System.out.println("Sent message " + helloMessage.getText());
-
- // Step 16. Stop the work for xid1
- xaRes.end(xid1, XAResource.TMSUCCESS);
-
- // Step 17. Prepare xid1
- xaRes.prepare(xid1);
-
- // Step 18. Check none should be received
- checkNoMessageReceived(receiveHolder);
-
- // Step 19. Create another transaction.
- Xid xid2 = new DummyXid("xa-example2".getBytes(), 1, UUIDGenerator.getInstance().generateStringUUID().getBytes());
-
- // Step 20. Begin the transaction work
- xaRes.start(xid2, XAResource.TMNOFLAGS);
-
- // Step 21. Send the second message
- producer.send(worldMessage);
-
- System.out.println("Sent message " + worldMessage.getText());
-
- // Step 22. Stop the work for xid2
- xaRes.end(xid2, XAResource.TMSUCCESS);
-
- // Step 23. prepare xid2
- xaRes.prepare(xid2);
-
- // Step 24. Again, no messages should be received!
- checkNoMessageReceived(receiveHolder);
-
- // Step 25. Create JMX Connector to connect to the server's MBeanServer
- JMXConnector connector = JMXConnectorFactory.connect(new JMXServiceURL(JMX_URL), new HashMap<String, String>());
-
- // Step 26. Retrieve the MBeanServerConnection
- MBeanServerConnection mbsc = connector.getMBeanServerConnection();
-
- // Step 27. List the prepared transactions
- ObjectName serverObject = ObjectNameBuilder.DEFAULT.getActiveMQServerObjectName();
- String[] infos = (String[]) mbsc.invoke(serverObject, "listPreparedTransactions", null, null);
-
- System.out.println("Prepared transactions: ");
- for (String i : infos) {
- System.out.println(i);
- }
-
- // Step 28. Roll back the first transaction
- mbsc.invoke(serverObject, "rollbackPreparedTransaction", new String[]{DummyXid.toBase64String(xid1)}, new String[]{"java.lang.String"});
-
- // Step 29. Commit the second one
- mbsc.invoke(serverObject, "commitPreparedTransaction", new String[]{DummyXid.toBase64String(xid2)}, new String[]{"java.lang.String"});
-
- Thread.sleep(2000);
-
- // Step 30. Check the result, only the 'world' message received
- checkMessageReceived("world", receiveHolder);
-
- // Step 31. Check the prepared transaction again, should have none.
- infos = (String[]) mbsc.invoke(serverObject, "listPreparedTransactions", null, null);
- System.out.println("No. of prepared transactions now: " + infos.length);
-
- // Step 32. Close the JMX Connector
- connector.close();
- }
- finally {
- // Step 32. Be sure to close our JMS resources!
- if (initialContext != null) {
- initialContext.close();
- }
- if (connection != null) {
- connection.close();
- }
- }
- }
-
- private static void checkMessageReceived(final String value, ArrayList<String> receiveHolder) {
- if (receiveHolder.size() != 1) {
- throw new IllegalStateException("Number of messages received not correct ! -- " + receiveHolder.size());
- }
- String msg = receiveHolder.get(0);
- if (!msg.equals(value)) {
- throw new IllegalStateException("Received message [" + msg + "], but we expect [" + value + "]");
- }
- receiveHolder.clear();
- }
-
- private static void checkNoMessageReceived(ArrayList<String> receiveHolder) {
- if (receiveHolder.size() > 0) {
- throw new IllegalStateException("Message received, wrong!");
- }
- receiveHolder.clear();
- }
-}
-
-class SimpleMessageListener implements MessageListener {
-
- ArrayList<String> receiveHolder;
- Boolean result;
-
- SimpleMessageListener(ArrayList<String> receiveHolder, Boolean result) {
- this.receiveHolder = receiveHolder;
- this.result = result;
- }
-
- public void onMessage(final Message message) {
- try {
- System.out.println("Message received: " + ((TextMessage) message).getText());
- receiveHolder.add(((TextMessage) message).getText());
- }
- catch (JMSException e) {
- result = false;
- e.printStackTrace();
- }
- }
-}
http://git-wip-us.apache.org/repos/asf/activemq-artemis/blob/6b17d966/examples/broker-features/standard/xa-heuristic/src/main/resources/jndi.properties
----------------------------------------------------------------------
diff --git a/examples/broker-features/standard/xa-heuristic/src/main/resources/jndi.properties b/examples/broker-features/standard/xa-heuristic/src/main/resources/jndi.properties
deleted file mode 100644
index 77561f7..0000000
--- a/examples/broker-features/standard/xa-heuristic/src/main/resources/jndi.properties
+++ /dev/null
@@ -1,21 +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.
-
-java.naming.factory.initial=org.apache.activemq.artemis.jndi.ActiveMQInitialContextFactory
-connectionFactory.ConnectionFactory=tcp://localhost:61616
-connectionFactory.XAConnectionFactory=tcp://localhost:61616?type=XA_CF
-queue.queue/exampleQueue=exampleQueue
http://git-wip-us.apache.org/repos/asf/activemq-artemis/blob/6b17d966/examples/broker-features/standard/xa-receive/pom.xml
----------------------------------------------------------------------
diff --git a/examples/broker-features/standard/xa-receive/pom.xml b/examples/broker-features/standard/xa-receive/pom.xml
deleted file mode 100644
index f421aaf..0000000
--- a/examples/broker-features/standard/xa-receive/pom.xml
+++ /dev/null
@@ -1,109 +0,0 @@
-<?xml version='1.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.
--->
-
-<project xmlns="http://maven.apache.org/POM/4.0.0" xmlns:xsi="http://www.w3.org/2001/XMLSchema-instance"
- xsi:schemaLocation="http://maven.apache.org/POM/4.0.0 http://maven.apache.org/maven-v4_0_0.xsd">
- <modelVersion>4.0.0</modelVersion>
-
- <parent>
- <groupId>org.apache.activemq.examples.broker</groupId>
- <artifactId>jms-examples</artifactId>
- <version>1.0.1-SNAPSHOT</version>
- </parent>
-
- <artifactId>xa-receive</artifactId>
- <packaging>jar</packaging>
- <name>ActiveMQ Artemis JMS XA Receive Example</name>
-
- <properties>
- <activemq.basedir>${project.basedir}/../../../..</activemq.basedir>
- </properties>
-
- <dependencies>
- <dependency>
- <groupId>org.apache.activemq</groupId>
- <artifactId>artemis-jms-client</artifactId>
- <version>${project.version}</version>
- </dependency>
- </dependencies>
-
- <build>
- <plugins>
- <plugin>
- <groupId>org.apache.activemq</groupId>
- <artifactId>artemis-maven-plugin</artifactId>
- <executions>
- <execution>
- <id>create</id>
- <goals>
- <goal>create</goal>
- </goals>
- <configuration>
- <ignore>${noServer}</ignore>
- </configuration>
- </execution>
- <execution>
- <id>start</id>
- <goals>
- <goal>cli</goal>
- </goals>
- <configuration>
- <ignore>${noServer}</ignore>
- <spawn>true</spawn>
- <testURI>tcp://localhost:61616</testURI>
- <args>
- <param>run</param>
- </args>
- </configuration>
- </execution>
- <execution>
- <id>runClient</id>
- <goals>
- <goal>runClient</goal>
- </goals>
- <configuration>
- <clientClass>org.apache.activemq.artemis.jms.example.XAReceiveExample</clientClass>
- </configuration>
- </execution>
- <execution>
- <id>stop</id>
- <goals>
- <goal>cli</goal>
- </goals>
- <configuration>
- <ignore>${noServer}</ignore>
- <args>
- <param>stop</param>
- </args>
- </configuration>
- </execution>
- </executions>
- <dependencies>
- <dependency>
- <groupId>org.apache.activemq.examples.broker</groupId>
- <artifactId>xa-receive</artifactId>
- <version>${project.version}</version>
- </dependency>
- </dependencies>
- </plugin>
- </plugins>
- </build>
-
-</project>
http://git-wip-us.apache.org/repos/asf/activemq-artemis/blob/6b17d966/examples/broker-features/standard/xa-receive/readme.html
----------------------------------------------------------------------
diff --git a/examples/broker-features/standard/xa-receive/readme.html b/examples/broker-features/standard/xa-receive/readme.html
deleted file mode 100644
index ab6d7d7..0000000
--- a/examples/broker-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/6b17d966/examples/broker-features/standard/xa-receive/src/main/java/org/apache/activemq/artemis/jms/example/DummyXid.java
----------------------------------------------------------------------
diff --git a/examples/broker-features/standard/xa-receive/src/main/java/org/apache/activemq/artemis/jms/example/DummyXid.java b/examples/broker-features/standard/xa-receive/src/main/java/org/apache/activemq/artemis/jms/example/DummyXid.java
deleted file mode 100644
index 4dbe2f8..0000000
--- a/examples/broker-features/standard/xa-receive/src/main/java/org/apache/activemq/artemis/jms/example/DummyXid.java
+++ /dev/null
@@ -1,184 +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.
- */
-package org.apache.activemq.artemis.jms.example;
-
-import org.apache.activemq.artemis.utils.Base64;
-
-import javax.transaction.xa.Xid;
-
-public class DummyXid implements Xid {
-
- private static final long serialVersionUID = 407053232840068514L;
-
- private final byte[] branchQualifier;
-
- private final int formatId;
-
- private final byte[] globalTransactionId;
-
- private int hash;
-
- private boolean hashCalculated;
-
- // Static --------------------------------------------------------
-
- public static String toBase64String(final Xid xid) {
- return Base64.encodeBytes(DummyXid.toByteArray(xid));
- }
-
- private static byte[] toByteArray(final Xid xid) {
- byte[] branchQualifier = xid.getBranchQualifier();
- byte[] globalTransactionId = xid.getGlobalTransactionId();
- int formatId = xid.getFormatId();
-
- byte[] hashBytes = new byte[branchQualifier.length + globalTransactionId.length + 4];
- System.arraycopy(branchQualifier, 0, hashBytes, 0, branchQualifier.length);
- System.arraycopy(globalTransactionId, 0, hashBytes, branchQualifier.length, globalTransactionId.length);
- byte[] intBytes = new byte[4];
- for (int i = 0; i < 4; i++) {
- intBytes[i] = (byte) ((formatId >> i * 8) % 0xFF);
- }
- System.arraycopy(intBytes, 0, hashBytes, branchQualifier.length + globalTransactionId.length, 4);
- return hashBytes;
- }
-
- // Constructors --------------------------------------------------
-
- /**
- * Standard constructor
- *
- * @param branchQualifier
- * @param formatId
- * @param globalTransactionId
- */
- public DummyXid(final byte[] branchQualifier, final int formatId, final byte[] globalTransactionId) {
- this.branchQualifier = branchQualifier;
- this.formatId = formatId;
- this.globalTransactionId = globalTransactionId;
- }
-
- /**
- * Copy constructor
- *
- * @param other
- */
- public DummyXid(final Xid other) {
- branchQualifier = copyBytes(other.getBranchQualifier());
- formatId = other.getFormatId();
- globalTransactionId = copyBytes(other.getGlobalTransactionId());
- }
-
- // Xid implementation ------------------------------------------------------------------
-
- public byte[] getBranchQualifier() {
- return branchQualifier;
- }
-
- public int getFormatId() {
- return formatId;
- }
-
- public byte[] getGlobalTransactionId() {
- return globalTransactionId;
- }
-
- // Public -------------------------------------------------------------------------------
-
- @Override
- public int hashCode() {
- if (!hashCalculated) {
- calcHash();
- }
- return hash;
- }
-
- @Override
- public boolean equals(final Object other) {
- if (this == other) {
- return true;
- }
- if (!(other instanceof Xid)) {
- return false;
- }
- Xid xother = (Xid) other;
- if (xother.getFormatId() != formatId) {
- return false;
- }
- if (xother.getBranchQualifier().length != branchQualifier.length) {
- return false;
- }
- if (xother.getGlobalTransactionId().length != globalTransactionId.length) {
- return false;
- }
- for (int i = 0; i < branchQualifier.length; i++) {
- byte[] otherBQ = xother.getBranchQualifier();
- if (branchQualifier[i] != otherBQ[i]) {
- return false;
- }
- }
- for (int i = 0; i < globalTransactionId.length; i++) {
- byte[] otherGtx = xother.getGlobalTransactionId();
- if (globalTransactionId[i] != otherGtx[i]) {
- return false;
- }
- }
- return true;
- }
-
- @Override
- public String toString() {
- return "XidImpl (" + System.identityHashCode(this) +
- " bq:" +
- stringRep(branchQualifier) +
- " formatID:" +
- formatId +
- " gtxid:" +
- stringRep(globalTransactionId);
- }
-
- // Private -------------------------------------------------------------------------------
-
- private String stringRep(final byte[] bytes) {
- StringBuilder buff = new StringBuilder();
- for (int i = 0; i < bytes.length; i++) {
- byte b = bytes[i];
-
- buff.append(b);
-
- if (i != bytes.length - 1) {
- buff.append('.');
- }
- }
-
- return buff.toString();
- }
-
- private void calcHash() {
- byte[] hashBytes = DummyXid.toByteArray(this);
- String s = new String(hashBytes);
- hash = s.hashCode();
- hashCalculated = true;
- }
-
- private byte[] copyBytes(final byte[] other) {
- byte[] bytes = new byte[other.length];
-
- System.arraycopy(other, 0, bytes, 0, other.length);
-
- return bytes;
- }
-}
http://git-wip-us.apache.org/repos/asf/activemq-artemis/blob/6b17d966/examples/broker-features/standard/xa-receive/src/main/java/org/apache/activemq/artemis/jms/example/XAReceiveExample.java
----------------------------------------------------------------------
diff --git a/examples/broker-features/standard/xa-receive/src/main/java/org/apache/activemq/artemis/jms/example/XAReceiveExample.java b/examples/broker-features/standard/xa-receive/src/main/java/org/apache/activemq/artemis/jms/example/XAReceiveExample.java
deleted file mode 100644
index 4c4448d..0000000
--- a/examples/broker-features/standard/xa-receive/src/main/java/org/apache/activemq/artemis/jms/example/XAReceiveExample.java
+++ /dev/null
@@ -1,145 +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.
- */
-package org.apache.activemq.artemis.jms.example;
-
-import javax.jms.MessageConsumer;
-import javax.jms.MessageProducer;
-import javax.jms.Queue;
-import javax.jms.Session;
-import javax.jms.TextMessage;
-import javax.jms.XAConnection;
-import javax.jms.XAConnectionFactory;
-import javax.jms.XASession;
-import javax.naming.InitialContext;
-import javax.transaction.xa.XAResource;
-import javax.transaction.xa.Xid;
-import java.nio.charset.StandardCharsets;
-
-import org.apache.activemq.artemis.utils.UUIDGenerator;
-
-/**
- * A simple JMS example showing the usage of XA support in JMS.
- */
-public class XAReceiveExample {
-
- public static void main(final String[] args) throws Exception {
- XAConnection connection = null;
- InitialContext initialContext = null;
- try {
- // Step 1. Create an initial context to perform the JNDI lookup.
- initialContext = new InitialContext();
-
- // Step 2. Lookup on the queue
- Queue queue = (Queue) initialContext.lookup("queue/exampleQueue");
-
- // Step 3. Perform a lookup on the XA Connection Factory
- XAConnectionFactory cf = (XAConnectionFactory) initialContext.lookup("XAConnectionFactory");
-
- // Step 4.Create a JMS XAConnection
- connection = cf.createXAConnection();
-
- // Step 5. Start the connection
- connection.start();
-
- // Step 6. Create a JMS XASession
- XASession xaSession = connection.createXASession();
-
- // Step 7. Create a normal session
- Session normalSession = connection.createSession(false, Session.AUTO_ACKNOWLEDGE);
-
- // Step 8. Create a normal Message Producer
- MessageProducer normalProducer = normalSession.createProducer(queue);
-
- // Step 9. Get the JMS Session
- Session session = xaSession.getSession();
-
- // Step 10. Create a message consumer
- MessageConsumer xaConsumer = session.createConsumer(queue);
-
- // Step 11. Create two Text Messages
- TextMessage helloMessage = session.createTextMessage("hello");
- TextMessage worldMessage = session.createTextMessage("world");
-
- // Step 12. create a transaction
- Xid xid1 = new DummyXid("xa-example1".getBytes(StandardCharsets.US_ASCII), 1, UUIDGenerator.getInstance().generateStringUUID().getBytes());
-
- // Step 13. Get the JMS XAResource
- XAResource xaRes = xaSession.getXAResource();
-
- // Step 14. Begin the Transaction work
- xaRes.start(xid1, XAResource.TMNOFLAGS);
-
- // Step 15. Send two messages.
- normalProducer.send(helloMessage);
- normalProducer.send(worldMessage);
-
- // Step 16. Receive the message
- TextMessage rm1 = (TextMessage) xaConsumer.receive();
- System.out.println("Message received: " + rm1.getText());
- TextMessage rm2 = (TextMessage) xaConsumer.receive();
- System.out.println("Message received: " + rm2.getText());
-
- // Step 17. Stop the work
- xaRes.end(xid1, XAResource.TMSUCCESS);
-
- // Step 18. Prepare
- xaRes.prepare(xid1);
-
- // Step 19. Roll back the transaction
- xaRes.rollback(xid1);
-
- // Step 20. Create another transaction
- Xid xid2 = new DummyXid("xa-example2".getBytes(), 1, UUIDGenerator.getInstance().generateStringUUID().getBytes());
-
- // Step 21. Start the transaction
- xaRes.start(xid2, XAResource.TMNOFLAGS);
-
- // Step 22. receive those messages again
- rm1 = (TextMessage) xaConsumer.receive();
- System.out.println("Message received again: " + rm1.getText());
- rm2 = (TextMessage) xaConsumer.receive();
- System.out.println("Message received again: " + rm2.getText());
-
- // Step 23. Stop the work
- xaRes.end(xid2, XAResource.TMSUCCESS);
-
- // Step 24. Prepare
- xaRes.prepare(xid2);
-
- // Step 25. Commit!
- xaRes.commit(xid2, false);
-
- // Step 26. Check no more messages are received.
- TextMessage rm3 = (TextMessage) xaConsumer.receive(2000);
- if (rm3 == null) {
- System.out.println("No message received after commit.");
- }
- else {
- throw new IllegalStateException();
- }
- }
- finally {
- // Step 27. Be sure to close our JMS resources!
- if (initialContext != null) {
- initialContext.close();
- }
- if (connection != null) {
- connection.close();
- }
- }
- }
-}