Package org.apache.activemq.broker.region

Examples of org.apache.activemq.broker.region.RegionBroker


            verifyConsumerCount(broker, 0, dest);
        }
    }

    private void verifyConsumerCount(BrokerService broker, int count, final Destination dest) throws Exception {
        final RegionBroker regionBroker = (RegionBroker) broker.getRegionBroker();
        waitFor(new Condition() {
            public boolean isSatisified() throws Exception {
                return !regionBroker.getDestinations(ActiveMQDestination.transform(dest)).isEmpty();
            }
        });
        Queue internalQueue = (Queue) regionBroker.getDestinations(ActiveMQDestination.transform(dest)).iterator().next();
        assertEquals("consumer count on " + broker.getBrokerName() + " matches for q: " + internalQueue, count, internalQueue.getConsumers().size());     
    }
View Full Code Here


        Queue internalQueue = (Queue) regionBroker.getDestinations(ActiveMQDestination.transform(dest)).iterator().next();
        assertEquals("consumer count on " + broker.getBrokerName() + " matches for q: " + internalQueue, count, internalQueue.getConsumers().size());     
    }

    private void verifyConsumePriority(BrokerService broker, byte expectedPriority, Destination dest) throws Exception {
        RegionBroker regionBroker = (RegionBroker) broker.getRegionBroker();
        Queue internalQueue = (Queue) regionBroker.getDestinations(ActiveMQDestination.transform(dest)).iterator().next();
        for (Subscription consumer : internalQueue.getConsumers()) {
            assertEquals("consumer on " + broker.getBrokerName() + " matches priority: " + internalQueue, expectedPriority, consumer.getConsumerInfo().getPriority());     
        }
    }
View Full Code Here

        }
        return found;
    }

    protected final Collection<Subscription> getRegionSubscriptions(ActiveMQDestination dest) {
        RegionBroker region_broker = (RegionBroker) brokerService.getRegionBroker();
        Region region;
        Collection<Subscription> subs;

        region = null;
        switch (dest.getDestinationType()) {
            case ActiveMQDestination.QUEUE_TYPE:
                region = region_broker.getQueueRegion();
                break;
            case ActiveMQDestination.TOPIC_TYPE:
                region = region_broker.getTopicRegion();
                break;
            case ActiveMQDestination.TEMP_QUEUE_TYPE:
                region = region_broker.getTempQueueRegion();
                break;
            case ActiveMQDestination.TEMP_TOPIC_TYPE:
                region = region_broker.getTempTopicRegion();
                break;
        }

        if (region instanceof AbstractRegion) {
            subs = ((AbstractRegion) region).getSubscriptions().values();
View Full Code Here

        }
        return createRegionBroker(destinationInterceptor);
    }

    protected Broker createRegionBroker(DestinationInterceptor destinationInterceptor) throws IOException {
        RegionBroker regionBroker;
        if (isUseJmx()) {
            try {
                regionBroker = new ManagedRegionBroker(this, getManagementContext(), getBrokerObjectName(),
                    getTaskRunnerFactory(), getConsumerSystemUsage(), destinationFactory, destinationInterceptor,getScheduler(),getExecutor());
            } catch(MalformedObjectNameException me){
                LOG.warn("Cannot create ManagedRegionBroker due " + me.getMessage(), me);
                throw new IOException(me);
            }
        } else {
            regionBroker = new RegionBroker(this, getTaskRunnerFactory(), getConsumerSystemUsage(), destinationFactory,
                    destinationInterceptor,getScheduler(),getExecutor());
        }
        destinationFactory.setRegionBroker(regionBroker);
        regionBroker.setKeepDurableSubsActive(keepDurableSubsActive);
        regionBroker.setBrokerName(getBrokerName());
        regionBroker.getDestinationStatistics().setEnabled(enableStatistics);
        regionBroker.setAllowTempAutoCreationOnSend(isAllowTempAutoCreationOnSend());
        if (brokerId != null) {
            regionBroker.setBrokerId(brokerId);
        }
        return regionBroker;
    }
