Search in sources :

Example 1 with BrokerPlugin

use of org.apache.activemq.broker.BrokerPlugin in project fabric8 by jboss-fuse.

the class Activator method start.

@Override
public void start(BundleContext context) throws Exception {
    this.bundleContext = context;
    storageProxy.setContext(context);
    storageProxy.init();
    mbeanServer = lookupMBeanServer();
    if (mbeanServer != null) {
        for (BrokerPlugin plugin : plugins.values()) {
            try {
                mbeanServer.registerMBean(plugin, getObjectName(plugin));
            } catch (Exception e) {
                LOG.warn("An error occured during mbean server unregistration: " + e, e);
            }
        }
    }
    Hashtable<String, Object> props = new Hashtable<String, Object>();
    props.put(Constants.SERVICE_PID, INSIGHT_ACTIVEMQ_PID);
    registration = bundleContext.registerService(ManagedService.class, this, props);
    commandRegistrations = Arrays.asList();
    Activator.INSTANCE = this;
}
Also used : ManagedService(org.osgi.service.cm.ManagedService) Hashtable(java.util.Hashtable) BrokerPlugin(org.apache.activemq.broker.BrokerPlugin) MalformedObjectNameException(javax.management.MalformedObjectNameException) ConfigurationException(org.osgi.service.cm.ConfigurationException)

Example 2 with BrokerPlugin

use of org.apache.activemq.broker.BrokerPlugin in project fabric8 by jboss-fuse.

the class Activator method stop.

@Override
public void stop(BundleContext context) throws Exception {
    Activator.INSTANCE = null;
    for (ServiceRegistration sr : commandRegistrations) {
        sr.unregister();
    }
    registration.unregister();
    if (mbeanServer != null) {
        for (BrokerPlugin plugin : plugins.values()) {
            try {
                mbeanServer.unregisterMBean(getObjectName(plugin));
            } catch (Exception e) {
                LOG.warn("An error occured during mbean server unregistration: " + e, e);
            }
        }
    }
    storageProxy.destroy();
}
Also used : BrokerPlugin(org.apache.activemq.broker.BrokerPlugin) MalformedObjectNameException(javax.management.MalformedObjectNameException) ConfigurationException(org.osgi.service.cm.ConfigurationException) ServiceRegistration(org.osgi.framework.ServiceRegistration)

Example 3 with BrokerPlugin

use of org.apache.activemq.broker.BrokerPlugin in project activemq-artemis by apache.

the class BrokerStatisticsPluginTest method createBroker.

protected BrokerService createBroker() throws Exception {
    BrokerService answer = new BrokerService();
    BrokerPlugin[] plugins = new BrokerPlugin[1];
    plugins[0] = new StatisticsBrokerPlugin();
    answer.setPlugins(plugins);
    answer.setDeleteAllMessagesOnStartup(true);
    answer.addConnector("tcp://localhost:0");
    answer.start();
    return answer;
}
Also used : BrokerPlugin(org.apache.activemq.broker.BrokerPlugin) BrokerService(org.apache.activemq.broker.BrokerService)

Example 4 with BrokerPlugin

use of org.apache.activemq.broker.BrokerPlugin in project activemq-artemis by apache.

the class ThreeBrokerQueueNetworkTest method testNoDuplicateQueueSubsHasLowestPriority.

