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 2017/12/19 03:13:13 UTC
activemq-artemis git commit: NO-JIRA removing example added by
accident
Repository: activemq-artemis
Updated Branches:
refs/heads/master de7251d54 -> fe537fa25
NO-JIRA removing example added by accident
Project: http://git-wip-us.apache.org/repos/asf/activemq-artemis/repo
Commit: http://git-wip-us.apache.org/repos/asf/activemq-artemis/commit/fe537fa2
Tree: http://git-wip-us.apache.org/repos/asf/activemq-artemis/tree/fe537fa2
Diff: http://git-wip-us.apache.org/repos/asf/activemq-artemis/diff/fe537fa2
Branch: refs/heads/master
Commit: fe537fa257a371c8985d4ea15e528a74540fd162
Parents: de7251d
Author: Clebert Suconic <cl...@apache.org>
Authored: Mon Dec 18 22:12:36 2017 -0500
Committer: Clebert Suconic <cl...@apache.org>
Committed: Mon Dec 18 22:12:40 2017 -0500
----------------------------------------------------------------------
.../standard/send-acknowledgements-fail/pom.xml | 94 ------------
.../send-acknowledgements-fail/readme.html | 140 -----------------
.../example/SendAcknowledgementsExample.java | 151 -------------------
.../src/main/resources/jndi.properties | 20 ---
4 files changed, 405 deletions(-)
----------------------------------------------------------------------
http://git-wip-us.apache.org/repos/asf/activemq-artemis/blob/fe537fa2/examples/features/standard/send-acknowledgements-fail/pom.xml
----------------------------------------------------------------------
diff --git a/examples/features/standard/send-acknowledgements-fail/pom.xml b/examples/features/standard/send-acknowledgements-fail/pom.xml
deleted file mode 100644
index 369f94e..0000000
--- a/examples/features/standard/send-acknowledgements-fail/pom.xml
+++ /dev/null
@@ -1,94 +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>2.5.0-SNAPSHOT</version>
- </parent>
-
- <artifactId>send-acknowledgements-fail</artifactId>
- <packaging>jar</packaging>
- <name>ActiveMQ Artemis JMS Send Acknowledgements Example</name>
-
- <properties>
- <activemq.basedir>${project.basedir}/../../../..</activemq.basedir>
- </properties>
-
- <dependencies>
- <dependency>
- <groupId>org.apache.activemq</groupId>
- <artifactId>artemis-jms-client-all</artifactId>
- <version>${project.version}</version>
- </dependency>
- <dependency>
- <groupId>org.apache.activemq</groupId>
- <artifactId>artemis-cli</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>
- <instance>${basedir}/target/server0</instance>
- <args>
- <arg>--global-max-size</arg>
- <arg>10M</arg>
- </args>
- </configuration>
- </execution>
- <execution>
- <id>runClient</id>
- <goals>
- <goal>runClient</goal>
- </goals>
- <configuration>
- <clientClass>org.apache.activemq.artemis.jms.example.SendAcknowledgementsExample</clientClass>
- <args>
- <param>${basedir}/target/server0</param>
- </args>
- </configuration>
- </execution>
- </executions>
- <dependencies>
- <dependency>
- <groupId>org.apache.activemq.examples.broker</groupId>
- <artifactId>send-acknowledgements-fail</artifactId>
- <version>${project.version}</version>
- </dependency>
- </dependencies>
- </plugin>
- </plugins>
- </build>
-
-</project>
http://git-wip-us.apache.org/repos/asf/activemq-artemis/blob/fe537fa2/examples/features/standard/send-acknowledgements-fail/readme.html
----------------------------------------------------------------------
diff --git a/examples/features/standard/send-acknowledgements-fail/readme.html b/examples/features/standard/send-acknowledgements-fail/readme.html
deleted file mode 100644
index fcc37fc..0000000
--- a/examples/features/standard/send-acknowledgements-fail/readme.html
+++ /dev/null
@@ -1,140 +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 Asynchronous Send Acknowledgements 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>Asynchronous Send Acknowledgements 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>Asynchronous Send Acknowledgements are an advanced feature of ActiveMQ Artemis which allow you to
- receive acknowledgements that messages were successfully received at the server in a separate thread to the sending thread<p/>
- <p>In this example we create a normal JMS session, then set a SendAcknowledgementHandler on the JMS
- session's underlying core session. We send many messages to the server without blocking and asynchronously
- receive send acknowledgements via the SendAcknowledgementHandler.
-
- <p>For more information on Asynchronous Send Acknowledgements please see the user manual</p>
- <h2>Example step-by-step</h2>
- <p><i>To run the example, simply type <code>mvn verify -Pexample</code> from this directory</i></p>
-
- <ol>
- <li>First we need to get an initial context so we can look-up the JMS connection factory and destination objects from JNDI. This initial context will get it's properties from the <code>client-jndi.properties</code> file in the directory <code>../common/config</code></li>
- <pre class="prettyprint">
- <code>InitialContext initialContext = getContext();</code>
- </pre>
-
- <li>We look-up the JMS queue object from JNDI</li>
- <pre class="prettyprint">
- <code>Queue queue = (Queue) initialContext.lookup("/queue/exampleQueue");</code>
- </pre>
-
- <li>We look-up the JMS connection factory object from JNDI</li>
- <pre class="prettyprint">
- <code>ConnectionFactory cf = (ConnectionFactory) initialContext.lookup("/ConnectionFactory");</code>
- </pre>
-
- <li>We create a JMS connection</li>
- <pre class="prettyprint">
- <code>connection = cf.createConnection();</code>
- </pre>
-
- <li>Define a SendAcknowledgementHandler which will receive asynchronous acknowledgements</li>
- <pre class="prettyprint">
- <code>
- class MySendAcknowledgementsHandler implements SendAcknowledgementHandler
- {
- int count = 0;
-
- public void sendAcknowledged(final Message message)
- {
- System.out.println("Received send acknowledgement for message " + count++);
- }
- }
- </code>
- </pre>
-
- <li>Create a JMS session</li>
- <pre class="prettyprint">
- <code>Session session = connection.createSession(false, Session.AUTO_ACKNOWLEDGE);</code>
- </pre>
-
- <li>Set the handler on the underlying core session</li>
- <pre class="prettyprint">
- <code>
- ClientSession coreSession = ((ActiveMQSession)session).getCoreSession();
-
- coreSession.setSendAcknowledgementHandler(new MySendAcknowledgementsHandler());
-
- </code>
- </pre>
-
- <li>Create a JMS Message Producer</li>
- <pre class="prettyprint">
- <code>
- MessageProducer producer = session.createProducer(queue);
-
- producer.setDeliveryMode(DeliveryMode.NON_PERSISTENT);
- </code>
- </pre>
-
- <li>Send 5000 messages, the handler will get called asynchronously some time later after the messages are sent.</li>
- <pre class="prettyprint">
- <code>
- final int numMessages = 5000;
-
- for (int i = 0; i < numMessages; i++)
- {
- javax.jms.Message jmsMessage = session.createMessage();
-
- producer.send(jmsMessage);
-
- System.out.println("Sent message " + i);
- }
- </code>
- </pre>
-
-
- <li>And finally, <b>always</b> remember to close your JMS connections and resources after use, in a <code>finally</code> block. Closing a JMS connection will automatically close all of its sessions, consumers, producer and browser objects</li>
-
- <pre class="prettyprint">
- <code>finally
- {
- if (initialContext != null)
- {
- initialContext.close();
- }
- if (connection != null)
- {
- connection.close();
- }
- }</code>
- </pre>
-
-
-
- </ol>
- </body>
-</html>
http://git-wip-us.apache.org/repos/asf/activemq-artemis/blob/fe537fa2/examples/features/standard/send-acknowledgements-fail/src/main/java/org/apache/activemq/artemis/jms/example/SendAcknowledgementsExample.java
----------------------------------------------------------------------
diff --git a/examples/features/standard/send-acknowledgements-fail/src/main/java/org/apache/activemq/artemis/jms/example/SendAcknowledgementsExample.java b/examples/features/standard/send-acknowledgements-fail/src/main/java/org/apache/activemq/artemis/jms/example/SendAcknowledgementsExample.java
deleted file mode 100644
index 86c4333..0000000
--- a/examples/features/standard/send-acknowledgements-fail/src/main/java/org/apache/activemq/artemis/jms/example/SendAcknowledgementsExample.java
+++ /dev/null
@@ -1,151 +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 java.util.concurrent.CountDownLatch;
-import java.util.concurrent.TimeUnit;
-
-import org.apache.activemq.artemis.api.core.Message;
-import org.apache.activemq.artemis.api.core.RoutingType;
-import org.apache.activemq.artemis.api.core.SimpleString;
-import org.apache.activemq.artemis.api.core.client.ActiveMQClient;
-import org.apache.activemq.artemis.api.core.client.ClientConsumer;
-import org.apache.activemq.artemis.api.core.client.ClientMessage;
-import org.apache.activemq.artemis.api.core.client.ClientProducer;
-import org.apache.activemq.artemis.api.core.client.ClientSession;
-import org.apache.activemq.artemis.api.core.client.ClientSessionFactory;
-import org.apache.activemq.artemis.api.core.client.SendAcknowledgementHandler;
-import org.apache.activemq.artemis.api.core.client.ServerLocator;
-import org.apache.activemq.artemis.util.ServerUtil;
-
-/**
- * Asynchronous Send Acknowledgements are an advanced feature of ActiveMQ Artemis which allow you to
- * receive acknowledgements that messages were successfully received at the server in a separate stream
- * to the stream of messages being sent to the server.
- * For more information please see the readme.html file
- */
-public class SendAcknowledgementsExample {
-
- private static Process server0;
- private static final int numMessages = 30_000;
- private static final SimpleString queueName = SimpleString.toSimpleString("testQueue");
-
- public static void main(final String[] args) throws Exception {
-
- for (int i = 0; i < 500; i++) {
- System.out.println("$$$$$$$$$$$$$$$$$$$$$$$$$$$$$$$$$$$$$$$$$$$$$$$$$$$$$$$$$$$$$$$$$$$$$$$$$$$$$$$$$$$$$$$$$$$$ Running test " + i);
- server0 = ServerUtil.startServer(args[0], SendAcknowledgementsExample.class.getSimpleName() + "0", 0, 10000);
- sendMessages();
-
- server0 = ServerUtil.startServer(args[0], SendAcknowledgementsExample.class.getSimpleName() + "0", 0, 10000);
- consumeMessages();
- }
- }
-
- private static void sendMessages() throws Exception {
- try {
-
- ServerLocator locator = ActiveMQClient.createServerLocator("tcp://localhost:61616").setBlockOnDurableSend(false).setConfirmationWindowSize(1024 * 1024);
-
- ClientSessionFactory factory = locator.createSessionFactory();
-
- ClientSession session = factory.createSession(null, null, false, true, true, false, ActiveMQClient.DEFAULT_ACK_BATCH_SIZE);
-
- try {
- // Tried with and without the createAddress
- session.createAddress(queueName, RoutingType.MULTICAST, false);
- session.createQueue(queueName.toString(), RoutingType.MULTICAST, queueName.toString(), true);
- } catch (Exception e) {
- }
-
- ClientProducer producer = session.createProducer(queueName);
-
- CountDownLatch latch = new CountDownLatch(numMessages);
-
- for (int i = 0; i < numMessages; i++) {
-
- if (i % 10000 == 0) {
- System.out.println("Send " + i);
- }
- ClientMessage message = session.createMessage(true);
- message.getBodyBuffer().writeBytes("hello world".getBytes());
-
- // tried with producer.send(queueName, message, ...);; // didn't make a difference
-
- producer.send(message, new SendAcknowledgementHandler() {
- @Override
- public void sendAcknowledged(Message message) {
- latch.countDown();
- if (latch.getCount() % 10_000 == 0) {
- System.out.println(latch.getCount() + " to go");
- }
- }
- });
- }
- latch.await(10, TimeUnit.MINUTES);
- } finally {
- server0.destroy();
- server0.waitFor();
- }
- }
-
- private static void consumeMessages() throws Exception {
- try {
-
- ServerLocator locator = ActiveMQClient.createServerLocator("tcp://localhost:61616").setBlockOnDurableSend(false).setConfirmationWindowSize(-1);
-
- ClientSessionFactory factory = locator.createSessionFactory();
-
- ClientSession session = factory.createSession(null, null, false, false, false, false, ActiveMQClient.DEFAULT_ACK_BATCH_SIZE);
-
- ClientConsumer consumer = session.createConsumer(queueName);
-
- session.start();
-
- for (int i = 0; i < numMessages; i++) {
-
- if (i % 10000 == 0) {
- System.out.println("Received " + i);
- }
-
- ClientMessage message = consumer.receive(5000);
- message.acknowledge();
-
- if (message == null) {
- System.err.println("Expected message at " + i);
- System.exit(-1);
- }
- }
-
- session.commit();
-
- ClientMessage message = consumer.receiveImmediate();
- if (message != null) {
- System.err.println("Received too many messages");
- System.exit(-1);
- }
-
- session.close();
- locator.close();
-
- } finally {
- server0.destroy();
- server0.waitFor();
- }
- }
-
-}
http://git-wip-us.apache.org/repos/asf/activemq-artemis/blob/fe537fa2/examples/features/standard/send-acknowledgements-fail/src/main/resources/jndi.properties
----------------------------------------------------------------------
diff --git a/examples/features/standard/send-acknowledgements-fail/src/main/resources/jndi.properties b/examples/features/standard/send-acknowledgements-fail/src/main/resources/jndi.properties
deleted file mode 100644
index 8421f25..0000000
--- a/examples/features/standard/send-acknowledgements-fail/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?confirmationWindowSize=1048576
-queue.queue/exampleQueue=exampleQueue