View Full Code Here

    }

    @Override
    void rollbackStatsOnDuplicate(KahaDestination commandDestination) {
        if (brokerService != null) {
            RegionBroker regionBroker = (RegionBroker) brokerService.getRegionBroker();
            if (regionBroker != null) {
                Set<Destination> destinationSet = regionBroker.getDestinations(convert(commandDestination));
                for (Destination destination : destinationSet) {
                    destination.getDestinationStatistics().getMessages().decrement();
                    destination.getDestinationStatistics().getEnqueues().decrement();
                }
            }
View Full Code Here

            boolean brokerStats = physicalName.regionMatches(true, 0, STATS_BROKER_PREFIX, 0, STATS_BROKER_PREFIX
                    .length());
            boolean subStats = physicalName.regionMatches(true, 0, STATS_SUBSCRIPTION_PREFIX, 0, STATS_SUBSCRIPTION_PREFIX
                    .length());
            BrokerService brokerService = getBrokerService();
            RegionBroker regionBroker = (RegionBroker) brokerService.getRegionBroker();
            if (destStats) {
                String destinationName = physicalName.substring(STATS_DESTINATION_PREFIX.length(), physicalName.length());
                String destinationQuery = destinationName.replace(STATS_DENOTE_END_LIST,"");
                boolean endListMessage = !destinationName.equals(destinationQuery);
                ActiveMQDestination queryDestination = ActiveMQDestination.createDestination(destinationQuery,msgDest.getDestinationType());
                Set<Destination> destinations = getDestinations(queryDestination);

                for (Destination dest : destinations) {
                    DestinationStatistics stats = dest.getDestinationStatistics();
                    if (stats != null) {
                        ActiveMQMapMessage statsMessage = new ActiveMQMapMessage();
                        statsMessage.setString("destinationName", dest.getActiveMQDestination().toString());
                        statsMessage.setLong("size", stats.getMessages().getCount());
                        statsMessage.setLong("enqueueCount", stats.getEnqueues().getCount());
                        statsMessage.setLong("dequeueCount", stats.getDequeues().getCount());
                        statsMessage.setLong("dispatchCount", stats.getDispatched().getCount());
                        statsMessage.setLong("expiredCount", stats.getExpired().getCount());
                        statsMessage.setLong("inflightCount", stats.getInflight().getCount());
                        statsMessage.setLong("messagesCached", stats.getMessagesCached().getCount());
                        statsMessage.setDouble("averageMessageSize", stats.getMessageSize().getAveragePerSecond());
                        statsMessage.setInt("memoryPercentUsage", dest.getMemoryUsage().getPercentUsage());
                        statsMessage.setLong("memoryUsage", dest.getMemoryUsage().getUsage());
                        statsMessage.setLong("memoryLimit", dest.getMemoryUsage().getLimit());
                        statsMessage.setDouble("averageEnqueueTime", stats.getProcessTime().getAverageTime());
                        statsMessage.setDouble("maxEnqueueTime", stats.getProcessTime().getMaxTime());
                        statsMessage.setDouble("minEnqueueTime", stats.getProcessTime().getMinTime());
                        statsMessage.setLong("consumerCount", stats.getConsumers().getCount());
                        statsMessage.setLong("producerCount", stats.getProducers().getCount());
                        statsMessage.setJMSCorrelationID(messageSend.getCorrelationId());
                        sendStats(producerExchange.getConnectionContext(), statsMessage, replyTo);
                    }
                }
                if(endListMessage){
                    ActiveMQMapMessage statsMessage = new ActiveMQMapMessage();
                    statsMessage.setJMSCorrelationID(messageSend.getCorrelationId());
                    sendStats(producerExchange.getConnectionContext(),statsMessage,replyTo);
                }

            } else if (subStats) {
                sendSubStats(producerExchange.getConnectionContext(), getBrokerView().getQueueSubscribers(), replyTo);
                sendSubStats(producerExchange.getConnectionContext(), getBrokerView().getTopicSubscribers(), replyTo);
            } else if (brokerStats) {

                if (messageSend.getProperties().containsKey(STATS_BROKER_RESET_HEADER)) {
                    getBrokerView().resetStatistics();
                }

                ActiveMQMapMessage statsMessage = new ActiveMQMapMessage();
                SystemUsage systemUsage = brokerService.getSystemUsage();
                DestinationStatistics stats = regionBroker.getDestinationStatistics();
                statsMessage.setString("brokerName", regionBroker.getBrokerName());
                statsMessage.setString("brokerId", regionBroker.getBrokerId().toString());
                statsMessage.setLong("size", stats.getMessages().getCount());
                statsMessage.setLong("enqueueCount", stats.getEnqueues().getCount());
                statsMessage.setLong("dequeueCount", stats.getDequeues().getCount());
                statsMessage.setLong("dispatchCount", stats.getDispatched().getCount());
                statsMessage.setLong("expiredCount", stats.getExpired().getCount());
View Full Code Here

     */
    public TransportConnection(TransportConnector connector, final Transport transport, Broker broker,
                               TaskRunnerFactory taskRunnerFactory, TaskRunnerFactory stopTaskRunnerFactory) {
        this.connector = connector;
        this.broker = broker;
        RegionBroker rb = (RegionBroker) broker.getAdaptor(RegionBroker.class);
        brokerConnectionStates = rb.getConnectionStates();
        if (connector != null) {
            this.statistics.setParent(connector.getStatistics());
            this.messageAuthorizationPolicy = connector.getMessageAuthorizationPolicy();
        }
        this.taskRunnerFactory = taskRunnerFactory;
View Full Code Here

            addNew(candidate);
        }
    }

    private void applyRetrospectively(PolicyEntry updatedEntry) {
        RegionBroker regionBroker = (RegionBroker) getBrokerService().getRegionBroker();
        for (Destination destination : regionBroker.getDestinations(updatedEntry.getDestination())) {
            if (destination.getActiveMQDestination().isQueue()) {
                updatedEntry.update((Queue) destination);
            } else if (destination.getActiveMQDestination().isTopic()) {
                updatedEntry.update((Topic) destination);
            }
View Full Code Here

                        interceptorsList.addAll(Arrays.asList(getBrokerService().getDestinationInterceptors()));
                        interceptorsList.add(virtualDestinationInterceptor);

                        DestinationInterceptor[] destinationInterceptors = interceptorsList.toArray(new DestinationInterceptor[]{});
                        getBrokerService().setDestinationInterceptors(destinationInterceptors);
                        RegionBroker regionBroker = (RegionBroker) getBrokerService().getRegionBroker();
                        ((CompositeDestinationInterceptor) regionBroker.getDestinationInterceptor()).setInterceptors(destinationInterceptors);
                        info("applied new: " + interceptorsList);
                    }
                }
            });
        } else if (o instanceof DtoPolicyEntry) {
View Full Code Here

        }
        return destination;
    }
   
    private void validateConsumerPrefetch(String destination, long expectedCount) {
        RegionBroker regionBroker = (RegionBroker) broker.getRegionBroker();
        for (org.apache.activemq.broker.region.Destination dest : regionBroker.getQueueRegion().getDestinationMap().values()) {
            if (dest.getName().equals(destination)) {
                DestinationStatistics stats = dest.getDestinationStatistics();
                LOG.info("inflight for : " + dest.getName() + ": " + stats.getInflight().getCount());
                assertEquals("inflight for: " + dest.getName() + ": " + stats.getInflight().getCount() + " matches",
                        expectedCount, stats.getInflight().getCount());     
View Full Code Here

TOP

Related Classes of org.apache.activemq.broker.region.RegionBroker

Copyright © 2018 www.massapicom. All rights reserved.
All source code are property of their respective owners. Java is a trademark of Sun Microsystems, Inc and owned by ORACLE Inc. Contact coftware#gmail.com.