@Override public MessageStore createQueueMessageStore(ActiveMQQueue destination) throws IOException { JournalMessageStore store = queues.get(destination); if (store == null) { MessageStore checkpointStore = longTermPersistence.createQueueMessageStore(destination); store = new JournalMessageStore(this, checkpointStore, destination); queues.put(destination, store); } return store; }
@Override public Set<ActiveMQDestination> getDestinations() { Set<ActiveMQDestination> destinations = new HashSet<ActiveMQDestination>(longTermPersistence.getDestinations()); destinations.addAll(queues.keySet()); destinations.addAll(topics.keySet()); return destinations; }
@Override public void gc() throws Exception { brokerService.getBroker().gc(); try { brokerService.getPersistenceAdapter().checkpoint(true); } catch (IOException e) { LOG.error("Failed to checkpoint persistence adapter on gc request", e); } }
private MessageStore findMessageStore(ActiveMQDestination destination) { ProxyMessageStore proxyMessageStore = null; try { if (destination.isQueue()) { proxyMessageStore = (ProxyMessageStore) persistenceAdapter.createQueueMessageStore((ActiveMQQueue) destination); } else { proxyMessageStore = (ProxyMessageStore) persistenceAdapter.createTopicMessageStore((ActiveMQTopic) destination); } } catch (IOException error) { throw new RuntimeException("Failed to find/create message store for destination: " + destination, error); } return proxyMessageStore.getDelegate(); }
@Override public MessageStore createQueueMessageStore(ActiveMQQueue destination) throws IOException { PersistenceAdapter persistenceAdapter = getMatchingPersistenceAdapter(destination); return transactionStore.proxy(persistenceAdapter.createTransactionStore(), persistenceAdapter.createQueueMessageStore(destination)); }
@Override public void removeDestination(Destination dest) { ActiveMQDestination destination = dest.getActiveMQDestination(); if (!destination.isTemporary()) { if (destination.isQueue()) { persistenceAdapter.removeQueueMessageStore((ActiveMQQueue) destination); } else if (!AdvisorySupport.isAdvisoryTopic(destination)) { persistenceAdapter.removeTopicMessageStore((ActiveMQTopic) destination); } } }
@Override public TopicMessageStore createTopicMessageStore(ActiveMQTopic destinationName) throws IOException { JournalTopicMessageStore store = topics.get(destinationName); if (store == null) { TopicMessageStore checkpointStore = longTermPersistence.createTopicMessageStore(destinationName); store = new JournalTopicMessageStore(this, checkpointStore, destinationName); topics.put(destinationName, store); } return store; }
if (isSchedulerSupport()) { SchedulerBroker sb = new SchedulerBroker(this, broker, getJobSchedulerStore()); if (isUseJmx()) { JobSchedulerViewMBean view = new JobSchedulerView(sb.getJobScheduler()); try { this.adminView.setJMSJobScheduler(objectName); } catch (Throwable e) { throw IOExceptionSupport.create("JobScheduler could not be registered in JMX: " + e.getMessage(), e); AnnotatedMBean.registerMBean(getManagementContext(), statusView, objectName); } catch (Throwable e) { throw IOExceptionSupport.create("Status MBean could not be registered in JMX: " + e.getMessage(), e); broker = new TransactionBroker(broker, getPersistenceAdapter().createTransactionStore()); if (isPopulateJMSXUserID()) { UserIDBroker userIDBroker = new UserIDBroker(broker);
@Override public void run() { Thread.currentThread().setContextClassLoader(ActiveMQResourceAdapter.class.getClassLoader()); try { //Start before returning - this is known to be safe. if (!bs.isStarted()) { Logger .getInstance(LogCategory.OPENEJB_STARTUP, ActiveMQ5Factory.class) .getChildLogger("service") .info("Starting ActiveMQ BrokerService"); bs.start(); } bs.waitUntilStarted(); //Force a checkpoint to initialize pools Logger .getInstance(LogCategory.OPENEJB_STARTUP, ActiveMQ5Factory.class) .getChildLogger("service") .info("Starting ActiveMQ checkpoint"); bs.getPersistenceAdapter().checkpoint(true); started.set(true); } catch (final Throwable t) { throwable = t; } } };
if (isSchedulerSupport()) { SchedulerBroker sb = new SchedulerBroker(broker, getSchedulerDirectoryFile()); if (isUseJmx()) { JobSchedulerViewMBean view = new JobSchedulerView(sb.getJobScheduler()); try { this.adminView.setJMSJobScheduler(objectName); } catch (Throwable e) { throw IOExceptionSupport.create("JobScheduler could not be registered in JMX: " + e.getMessage(), e); broker = new TransactionBroker(broker, getPersistenceAdapter().createTransactionStore()); if (isPopulateJMSXUserID()) { UserIDBroker userIDBroker = new UserIDBroker(broker);
private void doStartPersistenceAdapter() throws Exception { PersistenceAdapter persistenceAdapterToStart = getPersistenceAdapter(); if (persistenceAdapterToStart == null) { checkStartException(); throw new ConfigurationException("Cannot start null persistence adapter"); persistenceAdapterToStart.setUsageManager(getProducerSystemUsage()); persistenceAdapterToStart.setBrokerName(getBrokerName()); LOG.info("Using Persistence Adapter: {}", persistenceAdapterToStart); if (deleteAllMessagesOnStartup) { deleteAllMessages(); persistenceAdapterToStart.start(); getTempDataStore();
@Override public void deleteAllMessages() throws IOException { try { JournalTrace trace = new JournalTrace(); trace.setMessage("DELETED"); RecordLocation location = journal.write(toPacket(wireFormat.marshal(trace)), false); journal.setMark(location, true); LOG.info("Journal deleted: "); } catch (IOException e) { throw e; } catch (Throwable e) { throw IOExceptionSupport.create(e); } longTermPersistence.deleteAllMessages(); }
if (destination.isQueue()) { if (destination.isTemporary()) { final ActiveMQTempDestination tempDest = (ActiveMQTempDestination)destination; Queue queue = new TempQueue(brokerService, destination, null, destinationStatistics, taskRunnerFactory); return queue; } else { MessageStore store = persistenceAdapter.createQueueMessageStore((ActiveMQQueue)destination); Queue queue = new Queue(brokerService, destination, store, destinationStatistics, taskRunnerFactory); configureQueue(queue, destination); return queue; } else if (destination.isTemporary()) { TopicMessageStore store = null; if (!AdvisorySupport.isAdvisoryTopic(destination)) { store = persistenceAdapter.createTopicMessageStore((ActiveMQTopic)destination);
wireFormat.setVersion(brokerService.getStoreOpenWireVersion()); this.usageManager.getMemoryUsage().addUsageListener(this); longTermPersistence.start(); createTransactionStore(); recover();
/** * Delete all messages from the persistent store * * @throws IOException */ public void deleteAllMessages() throws IOException { getPersistenceAdapter().deleteAllMessages(); }
/** * Searches the set of subscriptions from the given persistence adapter and returns all those * that belong to the given ClientId value. * * @param adapter * the persistence adapter instance to search within. * @param clientId * the client ID value used to filter the subscription set. * * @return a list of all subscriptions belonging to the given client. * * @throws IOException if an error occurs while listing the stored subscriptions. */ static public List<SubscriptionInfo> listSubscriptions(PersistenceAdapter adapter, String clientId) throws IOException { ArrayList<SubscriptionInfo> rc = new ArrayList<SubscriptionInfo>(); for (ActiveMQDestination destination : adapter.getDestinations()) { if (destination.isTopic()) { TopicMessageStore store = adapter.createTopicMessageStore((ActiveMQTopic) destination); for (SubscriptionInfo sub : store.getAllSubscriptions()) { if (clientId == sub.getClientId() || clientId.equals(sub.getClientId())) { rc.add(sub); } } } } return rc; }
/** * Provides a means of querying the persistence adapter for a list of ActiveMQQueue instances * that match some given search criteria. * * @param adapter * the persistence adapter instance to query. * @param matcher * the DestinationMatcher instance used to find the target destinations. * * @return a List<ActiveMQQeue> with all the matching destinations. * * @throws IOException if an error occurs while reading the destinations. */ static public List<ActiveMQQueue> listQueues(PersistenceAdapter adapter, DestinationMatcher matcher) throws IOException { ArrayList<ActiveMQQueue> rc = new ArrayList<ActiveMQQueue>(); for (ActiveMQDestination destination : adapter.getDestinations()) { if (destination.isQueue() && matcher.matches(destination)) { rc.add((ActiveMQQueue) destination); } } return rc; }
public void testAddRemoveConsumerDest() throws Exception { ActiveMQQueue consumerQ = new ActiveMQQueue("Consumer.A.VirtualTopicTest"); MessageStore ms = pa.createQueueMessageStore(consumerQ); pa.removeQueueMessageStore(consumerQ); assertFalse(pa.getDestinations().contains(consumerQ)); }
/** * Provides a means of querying the persistence adapter for a list of ActiveMQTopic instances * that match some given search criteria. * * @param adapter * the persistence adapter instance to query. * @param matcher * the DestinationMatcher instance used to find the target destinations. * * @return a List<ActiveMQTopic> with all the matching destinations. * * @throws IOException if an error occurs while reading the destinations. */ static public List<ActiveMQTopic> listTopics(PersistenceAdapter adapter, DestinationMatcher matcher) throws IOException { ArrayList<ActiveMQTopic> rc = new ArrayList<ActiveMQTopic>(); for (ActiveMQDestination destination : adapter.getDestinations()) { if (destination.isTopic() && matcher.matches(destination)) { rc.add((ActiveMQTopic) destination); } } return rc; }
@Override public void removeQueueMessageStore(ActiveMQQueue destination) { PersistenceAdapter adapter = null; try { adapter = getMatchingPersistenceAdapter(destination); } catch (IOException e) { throw new RuntimeException(e); } if (adapter instanceof PersistenceAdapter && adapter.getDestinations().isEmpty()) { adapter.removeQueueMessageStore(destination); removeMessageStore(adapter, destination); destinationMap.remove(destination, adapter); } }