@Override public String getAddressInfo(String address) throws ActiveMQAddressDoesNotExistException { checkStarted(); clearIO(); try { final AddressInfo addressInfo = server.getAddressInfo(SimpleString.toSimpleString(address)); if (addressInfo == null) { throw ActiveMQMessageBundle.BUNDLE.addressDoesNotExist(SimpleString.toSimpleString(address)); } else { return AddressInfoTextFormatter.Long.format(addressInfo, new StringBuilder()).toString(); } } finally { blockOnIO(); } }
public void registerAcceptor(final int id, final InVMAcceptor acceptor) { if (acceptors.putIfAbsent(id, acceptor) != null) { throw ActiveMQMessageBundle.BUNDLE.acceptorExists(id); } }
public void unregisterAcceptor(final int id) { if (acceptors.remove(id) == null) { throw ActiveMQMessageBundle.BUNDLE.acceptorNotExists(id); } }
/** * Creates a Queue if it doesn't already exist, based on a topic and address. Returning the queue name. */ private Queue createQueueForSubscription(String address, int qos) throws Exception { // Check to see if a subscription queue already exists. SimpleString queue = getQueueNameForTopic(address); Queue q = session.getServer().locateQueue(queue); // The queue does not exist so we need to create it. if (q == null) { SimpleString sAddress = SimpleString.toSimpleString(address); // Check we can auto create queues. BindingQueryResult bindingQueryResult = session.getServerSession().executeBindingQuery(sAddress); if (!bindingQueryResult.isAutoCreateQueues()) { throw ActiveMQMessageBundle.BUNDLE.noSuchQueue(sAddress); } // Check that the address exists, if not we try to auto create it. AddressInfo addressInfo = session.getServerSession().getAddress(sAddress); if (addressInfo == null) { if (!bindingQueryResult.isAutoCreateAddresses()) { throw ActiveMQMessageBundle.BUNDLE.addressDoesNotExist(SimpleString.toSimpleString(address)); } addressInfo = session.getServerSession().createAddress(SimpleString.toSimpleString(address), RoutingType.MULTICAST, true); } return findOrCreateQueue(bindingQueryResult, addressInfo, queue, qos); } return q; }
throw ActiveMQMessageBundle.BUNDLE.invalidQueueName(queueName); return binding.getQueue(); } else { throw ActiveMQMessageBundle.BUNDLE.queueAlreadyExists(realQueueName, binding.getAddress()); throw ActiveMQMessageBundle.BUNDLE.addressDoesNotExist(addressToUse); } else if (!info.getRoutingTypes().contains(rt)) { throw ActiveMQMessageBundle.BUNDLE.invalidRoutingTypeForAddress(rt, info.getName().toString(), info.getRoutingTypes());
@Override public String updateQueue(String name, String routingType, String filter, Integer maxConsumers, Boolean purgeOnNoConsumers, Boolean exclusive, Boolean nonDestructive, Integer consumersBeforeDispatch, Long delayBeforeDispatch, String user) throws Exception { checkStarted(); clearIO(); try { final Queue queue = server.updateQueue(name, routingType != null ? RoutingType.valueOf(routingType) : null, filter, maxConsumers, purgeOnNoConsumers, exclusive, nonDestructive, consumersBeforeDispatch, delayBeforeDispatch, user); if (queue == null) { throw ActiveMQMessageBundle.BUNDLE.noSuchQueue(new SimpleString(name)); } return QueueTextFormatter.Long.format(queue, new StringBuilder()).toString(); } finally { blockOnIO(); } }
throw ActiveMQMessageBundle.BUNDLE.noSuchQueue(queueName); throw ActiveMQMessageBundle.BUNDLE.cannotDeleteQueueWithConsumers(queue.getName(), queueName, binding.getClass().getName()); throw ActiveMQMessageBundle.BUNDLE.cannotDeleteQueueWithMessages(queue.getName(), queueName, messageCount);
throw ActiveMQMessageBundle.BUNDLE.invalidJournal(); break; default: throw ActiveMQMessageBundle.BUNDLE.invalidJournalType2(config.getJournalType());
private static SequentialFileFactory newFactory(File datafolder, boolean datasync, JournalType journalType, int fileSize, int maxAIO) { SequentialFileFactory factory; if (journalType == JournalType.ASYNCIO && !LibaioContext.isLoaded()) { journalType = JournalType.NIO; } switch (journalType) { case NIO: factory = new NIOSequentialFileFactory(datafolder, 1).setDatasync(datasync); ((NIOSequentialFileFactory) factory).disableBufferReuse(); factory.start(); return factory; case ASYNCIO: factory = new AIOSequentialFileFactory(datafolder, maxAIO).setDatasync(datasync); factory.start(); ((AIOSequentialFileFactory) factory).disableBufferReuse(); return factory; case MAPPED: factory = new MappedSequentialFileFactory(datafolder, fileSize, false, 0, 0, null) .setDatasync(datasync) .disableBufferReuse(); factory.start(); return factory; default: throw ActiveMQMessageBundle.BUNDLE.invalidJournalType2(journalType); } } }
private Queue findOrCreateQueue(BindingQueryResult bindingQueryResult, AddressInfo addressInfo, SimpleString queue, int qos) throws Exception { if (addressInfo.getRoutingTypes().contains(RoutingType.MULTICAST)) { return session.getServerSession().createQueue(addressInfo.getName(), queue, RoutingType.MULTICAST, managementFilter, false, MQTTUtil.DURABLE_MESSAGES && qos >= 0, false); } if (addressInfo.getRoutingTypes().contains(RoutingType.ANYCAST)) { if (!bindingQueryResult.getQueueNames().isEmpty()) { SimpleString name = null; for (SimpleString qName : bindingQueryResult.getQueueNames()) { if (name == null) { name = qName; } else if (qName.equals(addressInfo.getName())) { name = qName; } } return session.getServer().locateQueue(name); } else { try { return session.getServerSession().createQueue(addressInfo.getName(), addressInfo.getName(), RoutingType.ANYCAST, managementFilter, false, MQTTUtil.DURABLE_MESSAGES && qos >= 0, false); } catch (ActiveMQQueueExistsException e) { return session.getServer().locateQueue(addressInfo.getName()); } } } Set<RoutingType> routingTypeSet = new HashSet(); routingTypeSet.add(RoutingType.MULTICAST); routingTypeSet.add(RoutingType.ANYCAST); throw ActiveMQMessageBundle.BUNDLE.invalidRoutingTypeForAddress(addressInfo.getRoutingType(), addressInfo.getName().toString(), routingTypeSet); }
/** * Transfers the Netty channel that has been created outside of this NettyAcceptor * to control it and configure it according to this NettyAcceptor setting. * * @param channel A Netty channel created outside this NettyAcceptor. */ public void transfer(Channel channel) { if (paused || eventLoopGroup == null) { throw ActiveMQMessageBundle.BUNDLE.acceptorUnavailable(); } channel.pipeline().addLast(protocolHandler.getProtocolDecoder()); }
@Override public String createAddress(String name, String routingTypes) throws Exception { checkStarted(); clearIO(); try { EnumSet<RoutingType> set = EnumSet.noneOf(RoutingType.class); for (String routingType : ListUtil.toList(routingTypes)) { set.add(RoutingType.valueOf(routingType)); } final AddressInfo addressInfo = new AddressInfo(new SimpleString(name), set); if (server.addAddressInfo(addressInfo)) { return AddressInfoTextFormatter.Long.format(addressInfo, new StringBuilder()).toString(); } else { throw ActiveMQMessageBundle.BUNDLE.addressAlreadyExists(addressInfo.getName()); } } finally { blockOnIO(); } }
logger.trace("starting activation"); activationThread = new ActivationThread(activation, ActiveMQMessageBundle.BUNDLE.activationForServer(this)); activationThread.start(); logger.trace("starting backupActivation"); activationThread = new ActivationThread(activation, ActiveMQMessageBundle.BUNDLE.activationForServer(this)); activationThread.start(); } else {
/** * Creates a Queue if it doesn't already exist, based on a topic and address. Returning the queue name. */ private Queue createQueueForSubscription(String address, int qos) throws Exception { // Check to see if a subscription queue already exists. SimpleString queue = getQueueNameForTopic(address); Queue q = session.getServer().locateQueue(queue); // The queue does not exist so we need to create it. if (q == null) { SimpleString sAddress = SimpleString.toSimpleString(address); // Check we can auto create queues. BindingQueryResult bindingQueryResult = session.getServerSession().executeBindingQuery(sAddress); if (!bindingQueryResult.isAutoCreateQueues()) { throw ActiveMQMessageBundle.BUNDLE.noSuchQueue(sAddress); } // Check that the address exists, if not we try to auto create it. AddressInfo addressInfo = session.getServerSession().getAddress(sAddress); if (addressInfo == null) { if (!bindingQueryResult.isAutoCreateAddresses()) { throw ActiveMQMessageBundle.BUNDLE.addressDoesNotExist(SimpleString.toSimpleString(address)); } addressInfo = session.getServerSession().createAddress(SimpleString.toSimpleString(address), RoutingType.MULTICAST, true); } return findOrCreateQueue(bindingQueryResult, addressInfo, queue, qos); } return q; }
@Override public void destroyQueue(final SimpleString queueName, final SecurityAuth session, final boolean checkConsumerCount, final boolean removeConsumers) throws Exception { if (postOffice == null) { return; } Binding binding = postOffice.getBinding(queueName); if (binding == null) { throw ActiveMQMessageBundle.BUNDLE.noSuchQueue(queueName); } String address = binding.getAddress().toString(); destroyQueue(queueName, session, checkConsumerCount, removeConsumers, addressSettingsRepository.getMatch(address).isAutoDeleteAddresses()); }
private static SequentialFileFactory newFactory(File datafolder, boolean datasync, JournalType journalType, int fileSize, int maxAIO) { SequentialFileFactory factory; if (journalType == JournalType.ASYNCIO && !LibaioContext.isLoaded()) { journalType = JournalType.NIO; } switch (journalType) { case NIO: factory = new NIOSequentialFileFactory(datafolder, 1).setDatasync(datasync); ((NIOSequentialFileFactory) factory).disableBufferReuse(); factory.start(); return factory; case ASYNCIO: factory = new AIOSequentialFileFactory(datafolder, maxAIO).setDatasync(datasync); factory.start(); ((AIOSequentialFileFactory) factory).disableBufferReuse(); return factory; case MAPPED: factory = new MappedSequentialFileFactory(datafolder, fileSize, false, 0, 0, null) .setDatasync(datasync) .disableBufferReuse(); factory.start(); return factory; default: throw ActiveMQMessageBundle.BUNDLE.invalidJournalType2(journalType); } } }
private Queue findOrCreateQueue(BindingQueryResult bindingQueryResult, AddressInfo addressInfo, SimpleString queue, int qos) throws Exception { if (addressInfo.getRoutingTypes().contains(RoutingType.MULTICAST)) { return session.getServerSession().createQueue(addressInfo.getName(), queue, RoutingType.MULTICAST, managementFilter, false, MQTTUtil.DURABLE_MESSAGES && qos >= 0, false); } if (addressInfo.getRoutingTypes().contains(RoutingType.ANYCAST)) { if (!bindingQueryResult.getQueueNames().isEmpty()) { SimpleString name = null; for (SimpleString qName : bindingQueryResult.getQueueNames()) { if (name == null) { name = qName; } else if (qName.equals(addressInfo.getName())) { name = qName; } } return session.getServer().locateQueue(name); } else { try { return session.getServerSession().createQueue(addressInfo.getName(), addressInfo.getName(), RoutingType.ANYCAST, managementFilter, false, MQTTUtil.DURABLE_MESSAGES && qos >= 0, false); } catch (ActiveMQQueueExistsException e) { return session.getServer().locateQueue(addressInfo.getName()); } } } Set<RoutingType> routingTypeSet = new HashSet(); routingTypeSet.add(RoutingType.MULTICAST); routingTypeSet.add(RoutingType.ANYCAST); throw ActiveMQMessageBundle.BUNDLE.invalidRoutingTypeForAddress(addressInfo.getRoutingType(), addressInfo.getName().toString(), routingTypeSet); }
/** * Checks to see if this destination exists. If it does not throw an invalid destination exception. * * @param destination */ private void validateDestination(ActiveMQDestination destination) throws Exception { if (destination.isQueue()) { SimpleString physicalName = new SimpleString(destination.getPhysicalName()); BindingQueryResult result = server.bindingQuery(physicalName); if (!result.isExists() && !result.isAutoCreateQueues()) { throw ActiveMQMessageBundle.BUNDLE.noSuchQueue(physicalName); } } }
@Override public String updateAddress(String name, String routingTypes) throws Exception { checkStarted(); clearIO(); try { final EnumSet<RoutingType> routingTypeSet; if (routingTypes == null) { routingTypeSet = null; } else { routingTypeSet = EnumSet.noneOf(RoutingType.class); final String[] routingTypeNames = routingTypes.split(","); for (String routingTypeName : routingTypeNames) { routingTypeSet.add(RoutingType.valueOf(routingTypeName)); } } if (!server.updateAddressInfo(SimpleString.toSimpleString(name), routingTypeSet)) { throw ActiveMQMessageBundle.BUNDLE.addressDoesNotExist(SimpleString.toSimpleString(name)); } return AddressInfoTextFormatter.Long.format(server.getAddressInfo(SimpleString.toSimpleString(name)), new StringBuilder()).toString(); } finally { blockOnIO(); } }
throw ActiveMQMessageBundle.BUNDLE.noSuchQueue(unPrefixedQueueName);