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/07/29 23:22:10 UTC
[04/24] activemq-artemis git commit: Continuing work on ARTEMIS-178
http://git-wip-us.apache.org/repos/asf/activemq-artemis/blob/54d0d2b4/examples/jms/replicated-multiple-failover/src/main/resources/activemq/server2/artemis-users.properties
----------------------------------------------------------------------
diff --git a/examples/jms/replicated-multiple-failover/src/main/resources/activemq/server2/artemis-users.properties b/examples/jms/replicated-multiple-failover/src/main/resources/activemq/server2/artemis-users.properties
deleted file mode 100644
index 4e2d44c..0000000
--- a/examples/jms/replicated-multiple-failover/src/main/resources/activemq/server2/artemis-users.properties
+++ /dev/null
@@ -1,17 +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.
-## ---------------------------------------------------------------------------
-guest=guest
\ No newline at end of file
http://git-wip-us.apache.org/repos/asf/activemq-artemis/blob/54d0d2b4/examples/jms/replicated-multiple-failover/src/main/resources/activemq/server2/broker.xml
----------------------------------------------------------------------
diff --git a/examples/jms/replicated-multiple-failover/src/main/resources/activemq/server2/broker.xml b/examples/jms/replicated-multiple-failover/src/main/resources/activemq/server2/broker.xml
index 804f63f..fbbd45f 100644
--- a/examples/jms/replicated-multiple-failover/src/main/resources/activemq/server2/broker.xml
+++ b/examples/jms/replicated-multiple-failover/src/main/resources/activemq/server2/broker.xml
@@ -29,13 +29,13 @@ under the License.
<core xmlns="urn:activemq:core">
- <bindings-directory>${data.dir}/server2/data/messaging/bindings</bindings-directory>
+ <bindings-directory>${data.dir:./data}/bindings</bindings-directory>
- <journal-directory>${data.dir}/server2/data/messaging/journal</journal-directory>
+ <journal-directory>${data.dir:./data}/journal</journal-directory>
- <large-messages-directory>${data.dir}/server2/data/messaging/largemessages</large-messages-directory>
+ <large-messages-directory>${data.dir:./data}/largemessages</large-messages-directory>
- <paging-directory>${data.dir}/server2/data/messaging/paging</paging-directory>
+ <paging-directory>${data.dir:./data}/paging</paging-directory>
<ha-policy>
<replication>
@@ -43,6 +43,7 @@ under the License.
</replication>
</ha-policy>
+ <!-- Connectors -->
<connectors>
<connector name="netty-connector">tcp://localhost:61618</connector>
</connectors>
http://git-wip-us.apache.org/repos/asf/activemq-artemis/blob/54d0d2b4/examples/jms/replicated-transaction-failover/pom.xml
----------------------------------------------------------------------
diff --git a/examples/jms/replicated-transaction-failover/pom.xml b/examples/jms/replicated-transaction-failover/pom.xml
index b6def66..2c10c66 100644
--- a/examples/jms/replicated-transaction-failover/pom.xml
+++ b/examples/jms/replicated-transaction-failover/pom.xml
@@ -37,8 +37,8 @@ under the License.
<dependencies>
<dependency>
- <groupId>org.apache.activemq.examples.jms</groupId>
- <artifactId>common</artifactId>
+ <groupId>org.apache.activemq</groupId>
+ <artifactId>artemis-cli</artifactId>
<version>${project.version}</version>
</dependency>
<dependency>
@@ -57,7 +57,7 @@ under the License.
<artifactId>artemis-maven-plugin</artifactId>
<executions>
<execution>
- <id>create</id>
+ <id>create0</id>
<goals>
<goal>create</goal>
</goals>
@@ -68,7 +68,7 @@ under the License.
</configuration>
</execution>
<execution>
- <id>create2</id>
+ <id>create1</id>
<goals>
<goal>create</goal>
</goals>
@@ -104,5 +104,4 @@ under the License.
</build>
</profile>
</profiles>
-
</project>
http://git-wip-us.apache.org/repos/asf/activemq-artemis/blob/54d0d2b4/examples/jms/replicated-transaction-failover/src/main/java/org/apache/activemq/artemis/jms/example/ReplicatedTransactionFailoverExample.java
----------------------------------------------------------------------
diff --git a/examples/jms/replicated-transaction-failover/src/main/java/org/apache/activemq/artemis/jms/example/ReplicatedTransactionFailoverExample.java b/examples/jms/replicated-transaction-failover/src/main/java/org/apache/activemq/artemis/jms/example/ReplicatedTransactionFailoverExample.java
index f202e2e..dcc89d2 100644
--- a/examples/jms/replicated-transaction-failover/src/main/java/org/apache/activemq/artemis/jms/example/ReplicatedTransactionFailoverExample.java
+++ b/examples/jms/replicated-transaction-failover/src/main/java/org/apache/activemq/artemis/jms/example/ReplicatedTransactionFailoverExample.java
@@ -16,6 +16,9 @@
*/
package org.apache.activemq.artemis.jms.example;
+import org.apache.activemq.artemis.api.core.Message;
+import org.apache.activemq.artemis.util.ServerUtil;
+
import javax.jms.Connection;
import javax.jms.ConnectionFactory;
import javax.jms.MessageConsumer;
@@ -26,29 +29,23 @@ import javax.jms.TextMessage;
import javax.jms.TransactionRolledBackException;
import javax.naming.InitialContext;
-import org.apache.activemq.artemis.api.core.Message;
-import org.apache.activemq.artemis.common.example.ActiveMQExample;
-
/**
* A simple example that demonstrates failover of the JMS connection from one node to another
* when the live server crashes using a JMS <em>transacted</em> session and replication.
*/
-public class ReplicatedTransactionFailoverExample extends ActiveMQExample
+public class ReplicatedTransactionFailoverExample
{
+ private static Process server0;
+
+ private static Process server1;
// You need to guarantee uniqueIDs when using duplicate detection
// It needs to be unique even after a restart
// as these IDs are stored on the journal for control
// We recommend some sort of UUID, but for this example the Current Time as string would be enough
- String uniqueID = Long.toString(System.currentTimeMillis());
-
- public static void main(final String[] args)
- {
- new ReplicatedTransactionFailoverExample().run(args);
- }
+ private static String uniqueID = Long.toString(System.currentTimeMillis());
- @Override
- public boolean runExample() throws Exception
+ public static void main(final String[] args) throws Exception
{
final int numMessages = 10;
@@ -58,6 +55,9 @@ public class ReplicatedTransactionFailoverExample extends ActiveMQExample
try
{
+ server0 = ServerUtil.startServer(args[0], ReplicatedTransactionFailoverExample.class.getSimpleName() + "0", 0, 5000);
+ server1 = ServerUtil.startServer(args[1], ReplicatedTransactionFailoverExample.class.getSimpleName() + "1", 1, 5000);
+
// Step 1. Get an initial context for looking up JNDI from the server #1
initialContext = new InitialContext();
@@ -108,9 +108,7 @@ public class ReplicatedTransactionFailoverExample extends ActiveMQExample
if (message0 == null)
{
- System.err.println("Example failed - message wasn't received");
-
- return false;
+ throw new IllegalStateException("Example failed - message wasn't received");
}
System.out.println("Got message: " + message0.getText());
@@ -119,8 +117,6 @@ public class ReplicatedTransactionFailoverExample extends ActiveMQExample
session.commit();
System.out.println("Other message on the server? " + consumer.receive(5000));
-
- return true;
}
finally
{
@@ -135,10 +131,13 @@ public class ReplicatedTransactionFailoverExample extends ActiveMQExample
{
initialContext.close();
}
+
+ ServerUtil.killServer(server0);
+ ServerUtil.killServer(server1);
}
}
- private void sendMessages(final Session session,
+ private static void sendMessages(final Session session,
final MessageProducer producer,
final int numMessages,
final boolean killServer) throws Exception
@@ -160,10 +159,7 @@ public class ReplicatedTransactionFailoverExample extends ActiveMQExample
if (killServer)
{
- Thread.sleep(5000);
-
- killServer(0);
-
+ ServerUtil.killServer(server0);
}
// We send the remaining half of messages
http://git-wip-us.apache.org/repos/asf/activemq-artemis/blob/54d0d2b4/examples/jms/replicated-transaction-failover/src/main/resources/activemq/server0/artemis-roles.properties
----------------------------------------------------------------------
diff --git a/examples/jms/replicated-transaction-failover/src/main/resources/activemq/server0/artemis-roles.properties b/examples/jms/replicated-transaction-failover/src/main/resources/activemq/server0/artemis-roles.properties
deleted file mode 100644
index 4e2d44c..0000000
--- a/examples/jms/replicated-transaction-failover/src/main/resources/activemq/server0/artemis-roles.properties
+++ /dev/null
@@ -1,17 +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.
-## ---------------------------------------------------------------------------
-guest=guest
\ No newline at end of file
http://git-wip-us.apache.org/repos/asf/activemq-artemis/blob/54d0d2b4/examples/jms/replicated-transaction-failover/src/main/resources/activemq/server0/artemis-users.properties
----------------------------------------------------------------------
diff --git a/examples/jms/replicated-transaction-failover/src/main/resources/activemq/server0/artemis-users.properties b/examples/jms/replicated-transaction-failover/src/main/resources/activemq/server0/artemis-users.properties
deleted file mode 100644
index 4e2d44c..0000000
--- a/examples/jms/replicated-transaction-failover/src/main/resources/activemq/server0/artemis-users.properties
+++ /dev/null
@@ -1,17 +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.
-## ---------------------------------------------------------------------------
-guest=guest
\ No newline at end of file
http://git-wip-us.apache.org/repos/asf/activemq-artemis/blob/54d0d2b4/examples/jms/replicated-transaction-failover/src/main/resources/activemq/server0/broker.xml
----------------------------------------------------------------------
diff --git a/examples/jms/replicated-transaction-failover/src/main/resources/activemq/server0/broker.xml b/examples/jms/replicated-transaction-failover/src/main/resources/activemq/server0/broker.xml
index 597f828..9233f17 100644
--- a/examples/jms/replicated-transaction-failover/src/main/resources/activemq/server0/broker.xml
+++ b/examples/jms/replicated-transaction-failover/src/main/resources/activemq/server0/broker.xml
@@ -29,13 +29,13 @@ under the License.
<core xmlns="urn:activemq:core">
- <bindings-directory>${data.dir}/server0/data/messaging/bindings</bindings-directory>
+ <bindings-directory>${data.dir:./data}/bindings</bindings-directory>
- <journal-directory>${data.dir}/server0/data/messaging/journal</journal-directory>
+ <journal-directory>${data.dir:./data}/journal</journal-directory>
- <large-messages-directory>${data.dir}/server0/data/messaging/largemessages</large-messages-directory>
+ <large-messages-directory>${data.dir:./data}/largemessages</large-messages-directory>
- <paging-directory>${data.dir}/server0/data/messaging/paging</paging-directory>
+ <paging-directory>${data.dir:./data}/paging</paging-directory>
<ha-policy>
<replication>
http://git-wip-us.apache.org/repos/asf/activemq-artemis/blob/54d0d2b4/examples/jms/replicated-transaction-failover/src/main/resources/activemq/server1/artemis-roles.properties
----------------------------------------------------------------------
diff --git a/examples/jms/replicated-transaction-failover/src/main/resources/activemq/server1/artemis-roles.properties b/examples/jms/replicated-transaction-failover/src/main/resources/activemq/server1/artemis-roles.properties
deleted file mode 100644
index 4e2d44c..0000000
--- a/examples/jms/replicated-transaction-failover/src/main/resources/activemq/server1/artemis-roles.properties
+++ /dev/null
@@ -1,17 +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.
-## ---------------------------------------------------------------------------
-guest=guest
\ No newline at end of file
http://git-wip-us.apache.org/repos/asf/activemq-artemis/blob/54d0d2b4/examples/jms/replicated-transaction-failover/src/main/resources/activemq/server1/artemis-users.properties
----------------------------------------------------------------------
diff --git a/examples/jms/replicated-transaction-failover/src/main/resources/activemq/server1/artemis-users.properties b/examples/jms/replicated-transaction-failover/src/main/resources/activemq/server1/artemis-users.properties
deleted file mode 100644
index 4e2d44c..0000000
--- a/examples/jms/replicated-transaction-failover/src/main/resources/activemq/server1/artemis-users.properties
+++ /dev/null
@@ -1,17 +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.
-## ---------------------------------------------------------------------------
-guest=guest
\ No newline at end of file
http://git-wip-us.apache.org/repos/asf/activemq-artemis/blob/54d0d2b4/examples/jms/replicated-transaction-failover/src/main/resources/activemq/server1/broker.xml
----------------------------------------------------------------------
diff --git a/examples/jms/replicated-transaction-failover/src/main/resources/activemq/server1/broker.xml b/examples/jms/replicated-transaction-failover/src/main/resources/activemq/server1/broker.xml
index cdefc88..848525e 100644
--- a/examples/jms/replicated-transaction-failover/src/main/resources/activemq/server1/broker.xml
+++ b/examples/jms/replicated-transaction-failover/src/main/resources/activemq/server1/broker.xml
@@ -29,13 +29,13 @@ under the License.
<core xmlns="urn:activemq:core">
- <bindings-directory>${data.dir}/server1/data/messaging/bindings</bindings-directory>
+ <bindings-directory>${data.dir:./data}/bindings</bindings-directory>
- <journal-directory>${data.dir}/server1/data/messaging/journal</journal-directory>
+ <journal-directory>${data.dir:./data}/journal</journal-directory>
- <large-messages-directory>${data.dir}/server1/data/messaging/largemessages</large-messages-directory>
+ <large-messages-directory>${data.dir:./data}/largemessages</large-messages-directory>
- <paging-directory>${data.dir}/server1/data/messaging/paging</paging-directory>
+ <paging-directory>${data.dir:./data}/paging</paging-directory>
<ha-policy>
<replication>
http://git-wip-us.apache.org/repos/asf/activemq-artemis/blob/54d0d2b4/examples/jms/request-reply/pom.xml
----------------------------------------------------------------------
diff --git a/examples/jms/request-reply/pom.xml b/examples/jms/request-reply/pom.xml
index 5880d9d..e8849d8 100644
--- a/examples/jms/request-reply/pom.xml
+++ b/examples/jms/request-reply/pom.xml
@@ -37,11 +37,6 @@ under the License.
<dependencies>
<dependency>
- <groupId>org.apache.activemq.examples.jms</groupId>
- <artifactId>common</artifactId>
- <version>${project.version}</version>
- </dependency>
- <dependency>
<groupId>org.apache.geronimo.specs</groupId>
<artifactId>geronimo-jms_2.0_spec</artifactId>
</dependency>
@@ -61,9 +56,18 @@ under the License.
<goals>
<goal>create</goal>
</goals>
+ </execution>
+ <execution>
+ <id>start</id>
+ <goals>
+ <goal>cli</goal>
+ </goals>
<configuration>
- <instance>${basedir}/target/server0</instance>
- <configuration>${basedir}/target/classes/activemq/server0</configuration>
+ <spawn>true</spawn>
+ <testURI>tcp://localhost:61616</testURI>
+ <args>
+ <param>run</param>
+ </args>
</configuration>
</execution>
<execution>
@@ -73,8 +77,16 @@ under the License.
</goals>
<configuration>
<clientClass>org.apache.activemq.artemis.jms.example.RequestReplyExample</clientClass>
+ </configuration>
+ </execution>
+ <execution>
+ <id>stop</id>
+ <goals>
+ <goal>cli</goal>
+ </goals>
+ <configuration>
<args>
- <param>${basedir}/target/server0</param>
+ <param>stop</param>
</args>
</configuration>
</execution>
@@ -91,5 +103,4 @@ under the License.
</build>
</profile>
</profiles>
-
</project>
http://git-wip-us.apache.org/repos/asf/activemq-artemis/blob/54d0d2b4/examples/jms/request-reply/src/main/java/org/apache/activemq/artemis/jms/example/RequestReplyExample.java
----------------------------------------------------------------------
diff --git a/examples/jms/request-reply/src/main/java/org/apache/activemq/artemis/jms/example/RequestReplyExample.java b/examples/jms/request-reply/src/main/java/org/apache/activemq/artemis/jms/example/RequestReplyExample.java
index 751f2da..7e9093f 100644
--- a/examples/jms/request-reply/src/main/java/org/apache/activemq/artemis/jms/example/RequestReplyExample.java
+++ b/examples/jms/request-reply/src/main/java/org/apache/activemq/artemis/jms/example/RequestReplyExample.java
@@ -33,8 +33,6 @@ import javax.jms.TemporaryQueue;
import javax.jms.TextMessage;
import javax.naming.InitialContext;
-import org.apache.activemq.artemis.common.example.ActiveMQExample;
-
/**
* A simple JMS example that shows how to use Request/Replay style messaging.
*
@@ -43,18 +41,11 @@ import org.apache.activemq.artemis.common.example.ActiveMQExample;
*
* Or better still use the correlation id, and just store the requests in a map, then you don't need a temporary queue at all
*/
-public class RequestReplyExample extends ActiveMQExample
+public class RequestReplyExample
{
- private final Map<String, TextMessage> requestMap = new HashMap<String, TextMessage>();
-
- public static void main(final String[] args)
- {
- new RequestReplyExample().run(args);
- }
-
- @Override
- public boolean runExample() throws Exception
+ public static void main(final String[] args) throws Exception
{
+ final Map<String, TextMessage> requestMap = new HashMap<String, TextMessage>();
Connection connection = null;
InitialContext initialContext = null;
@@ -129,8 +120,6 @@ public class RequestReplyExample extends ActiveMQExample
// Step 19. Shutdown the request server
server.shutdown();
-
- return true;
}
finally
{
@@ -146,79 +135,78 @@ public class RequestReplyExample extends ActiveMQExample
}
}
}
+}
- private class SimpleRequestServer implements MessageListener
- {
- private Connection connection;
+class SimpleRequestServer implements MessageListener
+{
+ private Connection connection;
- private Session session;
+ private Session session;
- MessageProducer replyProducer;
+ MessageProducer replyProducer;
- MessageConsumer requestConsumer;
+ MessageConsumer requestConsumer;
- public void start() throws Exception
- {
- // Get an initial context to perform the JNDI lookup.
- InitialContext initialContext = new InitialContext();
+ public void start() throws Exception
+ {
+ // Get an initial context to perform the JNDI lookup.
+ InitialContext initialContext = new InitialContext();
- // Lookup the queue to receive the request message
- Queue requestQueue = (Queue)initialContext.lookup("queue/exampleQueue");
+ // Lookup the queue to receive the request message
+ Queue requestQueue = (Queue)initialContext.lookup("queue/exampleQueue");
- // Lookup for the Connection Factory
- ConnectionFactory cfact = (ConnectionFactory)initialContext.lookup("ConnectionFactory");
+ // Lookup for the Connection Factory
+ ConnectionFactory cfact = (ConnectionFactory)initialContext.lookup("ConnectionFactory");
- // Create a connection
- connection = cfact.createConnection();
+ // Create a connection
+ connection = cfact.createConnection();
- // Start the connection;
- connection.start();
+ // Start the connection;
+ connection.start();
- // Create a session
- session = connection.createSession(false, Session.AUTO_ACKNOWLEDGE);
+ // Create a session
+ session = connection.createSession(false, Session.AUTO_ACKNOWLEDGE);
- // Create a producer to send the reply message
- replyProducer = session.createProducer(null);
+ // Create a producer to send the reply message
+ replyProducer = session.createProducer(null);
- // Create the request comsumer
- requestConsumer = session.createConsumer(requestQueue);
+ // Create the request comsumer
+ requestConsumer = session.createConsumer(requestQueue);
- // register the listener
- requestConsumer.setMessageListener(this);
- }
+ // register the listener
+ requestConsumer.setMessageListener(this);
+ }
- public void onMessage(final Message request)
+ public void onMessage(final Message request)
+ {
+ try
{
- try
- {
- System.out.println("Received request message: " + ((TextMessage)request).getText());
+ System.out.println("Received request message: " + ((TextMessage)request).getText());
- // Extract the ReplyTo destination
- Destination replyDestination = request.getJMSReplyTo();
+ // Extract the ReplyTo destination
+ Destination replyDestination = request.getJMSReplyTo();
- System.out.println("Reply to queue: " + replyDestination);
+ System.out.println("Reply to queue: " + replyDestination);
- // Create the reply message
- TextMessage replyMessage = session.createTextMessage("A reply message");
+ // Create the reply message
+ TextMessage replyMessage = session.createTextMessage("A reply message");
- // Set the CorrelationID, using message id.
- replyMessage.setJMSCorrelationID(request.getJMSMessageID());
+ // Set the CorrelationID, using message id.
+ replyMessage.setJMSCorrelationID(request.getJMSMessageID());
- // Send out the reply message
- replyProducer.send(replyDestination, replyMessage);
+ // Send out the reply message
+ replyProducer.send(replyDestination, replyMessage);
- System.out.println("Reply sent");
- }
- catch (JMSException e)
- {
- e.printStackTrace();
- }
+ System.out.println("Reply sent");
}
-
- public void shutdown() throws JMSException
+ catch (JMSException e)
{
- connection.close();
+ e.printStackTrace();
}
}
+ public void shutdown() throws JMSException
+ {
+ connection.close();
+ }
}
http://git-wip-us.apache.org/repos/asf/activemq-artemis/blob/54d0d2b4/examples/jms/scale-down/pom.xml
----------------------------------------------------------------------
diff --git a/examples/jms/scale-down/pom.xml b/examples/jms/scale-down/pom.xml
index 5a1cd36..596273b 100644
--- a/examples/jms/scale-down/pom.xml
+++ b/examples/jms/scale-down/pom.xml
@@ -37,8 +37,8 @@ under the License.
<dependencies>
<dependency>
- <groupId>org.apache.activemq.examples.jms</groupId>
- <artifactId>common</artifactId>
+ <groupId>org.apache.activemq</groupId>
+ <artifactId>artemis-cli</artifactId>
<version>${project.version}</version>
</dependency>
<dependency>
@@ -57,7 +57,7 @@ under the License.
<artifactId>artemis-maven-plugin</artifactId>
<executions>
<execution>
- <id>create</id>
+ <id>create0</id>
<goals>
<goal>create</goal>
</goals>
@@ -68,7 +68,7 @@ under the License.
</configuration>
</execution>
<execution>
- <id>create2</id>
+ <id>create1</id>
<goals>
<goal>create</goal>
</goals>
http://git-wip-us.apache.org/repos/asf/activemq-artemis/blob/54d0d2b4/examples/jms/scale-down/src/main/java/org/apache/activemq/artemis/jms/example/ScaleDownExample.java
----------------------------------------------------------------------
diff --git a/examples/jms/scale-down/src/main/java/org/apache/activemq/artemis/jms/example/ScaleDownExample.java b/examples/jms/scale-down/src/main/java/org/apache/activemq/artemis/jms/example/ScaleDownExample.java
index f370491..73adf33 100644
--- a/examples/jms/scale-down/src/main/java/org/apache/activemq/artemis/jms/example/ScaleDownExample.java
+++ b/examples/jms/scale-down/src/main/java/org/apache/activemq/artemis/jms/example/ScaleDownExample.java
@@ -16,6 +16,8 @@
*/
package org.apache.activemq.artemis.jms.example;
+import org.apache.activemq.artemis.util.ServerUtil;
+
import javax.jms.Connection;
import javax.jms.ConnectionFactory;
import javax.jms.MessageConsumer;
@@ -26,21 +28,17 @@ import javax.jms.TextMessage;
import javax.naming.InitialContext;
import java.util.Hashtable;
-import org.apache.activemq.artemis.common.example.ActiveMQExample;
-
/**
* A simple example that demonstrates a colocated server
*
*/
-public class ScaleDownExample extends ActiveMQExample
+public class ScaleDownExample
{
- public static void main(final String[] args)
- {
- new ScaleDownExample().run(args);
- }
+ private static Process server0;
+
+ private static Process server1;
- @Override
- public boolean runExample() throws Exception
+ public static void main(final String[] args) throws Exception
{
final int numMessages = 30;
@@ -52,16 +50,19 @@ public class ScaleDownExample extends ActiveMQExample
try
{
+ server0 = ServerUtil.startServer(args[0], ScaleDownExample.class.getSimpleName() + "0", 0, 5000);
+ server1 = ServerUtil.startServer(args[1], ScaleDownExample.class.getSimpleName() + "1", 1, 5000);
+
// Step 1. Get an initial context for looking up JNDI for both servers
Hashtable<String, Object> properties = new Hashtable<String, Object>();
properties.put("java.naming.factory.initial", "org.apache.activemq.artemis.jndi.ActiveMQInitialContextFactory");
- properties.put("connectionFactory.ConnectionFactory", DEFAULT_TCP1 + "?ha=true&retryInterval=1000&retryIntervalMultiplier=1.0&reconnectAttempts=-1");
+ properties.put("connectionFactory.ConnectionFactory", "tcp://localhost:61616?ha=true&retryInterval=1000&retryIntervalMultiplier=1.0&reconnectAttempts=-1");
properties.put("queue.queue/exampleQueue", "exampleQueue");
initialContext = new InitialContext(properties);
properties = new Hashtable<String, Object>();
properties.put("java.naming.factory.initial", "org.apache.activemq.artemis.jndi.ActiveMQInitialContextFactory");
- properties.put("connectionFactory.ConnectionFactory", DEFAULT_TCP2 + "?ha=true&retryInterval=1000&retryIntervalMultiplier=1.0&reconnectAttempts=-1");
+ properties.put("connectionFactory.ConnectionFactory", "tcp://localhost:61617?ha=true&retryInterval=1000&retryIntervalMultiplier=1.0&reconnectAttempts=-1");
initialContext1 = new InitialContext(properties);
// Step 2. Look up the JMS resources from JNDI
@@ -92,12 +93,8 @@ public class ScaleDownExample extends ActiveMQExample
System.out.println("Sent message: " + message.getText());
}
- // Step 7. Crash server #1, the live server, and wait a little while to make sure
- // it has really crashed
- Thread.sleep(5000);
- killServer(1);
- Thread.sleep(5000);
-
+ // Step 7. Crash server #1
+ ServerUtil.killServer(server1);
// Step 8. start the connection ready to receive messages
connection.start();
@@ -114,8 +111,6 @@ public class ScaleDownExample extends ActiveMQExample
System.out.println("Got message: " + message0.getText());
}
message0.acknowledge();
-
- return true;
}
finally
{
@@ -139,7 +134,9 @@ public class ScaleDownExample extends ActiveMQExample
{
initialContext1.close();
}
+
+ ServerUtil.killServer(server0);
+ ServerUtil.killServer(server1);
}
}
-
}
http://git-wip-us.apache.org/repos/asf/activemq-artemis/blob/54d0d2b4/examples/jms/scale-down/src/main/resources/activemq/server0/artemis-roles.properties
----------------------------------------------------------------------
diff --git a/examples/jms/scale-down/src/main/resources/activemq/server0/artemis-roles.properties b/examples/jms/scale-down/src/main/resources/activemq/server0/artemis-roles.properties
deleted file mode 100644
index 4e2d44c..0000000
--- a/examples/jms/scale-down/src/main/resources/activemq/server0/artemis-roles.properties
+++ /dev/null
@@ -1,17 +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.
-## ---------------------------------------------------------------------------
-guest=guest
\ No newline at end of file
http://git-wip-us.apache.org/repos/asf/activemq-artemis/blob/54d0d2b4/examples/jms/scale-down/src/main/resources/activemq/server0/artemis-users.properties
----------------------------------------------------------------------
diff --git a/examples/jms/scale-down/src/main/resources/activemq/server0/artemis-users.properties b/examples/jms/scale-down/src/main/resources/activemq/server0/artemis-users.properties
deleted file mode 100644
index 4e2d44c..0000000
--- a/examples/jms/scale-down/src/main/resources/activemq/server0/artemis-users.properties
+++ /dev/null
@@ -1,17 +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.
-## ---------------------------------------------------------------------------
-guest=guest
\ No newline at end of file
http://git-wip-us.apache.org/repos/asf/activemq-artemis/blob/54d0d2b4/examples/jms/scale-down/src/main/resources/activemq/server0/broker.xml
----------------------------------------------------------------------
diff --git a/examples/jms/scale-down/src/main/resources/activemq/server0/broker.xml b/examples/jms/scale-down/src/main/resources/activemq/server0/broker.xml
index b2e1887..1a08c9d 100644
--- a/examples/jms/scale-down/src/main/resources/activemq/server0/broker.xml
+++ b/examples/jms/scale-down/src/main/resources/activemq/server0/broker.xml
@@ -29,14 +29,13 @@ under the License.
<core xmlns="urn:activemq:core">
+ <bindings-directory>${data.dir:./data}/bindings</bindings-directory>
- <bindings-directory>${data.dir:../data}/bindings</bindings-directory>
+ <journal-directory>${data.dir:./data}/journal</journal-directory>
- <journal-directory>${data.dir:../data}/journal</journal-directory>
+ <large-messages-directory>${data.dir:./data}/largemessages</large-messages-directory>
- <large-messages-directory>${data.dir:../data}/largemessages</large-messages-directory>
-
- <paging-directory>${data.dir:../data}/paging</paging-directory>
+ <paging-directory>${data.dir:./data}/paging</paging-directory>
<!-- Connectors -->
<connectors>
http://git-wip-us.apache.org/repos/asf/activemq-artemis/blob/54d0d2b4/examples/jms/scale-down/src/main/resources/activemq/server1/artemis-roles.properties
----------------------------------------------------------------------
diff --git a/examples/jms/scale-down/src/main/resources/activemq/server1/artemis-roles.properties b/examples/jms/scale-down/src/main/resources/activemq/server1/artemis-roles.properties
deleted file mode 100644
index 4e2d44c..0000000
--- a/examples/jms/scale-down/src/main/resources/activemq/server1/artemis-roles.properties
+++ /dev/null
@@ -1,17 +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.
-## ---------------------------------------------------------------------------
-guest=guest
\ No newline at end of file
http://git-wip-us.apache.org/repos/asf/activemq-artemis/blob/54d0d2b4/examples/jms/scale-down/src/main/resources/activemq/server1/artemis-users.properties
----------------------------------------------------------------------
diff --git a/examples/jms/scale-down/src/main/resources/activemq/server1/artemis-users.properties b/examples/jms/scale-down/src/main/resources/activemq/server1/artemis-users.properties
deleted file mode 100644
index 4e2d44c..0000000
--- a/examples/jms/scale-down/src/main/resources/activemq/server1/artemis-users.properties
+++ /dev/null
@@ -1,17 +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.
-## ---------------------------------------------------------------------------
-guest=guest
\ No newline at end of file
http://git-wip-us.apache.org/repos/asf/activemq-artemis/blob/54d0d2b4/examples/jms/scale-down/src/main/resources/activemq/server1/broker.xml
----------------------------------------------------------------------
diff --git a/examples/jms/scale-down/src/main/resources/activemq/server1/broker.xml b/examples/jms/scale-down/src/main/resources/activemq/server1/broker.xml
index e198399..87dd4aa 100644
--- a/examples/jms/scale-down/src/main/resources/activemq/server1/broker.xml
+++ b/examples/jms/scale-down/src/main/resources/activemq/server1/broker.xml
@@ -29,14 +29,13 @@ under the License.
<core xmlns="urn:activemq:core">
+ <bindings-directory>${data.dir:./data}/bindings</bindings-directory>
- <bindings-directory>${data.dir:../data}/bindings</bindings-directory>
+ <journal-directory>${data.dir:./data}/journal</journal-directory>
- <journal-directory>${data.dir:../data}/journal</journal-directory>
+ <large-messages-directory>${data.dir:./data}/largemessages</large-messages-directory>
- <large-messages-directory>${data.dir:../data}/largemessages</large-messages-directory>
-
- <paging-directory>${data.dir:../data}/paging</paging-directory>
+ <paging-directory>${data.dir:./data}/paging</paging-directory>
<!-- Connectors -->
<connectors>
http://git-wip-us.apache.org/repos/asf/activemq-artemis/blob/54d0d2b4/examples/jms/scheduled-message/pom.xml
----------------------------------------------------------------------
diff --git a/examples/jms/scheduled-message/pom.xml b/examples/jms/scheduled-message/pom.xml
index 676e557..cfda2ac 100644
--- a/examples/jms/scheduled-message/pom.xml
+++ b/examples/jms/scheduled-message/pom.xml
@@ -37,8 +37,8 @@ under the License.
<dependencies>
<dependency>
- <groupId>org.apache.activemq.examples.jms</groupId>
- <artifactId>common</artifactId>
+ <groupId>org.apache.activemq</groupId>
+ <artifactId>artemis-core-client</artifactId>
<version>${project.version}</version>
</dependency>
<dependency>
@@ -61,9 +61,18 @@ under the License.
<goals>
<goal>create</goal>
</goals>
+ </execution>
+ <execution>
+ <id>start</id>
+ <goals>
+ <goal>cli</goal>
+ </goals>
<configuration>
- <instance>${basedir}/target/server0</instance>
- <configuration>${basedir}/target/classes/activemq/server0</configuration>
+ <spawn>true</spawn>
+ <testURI>tcp://localhost:61616</testURI>
+ <args>
+ <param>run</param>
+ </args>
</configuration>
</execution>
<execution>
@@ -73,8 +82,16 @@ under the License.
</goals>
<configuration>
<clientClass>org.apache.activemq.artemis.jms.example.ScheduledMessageExample</clientClass>
+ </configuration>
+ </execution>
+ <execution>
+ <id>stop</id>
+ <goals>
+ <goal>cli</goal>
+ </goals>
+ <configuration>
<args>
- <param>${basedir}/target/server0</param>
+ <param>stop</param>
</args>
</configuration>
</execution>
http://git-wip-us.apache.org/repos/asf/activemq-artemis/blob/54d0d2b4/examples/jms/scheduled-message/src/main/java/org/apache/activemq/artemis/jms/example/ScheduledMessageExample.java
----------------------------------------------------------------------
diff --git a/examples/jms/scheduled-message/src/main/java/org/apache/activemq/artemis/jms/example/ScheduledMessageExample.java b/examples/jms/scheduled-message/src/main/java/org/apache/activemq/artemis/jms/example/ScheduledMessageExample.java
index 2fa38bf..ffc99d8 100644
--- a/examples/jms/scheduled-message/src/main/java/org/apache/activemq/artemis/jms/example/ScheduledMessageExample.java
+++ b/examples/jms/scheduled-message/src/main/java/org/apache/activemq/artemis/jms/example/ScheduledMessageExample.java
@@ -29,17 +29,10 @@ import javax.jms.TextMessage;
import javax.naming.InitialContext;
import org.apache.activemq.artemis.api.core.Message;
-import org.apache.activemq.artemis.common.example.ActiveMQExample;
-public class ScheduledMessageExample extends ActiveMQExample
+public class ScheduledMessageExample
{
- public static void main(final String[] args)
- {
- new ScheduledMessageExample().run(args);
- }
-
- @Override
- public boolean runExample() throws Exception
+ public static void main(final String[] args) throws Exception
{
Connection connection = null;
InitialContext initialContext = null;
@@ -89,8 +82,6 @@ public class ScheduledMessageExample extends ActiveMQExample
System.out.println("Received message: " + messageReceived.getText());
System.out.println("Time of receive: " + formatter.format(new Date()));
-
- return true;
}
finally
{
@@ -105,5 +96,4 @@ public class ScheduledMessageExample extends ActiveMQExample
}
}
}
-
}
http://git-wip-us.apache.org/repos/asf/activemq-artemis/blob/54d0d2b4/examples/jms/scheduled-message/src/main/resources/activemq/server0/artemis-roles.properties
----------------------------------------------------------------------
diff --git a/examples/jms/scheduled-message/src/main/resources/activemq/server0/artemis-roles.properties b/examples/jms/scheduled-message/src/main/resources/activemq/server0/artemis-roles.properties
deleted file mode 100644
index 4e2d44c..0000000
--- a/examples/jms/scheduled-message/src/main/resources/activemq/server0/artemis-roles.properties
+++ /dev/null
@@ -1,17 +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.
-## ---------------------------------------------------------------------------
-guest=guest
\ No newline at end of file
http://git-wip-us.apache.org/repos/asf/activemq-artemis/blob/54d0d2b4/examples/jms/scheduled-message/src/main/resources/activemq/server0/artemis-users.properties
----------------------------------------------------------------------
diff --git a/examples/jms/scheduled-message/src/main/resources/activemq/server0/artemis-users.properties b/examples/jms/scheduled-message/src/main/resources/activemq/server0/artemis-users.properties
deleted file mode 100644
index 4e2d44c..0000000
--- a/examples/jms/scheduled-message/src/main/resources/activemq/server0/artemis-users.properties
+++ /dev/null
@@ -1,17 +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.
-## ---------------------------------------------------------------------------
-guest=guest
\ No newline at end of file
http://git-wip-us.apache.org/repos/asf/activemq-artemis/blob/54d0d2b4/examples/jms/scheduled-message/src/main/resources/activemq/server0/broker.xml
----------------------------------------------------------------------
diff --git a/examples/jms/scheduled-message/src/main/resources/activemq/server0/broker.xml b/examples/jms/scheduled-message/src/main/resources/activemq/server0/broker.xml
deleted file mode 100644
index 7690094..0000000
--- a/examples/jms/scheduled-message/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 queue used by the example-->
- <queue name="exampleQueue"/>
- </jms>
-
- <core xmlns="urn:activemq:core">
-
- <bindings-directory>${data.dir}/server0/data/messaging/bindings</bindings-directory>
-
- <journal-directory>${data.dir}/server0/data/messaging/journal</journal-directory>
-
- <large-messages-directory>${data.dir}/server0/data/messaging/largemessages</large-messages-directory>
-
- <paging-directory>${data.dir}/server0/data/messaging/paging</paging-directory>
-
- <!-- Acceptors -->
- <acceptors>
- <acceptor name="netty-acceptor">tcp://localhost:61616</acceptor>
- </acceptors>
-
- <!-- Other config -->
-
- <security-settings>
- <!--security for example queue-->
- <security-setting match="jms.queue.exampleQueue">
- <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/54d0d2b4/examples/jms/security/pom.xml
----------------------------------------------------------------------
diff --git a/examples/jms/security/pom.xml b/examples/jms/security/pom.xml
index 88330b1..a58e177 100644
--- a/examples/jms/security/pom.xml
+++ b/examples/jms/security/pom.xml
@@ -37,11 +37,6 @@ under the License.
<dependencies>
<dependency>
- <groupId>org.apache.activemq.examples.jms</groupId>
- <artifactId>common</artifactId>
- <version>${project.version}</version>
- </dependency>
- <dependency>
<groupId>org.apache.geronimo.specs</groupId>
<artifactId>geronimo-jms_2.0_spec</artifactId>
</dependency>
@@ -61,9 +56,20 @@ under the License.
<goals>
<goal>create</goal>
</goals>
+ </execution>
+ <execution>
+ <id>start</id>
+ <goals>
+ <goal>cli</goal>
+ </goals>
<configuration>
- <instance>${basedir}/target/server0</instance>
- <configuration>${basedir}/target/classes/activemq/server0</configuration>
+ <spawn>true</spawn>
+ <testURI>tcp://localhost:61616</testURI>
+ <testUser>bill</testUser>
+ <testPassword>activemq</testPassword>
+ <args>
+ <param>run</param>
+ </args>
</configuration>
</execution>
<execution>
@@ -73,8 +79,16 @@ under the License.
</goals>
<configuration>
<clientClass>org.apache.activemq.artemis.jms.example.SecurityExample</clientClass>
+ </configuration>
+ </execution>
+ <execution>
+ <id>stop</id>
+ <goals>
+ <goal>cli</goal>
+ </goals>
+ <configuration>
<args>
- <param>${basedir}/target/server0</param>
+ <param>stop</param>
</args>
</configuration>
</execution>
http://git-wip-us.apache.org/repos/asf/activemq-artemis/blob/54d0d2b4/examples/jms/security/src/main/java/org/apache/activemq/artemis/jms/example/SecurityExample.java
----------------------------------------------------------------------
diff --git a/examples/jms/security/src/main/java/org/apache/activemq/artemis/jms/example/SecurityExample.java b/examples/jms/security/src/main/java/org/apache/activemq/artemis/jms/example/SecurityExample.java
index eb7ffc0..fc83fe7 100644
--- a/examples/jms/security/src/main/java/org/apache/activemq/artemis/jms/example/SecurityExample.java
+++ b/examples/jms/security/src/main/java/org/apache/activemq/artemis/jms/example/SecurityExample.java
@@ -27,20 +27,13 @@ import javax.jms.TextMessage;
import javax.jms.Topic;
import javax.naming.InitialContext;
-import org.apache.activemq.artemis.common.example.ActiveMQExample;
-
-public class SecurityExample extends ActiveMQExample
+public class SecurityExample
{
- private boolean result = true;
-
- public static void main(final String[] args)
- {
- new SecurityExample().run(args);
- }
- @Override
- public boolean runExample() throws Exception
+ public static void main(final String[] args) throws Exception
{
+ boolean result = true;
+ Connection failConnection = null;
Connection billConnection = null;
Connection andrewConnection = null;
Connection frankConnection = null;
@@ -63,7 +56,7 @@ public class SecurityExample extends ActiveMQExample
// Step 4. Try to create a JMS Connection without user/password. It will fail.
try
{
- cf.createConnection();
+ failConnection = cf.createConnection();
result = false;
}
catch (JMSSecurityException e)
@@ -136,12 +129,14 @@ public class SecurityExample extends ActiveMQExample
// Step 18. Check permissions on news.us.usTopic for sam: can't send but can receive
checkUserReceiveNoSend(usTopic, samConnection, "sam", frankConnection);
System.out.println("-------------------------------------------------------------------------------------");
-
- return result;
}
finally
{
// Step 19. Be sure to close our JMS resources!
+ if (failConnection != null)
+ {
+ failConnection.close();
+ }
if (billConnection != null)
{
billConnection.close();
@@ -168,7 +163,7 @@ public class SecurityExample extends ActiveMQExample
}
// Check the user can receive message but cannot send message.
- private void checkUserReceiveNoSend(final Topic topic,
+ private static void checkUserReceiveNoSend(final Topic topic,
final Connection connection,
final String user,
final Connection sendingConn) throws JMSException
@@ -181,12 +176,11 @@ public class SecurityExample extends ActiveMQExample
try
{
producer.send(msg);
- System.out.println("Security setting is broken! User " + user +
+ throw new IllegalStateException("Security setting is broken! User " + user +
" can send message [" +
msg.getText() +
"] to topic " +
topic);
- result = false;
}
catch (JMSException e)
{
@@ -206,8 +200,7 @@ public class SecurityExample extends ActiveMQExample
}
else
{
- System.out.println("Security setting is broken! User " + user + " cannot receive message from topic " + topic);
- result = false;
+ throw new IllegalStateException("Security setting is broken! User " + user + " cannot receive message from topic " + topic);
}
session1.close();
@@ -215,7 +208,7 @@ public class SecurityExample extends ActiveMQExample
}
// Check the user can send message but cannot receive message
- private void checkUserSendNoReceive(final Topic topic,
+ private static void checkUserSendNoReceive(final Topic topic,
final Connection connection,
final String user,
final Connection receivingConn) throws JMSException
@@ -244,12 +237,11 @@ public class SecurityExample extends ActiveMQExample
}
else
{
- System.out.println("Security setting is broken! User " + user +
+ throw new IllegalStateException("Security setting is broken! User " + user +
" cannot send message [" +
msg.getText() +
"] to topic " +
topic);
- result = false;
}
session.close();
@@ -257,7 +249,7 @@ public class SecurityExample extends ActiveMQExample
}
// Check the user has neither send nor receive permission on topic
- private void checkUserNoSendNoReceive(final Topic topic, final Connection connection, final String user) throws JMSException
+ private static void checkUserNoSendNoReceive(final Topic topic, final Connection connection, final String user) throws JMSException
{
Session session = connection.createSession(false, Session.AUTO_ACKNOWLEDGE);
MessageProducer producer = session.createProducer(topic);
@@ -275,12 +267,11 @@ public class SecurityExample extends ActiveMQExample
try
{
producer.send(msg);
- System.out.println("Security setting is broken! User " + user +
+ throw new IllegalStateException("Security setting is broken! User " + user +
" can send message [" +
msg.getText() +
"] to topic " +
topic);
- result = false;
}
catch (JMSException e)
{
@@ -291,7 +282,7 @@ public class SecurityExample extends ActiveMQExample
}
// Check the user connection has both send and receive permissions on the topic
- private void checkUserSendAndReceive(final Topic topic, final Connection connection, final String user) throws JMSException
+ private static void checkUserSendAndReceive(final Topic topic, final Connection connection, final String user) throws JMSException
{
Session session = connection.createSession(false, Session.AUTO_ACKNOWLEDGE);
TextMessage msg = session.createTextMessage("hello-world-4");
@@ -306,13 +297,12 @@ public class SecurityExample extends ActiveMQExample
}
else
{
- System.out.println("Error! User " + user + " cannot receive the message! ");
- result = false;
+ throw new IllegalStateException("Error! User " + user + " cannot receive the message! ");
}
session.close();
}
- private Connection createConnection(final String username, final String password, final ConnectionFactory cf) throws JMSException
+ private static Connection createConnection(final String username, final String password, final ConnectionFactory cf) throws JMSException
{
return cf.createConnection(username, password);
}
http://git-wip-us.apache.org/repos/asf/activemq-artemis/blob/54d0d2b4/examples/jms/send-acknowledgements/pom.xml
----------------------------------------------------------------------
diff --git a/examples/jms/send-acknowledgements/pom.xml b/examples/jms/send-acknowledgements/pom.xml
index 7aa59cf..6d22b09 100644
--- a/examples/jms/send-acknowledgements/pom.xml
+++ b/examples/jms/send-acknowledgements/pom.xml
@@ -37,8 +37,8 @@ under the License.
<dependencies>
<dependency>
- <groupId>org.apache.activemq.examples.jms</groupId>
- <artifactId>common</artifactId>
+ <groupId>org.apache.activemq</groupId>
+ <artifactId>artemis-jms-client</artifactId>
<version>${project.version}</version>
</dependency>
<dependency>
@@ -61,9 +61,18 @@ under the License.
<goals>
<goal>create</goal>
</goals>
+ </execution>
+ <execution>
+ <id>start</id>
+ <goals>
+ <goal>cli</goal>
+ </goals>
<configuration>
- <instance>${basedir}/target/server0</instance>
- <configuration>${basedir}/target/classes/activemq/server0</configuration>
+ <spawn>true</spawn>
+ <testURI>tcp://localhost:61616</testURI>
+ <args>
+ <param>run</param>
+ </args>
</configuration>
</execution>
<execution>
@@ -73,8 +82,16 @@ under the License.
</goals>
<configuration>
<clientClass>org.apache.activemq.artemis.jms.example.SendAcknowledgementsExample</clientClass>
+ </configuration>
+ </execution>
+ <execution>
+ <id>stop</id>
+ <goals>
+ <goal>cli</goal>
+ </goals>
+ <configuration>
<args>
- <param>${basedir}/target/server0</param>
+ <param>stop</param>
</args>
</configuration>
</execution>
http://git-wip-us.apache.org/repos/asf/activemq-artemis/blob/54d0d2b4/examples/jms/send-acknowledgements/src/main/java/org/apache/activemq/artemis/jms/example/SendAcknowledgementsExample.java
----------------------------------------------------------------------
diff --git a/examples/jms/send-acknowledgements/src/main/java/org/apache/activemq/artemis/jms/example/SendAcknowledgementsExample.java b/examples/jms/send-acknowledgements/src/main/java/org/apache/activemq/artemis/jms/example/SendAcknowledgementsExample.java
index 03fb866..99fb0ba 100644
--- a/examples/jms/send-acknowledgements/src/main/java/org/apache/activemq/artemis/jms/example/SendAcknowledgementsExample.java
+++ b/examples/jms/send-acknowledgements/src/main/java/org/apache/activemq/artemis/jms/example/SendAcknowledgementsExample.java
@@ -27,7 +27,6 @@ import javax.naming.InitialContext;
import org.apache.activemq.artemis.api.core.Message;
import org.apache.activemq.artemis.api.core.client.ClientSession;
import org.apache.activemq.artemis.api.core.client.SendAcknowledgementHandler;
-import org.apache.activemq.artemis.common.example.ActiveMQExample;
import org.apache.activemq.artemis.jms.client.ActiveMQSession;
/**
@@ -37,15 +36,9 @@ import org.apache.activemq.artemis.jms.client.ActiveMQSession;
* to the stream of messages being sent to the server.
* For more information please see the readme.html file
*/
-public class SendAcknowledgementsExample extends ActiveMQExample
+public class SendAcknowledgementsExample
{
- public static void main(final String[] args)
- {
- new SendAcknowledgementsExample().run(args);
- }
-
- @Override
- public boolean runExample() throws Exception
+ public static void main(final String[] args) throws Exception
{
Connection connection = null;
InitialContext initialContext = null;
@@ -101,8 +94,6 @@ public class SendAcknowledgementsExample extends ActiveMQExample
System.out.println("Sent message " + i);
}
-
- return true;
}
finally
{
@@ -118,5 +109,4 @@ public class SendAcknowledgementsExample extends ActiveMQExample
}
}
}
-
}
http://git-wip-us.apache.org/repos/asf/activemq-artemis/blob/54d0d2b4/examples/jms/send-acknowledgements/src/main/resources/activemq/server0/artemis-roles.properties
----------------------------------------------------------------------
diff --git a/examples/jms/send-acknowledgements/src/main/resources/activemq/server0/artemis-roles.properties b/examples/jms/send-acknowledgements/src/main/resources/activemq/server0/artemis-roles.properties
deleted file mode 100644
index 4e2d44c..0000000
--- a/examples/jms/send-acknowledgements/src/main/resources/activemq/server0/artemis-roles.properties
+++ /dev/null
@@ -1,17 +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.
-## ---------------------------------------------------------------------------
-guest=guest
\ No newline at end of file
http://git-wip-us.apache.org/repos/asf/activemq-artemis/blob/54d0d2b4/examples/jms/send-acknowledgements/src/main/resources/activemq/server0/artemis-users.properties
----------------------------------------------------------------------
diff --git a/examples/jms/send-acknowledgements/src/main/resources/activemq/server0/artemis-users.properties b/examples/jms/send-acknowledgements/src/main/resources/activemq/server0/artemis-users.properties
deleted file mode 100644
index 4e2d44c..0000000
--- a/examples/jms/send-acknowledgements/src/main/resources/activemq/server0/artemis-users.properties
+++ /dev/null
@@ -1,17 +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.
-## ---------------------------------------------------------------------------
-guest=guest
\ No newline at end of file
http://git-wip-us.apache.org/repos/asf/activemq-artemis/blob/54d0d2b4/examples/jms/send-acknowledgements/src/main/resources/activemq/server0/broker.xml
----------------------------------------------------------------------
diff --git a/examples/jms/send-acknowledgements/src/main/resources/activemq/server0/broker.xml b/examples/jms/send-acknowledgements/src/main/resources/activemq/server0/broker.xml
deleted file mode 100644
index 7690094..0000000
--- a/examples/jms/send-acknowledgements/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 queue used by the example-->
- <queue name="exampleQueue"/>
- </jms>
-
- <core xmlns="urn:activemq:core">
-
- <bindings-directory>${data.dir}/server0/data/messaging/bindings</bindings-directory>
-
- <journal-directory>${data.dir}/server0/data/messaging/journal</journal-directory>
-
- <large-messages-directory>${data.dir}/server0/data/messaging/largemessages</large-messages-directory>
-
- <paging-directory>${data.dir}/server0/data/messaging/paging</paging-directory>
-
- <!-- Acceptors -->
- <acceptors>
- <acceptor name="netty-acceptor">tcp://localhost:61616</acceptor>
- </acceptors>
-
- <!-- Other config -->
-
- <security-settings>
- <!--security for example queue-->
- <security-setting match="jms.queue.exampleQueue">
- <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/54d0d2b4/examples/jms/spring-integration/pom.xml
----------------------------------------------------------------------
diff --git a/examples/jms/spring-integration/pom.xml b/examples/jms/spring-integration/pom.xml
index 25ae488..fcc6d9f 100644
--- a/examples/jms/spring-integration/pom.xml
+++ b/examples/jms/spring-integration/pom.xml
@@ -37,11 +37,6 @@ under the License.
<dependencies>
<dependency>
- <groupId>org.apache.activemq.examples.jms</groupId>
- <artifactId>common</artifactId>
- <version>${project.version}</version>
- </dependency>
- <dependency>
<groupId>org.apache.activemq</groupId>
<artifactId>artemis-spring-integration</artifactId>
<version>${project.version}</version>
@@ -72,9 +67,6 @@ under the License.
</goals>
<configuration>
<clientClass>org.apache.activemq.artemis.jms.example.SpringExample</clientClass>
- <args>
- <param>${basedir}/target/server0</param>
- </args>
</configuration>
</execution>
</executions>
http://git-wip-us.apache.org/repos/asf/activemq-artemis/blob/54d0d2b4/examples/jms/ssl-enabled/pom.xml
----------------------------------------------------------------------
diff --git a/examples/jms/ssl-enabled/pom.xml b/examples/jms/ssl-enabled/pom.xml
index 47989bf..7c6e4f8 100644
--- a/examples/jms/ssl-enabled/pom.xml
+++ b/examples/jms/ssl-enabled/pom.xml
@@ -37,11 +37,6 @@ under the License.
<dependencies>
<dependency>
- <groupId>org.apache.activemq.examples.jms</groupId>
- <artifactId>common</artifactId>
- <version>${project.version}</version>
- </dependency>
- <dependency>
<groupId>org.apache.geronimo.specs</groupId>
<artifactId>geronimo-jms_2.0_spec</artifactId>
</dependency>
@@ -61,9 +56,18 @@ under the License.
<goals>
<goal>create</goal>
</goals>
+ </execution>
+ <execution>
+ <id>start</id>
+ <goals>
+ <goal>cli</goal>
+ </goals>
<configuration>
- <instance>${basedir}/target/server0</instance>
- <configuration>${basedir}/target/classes/activemq/server0</configuration>
+ <spawn>true</spawn>
+ <testURI>tcp://localhost:5500?sslEnabled=true&trustStorePath=activemq/server0/activemq.example.truststore&trustStorePassword=activemqexample</testURI>
+ <args>
+ <param>run</param>
+ </args>
</configuration>
</execution>
<execution>
@@ -73,8 +77,16 @@ under the License.
</goals>
<configuration>
<clientClass>org.apache.activemq.artemis.jms.example.SSLExample</clientClass>
+ </configuration>
+ </execution>
+ <execution>
+ <id>stop</id>
+ <goals>
+ <goal>cli</goal>
+ </goals>
+ <configuration>
<args>
- <param>${basedir}/target/server0</param>
+ <param>stop</param>
</args>
</configuration>
</execution>
http://git-wip-us.apache.org/repos/asf/activemq-artemis/blob/54d0d2b4/examples/jms/ssl-enabled/src/main/java/org/apache/activemq/artemis/jms/example/SSLExample.java
----------------------------------------------------------------------
diff --git a/examples/jms/ssl-enabled/src/main/java/org/apache/activemq/artemis/jms/example/SSLExample.java b/examples/jms/ssl-enabled/src/main/java/org/apache/activemq/artemis/jms/example/SSLExample.java
index 11f5a91..a43e4c0 100644
--- a/examples/jms/ssl-enabled/src/main/java/org/apache/activemq/artemis/jms/example/SSLExample.java
+++ b/examples/jms/ssl-enabled/src/main/java/org/apache/activemq/artemis/jms/example/SSLExample.java
@@ -25,20 +25,12 @@ import javax.jms.Session;
import javax.jms.TextMessage;
import javax.naming.InitialContext;
-import org.apache.activemq.artemis.common.example.ActiveMQExample;
-
/**
* A simple JMS Queue example that uses SSL secure transport.
*/
-public class SSLExample extends ActiveMQExample
+public class SSLExample
{
- public static void main(final String[] args)
- {
- new SSLExample().run(args);
- }
-
- @Override
- public boolean runExample() throws Exception
+ public static void main(final String[] args) throws Exception
{
Connection connection = null;
InitialContext initialContext = null;
@@ -82,8 +74,6 @@ public class SSLExample extends ActiveMQExample
System.out.println("Received message: " + messageReceived.getText());
initialContext.close();
-
- return true;
}
finally
{
@@ -98,5 +88,4 @@ public class SSLExample extends ActiveMQExample
}
}
}
-
}
http://git-wip-us.apache.org/repos/asf/activemq-artemis/blob/54d0d2b4/examples/jms/static-selector-jms/pom.xml
----------------------------------------------------------------------
diff --git a/examples/jms/static-selector-jms/pom.xml b/examples/jms/static-selector-jms/pom.xml
index 750af00..02b8fb7 100644
--- a/examples/jms/static-selector-jms/pom.xml
+++ b/examples/jms/static-selector-jms/pom.xml
@@ -37,11 +37,6 @@ under the License.
<dependencies>
<dependency>
- <groupId>org.apache.activemq.examples.jms</groupId>
- <artifactId>common</artifactId>
- <version>${project.version}</version>
- </dependency>
- <dependency>
<groupId>org.apache.geronimo.specs</groupId>
<artifactId>geronimo-jms_2.0_spec</artifactId>
</dependency>
@@ -61,9 +56,18 @@ under the License.
<goals>
<goal>create</goal>
</goals>
+ </execution>
+ <execution>
+ <id>start</id>
+ <goals>
+ <goal>cli</goal>
+ </goals>
<configuration>
- <instance>${basedir}/target/server0</instance>
- <configuration>${basedir}/target/classes/activemq/server0</configuration>
+ <spawn>true</spawn>
+ <testURI>tcp://localhost:61616</testURI>
+ <args>
+ <param>run</param>
+ </args>
</configuration>
</execution>
<execution>
@@ -73,8 +77,16 @@ under the License.
</goals>
<configuration>
<clientClass>org.apache.activemq.artemis.jms.example.StaticSelectorJMSExample</clientClass>
+ </configuration>
+ </execution>
+ <execution>
+ <id>stop</id>
+ <goals>
+ <goal>cli</goal>
+ </goals>
+ <configuration>
<args>
- <param>${basedir}/target/server0</param>
+ <param>stop</param>
</args>
</configuration>
</execution>
@@ -91,6 +103,4 @@ under the License.
</build>
</profile>
</profiles>
-
-
</project>
http://git-wip-us.apache.org/repos/asf/activemq-artemis/blob/54d0d2b4/examples/jms/static-selector-jms/src/main/java/org/apache/activemq/artemis/jms/example/StaticSelectorJMSExample.java
----------------------------------------------------------------------
diff --git a/examples/jms/static-selector-jms/src/main/java/org/apache/activemq/artemis/jms/example/StaticSelectorJMSExample.java b/examples/jms/static-selector-jms/src/main/java/org/apache/activemq/artemis/jms/example/StaticSelectorJMSExample.java
index 16c22e5..0f06417 100644
--- a/examples/jms/static-selector-jms/src/main/java/org/apache/activemq/artemis/jms/example/StaticSelectorJMSExample.java
+++ b/examples/jms/static-selector-jms/src/main/java/org/apache/activemq/artemis/jms/example/StaticSelectorJMSExample.java
@@ -27,24 +27,16 @@ import javax.jms.Queue;
import javax.jms.Session;
import javax.jms.TextMessage;
import javax.naming.InitialContext;
-
-import org.apache.activemq.artemis.common.example.ActiveMQExample;
+import java.util.concurrent.atomic.AtomicBoolean;
/**
* A simple JMS example that shows how static message selectors work when using JMS config.
*/
-public class StaticSelectorJMSExample extends ActiveMQExample
+public class StaticSelectorJMSExample
{
- private volatile boolean result = true;
-
- public static void main(final String[] args)
- {
- new StaticSelectorJMSExample().run(args);
- }
-
- @Override
- public boolean runExample() throws Exception
+ public static void main(final String[] args) throws Exception
{
+ AtomicBoolean result = new AtomicBoolean(true);
Connection connection = null;
InitialContext initialContext = null;
try
@@ -73,7 +65,7 @@ public class StaticSelectorJMSExample extends ActiveMQExample
// Step 8. Create a JMS Message Consumer that receives 'red' messages
MessageConsumer redConsumer = session.createConsumer(queue);
- redConsumer.setMessageListener(new SimpleMessageListener("red"));
+ redConsumer.setMessageListener(new SimpleMessageListener("red", result));
// Step 9. Create five messages with different 'color' properties
TextMessage redMessage1 = session.createTextMessage("Red-1");
@@ -101,7 +93,8 @@ public class StaticSelectorJMSExample extends ActiveMQExample
// Step 11. Waiting for the message listener to check the received messages.
Thread.sleep(5000);
- return result;
+ if (!result.get())
+ throw new IllegalStateException();
}
finally
{
@@ -116,38 +109,39 @@ public class StaticSelectorJMSExample extends ActiveMQExample
}
}
}
+}
- public class SimpleMessageListener implements MessageListener
- {
- private final String name;
+class SimpleMessageListener implements MessageListener
+{
+ private final String name;
+ private AtomicBoolean result;
- public SimpleMessageListener(final String listener)
- {
- name = listener;
- }
+ public SimpleMessageListener(final String listener, AtomicBoolean result)
+ {
+ name = listener;
+ this.result = result;
+ }
- public void onMessage(final Message msg)
+ public void onMessage(final Message msg)
+ {
+ TextMessage textMessage = (TextMessage)msg;
+ try
{
- 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 != null && !colorProp.equals(name))
{
- String colorProp = msg.getStringProperty("color");
- System.out.println("Receiver " + name +
- " receives message [" +
- textMessage.getText() +
- "] with color property: " +
- colorProp);
- if (colorProp != null && !colorProp.equals(name))
- {
- result = false;
- }
- }
- catch (JMSException e)
- {
- e.printStackTrace();
- result = false;
+ 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/54d0d2b4/examples/jms/static-selector-jms/src/main/resources/activemq/server0/broker.xml
----------------------------------------------------------------------
diff --git a/examples/jms/static-selector-jms/src/main/resources/activemq/server0/broker.xml b/examples/jms/static-selector-jms/src/main/resources/activemq/server0/broker.xml
index 7442fac..cdeb534 100644
--- a/examples/jms/static-selector-jms/src/main/resources/activemq/server0/broker.xml
+++ b/examples/jms/static-selector-jms/src/main/resources/activemq/server0/broker.xml
@@ -31,13 +31,13 @@ under the License.
<core xmlns="urn:activemq:core">
- <bindings-directory>${data.dir}/server0/data/messaging/bindings</bindings-directory>
+ <bindings-directory>${data.dir:../data}/bindings</bindings-directory>
- <journal-directory>${data.dir}/server0/data/messaging/journal</journal-directory>
+ <journal-directory>${data.dir:../data}/journal</journal-directory>
- <large-messages-directory>${data.dir}/server0/data/messaging/largemessages</large-messages-directory>
+ <large-messages-directory>${data.dir:../data}/largemessages</large-messages-directory>
- <paging-directory>${data.dir}/server0/data/messaging/paging</paging-directory>
+ <paging-directory>${data.dir:../data}/paging</paging-directory>
<!-- Acceptors -->
<acceptors>