public void testNoDuplicateQueueSubsHasLowestPriority() throws Exception {
    boolean suppressQueueDuplicateSubscriptions = true;
    boolean decreaseNetworkConsumerPriority = true;
    bridgeAllBrokers("default", 3, suppressQueueDuplicateSubscriptions, decreaseNetworkConsumerPriority);
    // Setup destination
    final Destination dest = createDestination("TEST.FOO", false);
    // delay the advisory messages so that one can percolate fully (cyclically) before the other
    BrokerItem brokerB = brokers.get("BrokerA");
    brokerB.broker.setPlugins(new BrokerPlugin[] { new BrokerPlugin() {

        @Override
        public Broker installPlugin(Broker broker) throws Exception {
            return new BrokerFilter(broker) {

                final AtomicInteger count = new AtomicInteger();

                @Override
                public void preProcessDispatch(MessageDispatch messageDispatch) {
                    if (messageDispatch.getDestination().getPhysicalName().contains("ActiveMQ.Advisory.Consumer")) {
                        // lets delay the first advisory
                        if (count.getAndIncrement() == 0) {
                            LOG.info("Sleeping on first advisory: " + messageDispatch);
                            try {
                                Thread.sleep(2000);
                            } catch (InterruptedException e) {
                                e.printStackTrace();
                            }
                        }
                    }
                    super.postProcessDispatch(messageDispatch);
                }
            };
        }
    } });
    startAllBrokers();
    waitForBridgeFormation();
    // Setup consumers
    String brokerName = "BrokerA";
    createConsumer(brokerName, dest);
    // wait for advisories
    Thread.sleep(5000);
    // verify there is one consumer on each broker, no cycles
    Collection<BrokerItem> brokerList = brokers.values();
    for (Iterator<BrokerItem> i = brokerList.iterator(); i.hasNext(); ) {
        BrokerService broker = i.next().broker;
        verifyConsumerCount(broker, 1, dest);
        if (!brokerName.equals(broker.getBrokerName())) {
            verifyConsumePriority(broker, ConsumerInfo.NETWORK_CONSUMER_PRIORITY, dest);
        }
    }
}
Also used : ActiveMQDestination(org.apache.activemq.command.ActiveMQDestination) Destination(javax.jms.Destination) Broker(org.apache.activemq.broker.Broker) RegionBroker(org.apache.activemq.broker.region.RegionBroker) BrokerPlugin(org.apache.activemq.broker.BrokerPlugin) BrokerFilter(org.apache.activemq.broker.BrokerFilter) MessageDispatch(org.apache.activemq.command.MessageDispatch) AtomicInteger(java.util.concurrent.atomic.AtomicInteger) BrokerService(org.apache.activemq.broker.BrokerService)

Example 5 with BrokerPlugin

use of org.apache.activemq.broker.BrokerPlugin in project activemq-artemis by apache.

the class AuthorizationFromAdminViewTest method createBroker.

private void createBroker() throws Exception {
    broker = BrokerFactory.createBroker("broker:(vm://localhost)");
    broker.setPersistent(false);
    broker.setBrokerName(getName());
    AuthorizationPlugin plugin = new AuthorizationPlugin();
    plugin.setMap(new SimpleAuthorizationMap());
    BrokerPlugin[] plugins = new BrokerPlugin[] { plugin };
    broker.setPlugins(plugins);
    broker.start();
}
Also used : SimpleAuthorizationMap(org.apache.activemq.security.SimpleAuthorizationMap) AuthorizationPlugin(org.apache.activemq.security.AuthorizationPlugin) BrokerPlugin(org.apache.activemq.broker.BrokerPlugin)

Aggregations

BrokerPlugin (org.apache.activemq.broker.BrokerPlugin)10 BrokerService (org.apache.activemq.broker.BrokerService)6 ArrayList (java.util.ArrayList)3 URI (java.net.URI)2 HashMap (java.util.HashMap)2 MalformedObjectNameException (javax.management.MalformedObjectNameException)2 MemoryPersistenceAdapter (org.apache.activemq.store.memory.MemoryPersistenceAdapter)2 ConfigurationException (org.osgi.service.cm.ConfigurationException)2 Hashtable (java.util.Hashtable)1 LinkedList (java.util.LinkedList)1 Map (java.util.Map)1 Properties (java.util.Properties)1 AtomicInteger (java.util.concurrent.atomic.AtomicInteger)1 Destination (javax.jms.Destination)1 Context (javax.naming.Context)1 NamingException (javax.naming.NamingException)1 DataSource (javax.sql.DataSource)1 ActiveMQConnectionFactory (org.apache.activemq.ActiveMQConnectionFactory)1 Broker (org.apache.activemq.broker.Broker)1 BrokerFilter (org.apache.activemq.broker.BrokerFilter)1