|
ActiveMQ example source code file (QueueDuplicatesFromStoreTest.java)
The ActiveMQ QueueDuplicatesFromStoreTest.java source code/** * 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.broker.region; import java.io.IOException; import java.util.List; import java.util.Vector; import java.util.concurrent.CountDownLatch; import java.util.concurrent.TimeUnit; import java.util.concurrent.atomic.AtomicLong; import javax.jms.InvalidSelectorException; import javax.management.ObjectName; import junit.framework.TestCase; import org.apache.activemq.broker.BrokerService; import org.apache.activemq.broker.ConnectionContext; import org.apache.activemq.broker.ProducerBrokerExchange; import org.apache.activemq.command.ActiveMQDestination; import org.apache.activemq.command.ActiveMQQueue; import org.apache.activemq.command.ActiveMQTextMessage; import org.apache.activemq.command.ConsumerInfo; import org.apache.activemq.command.Message; import org.apache.activemq.command.MessageAck; import org.apache.activemq.command.MessageDispatchNotification; import org.apache.activemq.command.MessageId; import org.apache.activemq.command.MessagePull; import org.apache.activemq.command.ProducerInfo; import org.apache.activemq.command.Response; import org.apache.activemq.filter.MessageEvaluationContext; import org.apache.activemq.state.ProducerState; import org.apache.activemq.store.MessageStore; import org.apache.activemq.store.PersistenceAdapter; import org.apache.activemq.thread.TaskRunnerFactory; import org.slf4j.Logger; import org.slf4j.LoggerFactory; /** * @author gtully * @see https://issues.apache.org/activemq/browse/AMQ-2020 **/ public class QueueDuplicatesFromStoreTest extends TestCase { private static final Logger LOG = LoggerFactory .getLogger(QueueDuplicatesFromStoreTest.class); ActiveMQQueue destination = new ActiveMQQueue("queue-" + QueueDuplicatesFromStoreTest.class.getSimpleName()); BrokerService brokerService; final static String mesageIdRoot = "11111:22222:"; final int messageBytesSize = 256; final String text = new String(new byte[messageBytesSize]); final int ackStartIndex = 100; final int ackWindow = 50; final int ackBatchSize = 50; final int fullWindow = 200; protected int count = 20000; public void setUp() throws Exception { brokerService = createBroker(); brokerService.setUseJmx(false); brokerService.deleteAllMessages(); brokerService.start(); } protected BrokerService createBroker() throws Exception { return new BrokerService(); } public void tearDown() throws Exception { brokerService.stop(); } public void testNoDuplicateAfterCacheFullAndAckedWithLargeAuditDepth() throws Exception { doTestNoDuplicateAfterCacheFullAndAcked(1024*10); } public void testNoDuplicateAfterCacheFullAndAckedWithSmallAuditDepth() throws Exception { doTestNoDuplicateAfterCacheFullAndAcked(512); } public void doTestNoDuplicateAfterCacheFullAndAcked(final int auditDepth) throws Exception { final PersistenceAdapter persistenceAdapter = brokerService.getPersistenceAdapter(); final MessageStore queueMessageStore = persistenceAdapter.createQueueMessageStore(destination); final ConnectionContext contextNotInTx = new ConnectionContext(); final ConsumerInfo consumerInfo = new ConsumerInfo(); final DestinationStatistics destinationStatistics = new DestinationStatistics(); consumerInfo.setExclusive(true); final Queue queue = new Queue(brokerService, destination, queueMessageStore, destinationStatistics, brokerService.getTaskRunnerFactory()); // a workaround for this issue // queue.setUseCache(false); queue.systemUsage.getMemoryUsage().setLimit(1024 * 1024 * 10); queue.setMaxAuditDepth(auditDepth); queue.initialize(); queue.start(); ProducerBrokerExchange producerExchange = new ProducerBrokerExchange(); ProducerInfo producerInfo = new ProducerInfo(); ProducerState producerState = new ProducerState(producerInfo); producerExchange.setProducerState(producerState); producerExchange.setConnectionContext(contextNotInTx); final CountDownLatch receivedLatch = new CountDownLatch(count); final AtomicLong ackedCount = new AtomicLong(0); final AtomicLong enqueueCounter = new AtomicLong(0); final Vector<String> errors = new Vector Other ActiveMQ examples (source code examples)Here is a short list of links related to this ActiveMQ QueueDuplicatesFromStoreTest.java source code file: |
... this post is sponsored by my books ... | |
#1 New Release! |
FP Best Seller |
Copyright 1998-2021 Alvin Alexander, alvinalexander.com
All Rights Reserved.
A percentage of advertising revenue from
pages under the /java/jwarehouse
URI on this website is
paid back to open source projects.