Tabnine Logo
Broker
Code IndexAdd Tabnine to your IDE (free)

How to use
Broker
in
org.apache.activemq.broker

Best Java code snippets using org.apache.activemq.broker.Broker (Showing top 20 results out of 729)

Refine searchRefine arrow

  • BrokerService
  • ConnectionContext
  • Message
  • ActiveMQDestination
  • Destination
  • ProducerInfo
  • CountStatisticImpl
origin: apache/activemq

int match = sub.getActiveMQDestination().compareTo(next.getActiveMQDestination());
if (match == 0 || (!next.getActiveMQDestination().isPattern() && match == 1)) {
  super.addSubscription(context, sub);
  final RegionBroker regionBroker = (RegionBroker) context.getBroker().getAdaptor(RegionBroker.class);
  final Set<Destination> virtualDests = regionBroker.getDestinations(virtualDestination);
    if (virtualDest.getActiveMQDestination().isTopic() &&
        (virtualDest.isAlwaysRetroactive() || sub.getConsumerInfo().isRetroactive())) {
          final Message copy = message.copy();
          copy.setOriginalDestination(message.getDestination());
          copy.setDestination(newDestination);
          if (regionDest == null) {
origin: apache/activemq

public boolean checkQueueSize(String queueName) {
  long count = 0;
  long queueSize = 0;
  Map<ActiveMQDestination, Destination> destinationMap = regionBroker.getDestinationMap();
  for (Map.Entry<ActiveMQDestination, Destination> entry : destinationMap.entrySet()) {
    if (entry.getKey().isQueue()) {
      if (entry.getValue().getName().matches(queueName)) {
        queueSize = entry.getValue().getDestinationStatistics().getMessages().getCount();
        count += queueSize;
        if (queueSize > 0) {
          LOG.info("Queue has pending message: {} queueSize is: {}", entry.getValue().getName(), queueSize);
        }
      }
    }
  }
  return count == 0;
}
origin: gocd/gocd

public void removeQueue(String queueName) {
  try {
    ActiveMQQueue destination = new ActiveMQQueue(queueName);
    ConnectionContext connectionContext = BrokerSupport.getConnectionContext(broker.getBroker());
    Destination brokerDestination = broker.getDestination(destination);
    List<Subscription> consumers = brokerDestination.getConsumers();
    for (Subscription consumer : consumers) {
      consumer.remove(connectionContext, brokerDestination);
      brokerDestination.removeSubscription(connectionContext, consumer, 0);
    }
    broker.getBroker().removeDestination(connectionContext, destination, 1000);
    broker.removeDestination(destination);
  } catch (Exception e) {
    throw bomb(e);
  }
}
origin: apache/activemq

Broker broker = multiKahaDBPersistenceAdapter.getBrokerService().getBroker();
for (TransactionId txid : broker.getPreparedTransactions(null)) {
  if (multiKahaDBPersistenceAdapter.isLocalXid(txid)) {
    try {
      if (recoveredPendingCommit.contains(txid)) {
        LOG.info("delivering pending commit outcome for tid: " + txid);
        broker.commitTransaction(null, txid, false);
        broker.forgetTransaction(null, txid);
origin: apache/activemq

@Override
protected void send(final ProducerBrokerExchange context, final Message message, ActiveMQDestination destination) throws Exception {
  final Broker broker = context.getConnectionContext().getBroker();
  final Set<Destination> destinations = broker.getDestinations(destination);
  final int numDestinations = destinations.size();
      final BrokerService brokerService = broker.getBrokerService();
          brokerService.getTaskRunnerFactory().execute(new Runnable() {
            @Override
            public void run() {
        if (shouldDispatch(broker, message, dest)) {
          try {
            dest.send(context, copy(message, dest.getActiveMQDestination()));
          } catch (ResourceAllocationException e) {
            if (!dropMessageOnResourceLimit) {
origin: org.apache.activemq/activemq-all

@Override
protected void onRecovered(Tx tx) {
  for (RemoveMessageCommand removeMessageCommand: tx.acks) {
    if (removeMessageCommand instanceof LastAckCommand) {
      LastAckCommand lastAckCommand = (LastAckCommand) removeMessageCommand;
      JDBCTopicMessageStore jdbcTopicMessageStore = (JDBCTopicMessageStore) topicStores.get(lastAckCommand.getMessageAck().getDestination());
      jdbcTopicMessageStore.pendingCompletion(lastAckCommand.getClientId(), lastAckCommand.getSubName(), lastAckCommand.getSequence(), lastAckCommand.getPriority());
      lastAckCommand.setMessageStore(jdbcTopicMessageStore);
    } else {
      // when reading the store we ignore messages with non null XIDs but should include those with XIDS starting in - (pending acks in an xa transaction),
      // but the sql is non portable to match BLOB with LIKE etc
      // so we make up for it when we recover the ack
      ((JDBCPersistenceAdapter)persistenceAdapter).getBrokerService().getRegionBroker().getDestinationMap().get(removeMessageCommand.getMessageAck().getDestination()).getDestinationStatistics().getMessages().increment();
    }
  }
  for (AddMessageCommand addMessageCommand : tx.messages) {
    ActiveMQDestination destination = addMessageCommand.getMessage().getDestination();
    addMessageCommand.setMessageStore(destination.isQueue() ? queueStores.get(destination) : topicStores.get(destination));
  }
}
origin: apache/activemq

private void fireFailedForwardAdvisory(MessageDispatch messageDispatch, Throwable error) {
  if (configuration.isAdvisoryForFailedForward()) {
    AdvisoryBroker advisoryBroker = null;
    try {
      advisoryBroker = (AdvisoryBroker) brokerService.getBroker().getAdaptor(AdvisoryBroker.class);
      if (advisoryBroker != null) {
        ConnectionContext context = new ConnectionContext();
        context.setSecurityContext(SecurityContext.BROKER_SECURITY_CONTEXT);
        context.setBroker(brokerService.getBroker());
        ActiveMQMessage advisoryMessage = new ActiveMQMessage();
        advisoryMessage.setStringProperty("cause", error.getLocalizedMessage());
        advisoryBroker.fireAdvisory(context, AdvisorySupport.getNetworkBridgeForwardFailureAdvisoryTopic(), messageDispatch.getMessage(), null,
            advisoryMessage);
      }
    } catch (Exception e) {
      LOG.warn("failed to fire forward failure advisory, cause: {}", e);
      LOG.debug("detail", e);
    }
  }
}
origin: apache/activemq

private void commit(LocalTransactionId tx, ConnectionContext connectionContext, Message message) throws Exception {
  if (tx != null) {
    connectionContext.getBroker().commitTransaction(connectionContext, tx, true);
    connectionContext.getTransactions().remove(tx);
    connectionContext.setTransaction(null);
    message.setTransactionId(null);
  }
}
origin: apache/activemq

  map.putAll(tempTopicRegion.getDestinationMap());
long maxPurgedDests = this.brokerService.getMaxPurgedDestinationsPerSweep();
long timeStamp = System.currentTimeMillis();
for (Destination d : map.values()) {
  d.markForGC(timeStamp);
  if (d.canGC()) {
    list.add(d);
    if (maxPurgedDests > 0 && list.size() == maxPurgedDests) {
  context.setBroker(this);
      log = ((BaseDestination) dest).getLog();
    log.info("{} Inactive for longer than {} ms - removing ...", dest.getName(), dest.getInactiveTimeoutBeforeGC());
    try {
      getRoot().removeDestination(context, dest.getActiveMQDestination(), isAllowTempAutoCreationOnSend() ? 1 : 0);
    } catch (Throwable e) {
      LOG.error("Failed to remove inactive destination {}", dest, e);
origin: apache/activemq

/**
 * Sends a message to the given destination which may be a wildcard
 *
 * @param context broker context
 * @param message message to send
 * @param destination possibly wildcard destination to send the message to
 * @throws Exception on error
 */
protected void send(ProducerBrokerExchange context, Message message, ActiveMQDestination destination) throws Exception {
  Broker broker = context.getConnectionContext().getBroker();
  Set<Destination> destinations = broker.getDestinations(destination);
  for (Destination dest : destinations) {
    dest.send(context, message.copy());
  }
}
origin: apache/activemq

  final NetworkBridgeConfiguration config) {
RegionBroker regionBroker = (RegionBroker) brokerService.getRegionBroker();
TopicRegion topicRegion = (TopicRegion) regionBroker.getTopicRegion();
Set<ConsumerInfo> subscriptionInfos = new HashSet<>();
  AdvisoryBroker ab = (AdvisoryBroker) brokerService.getBroker().getAdaptor(AdvisoryBroker.class);
  if (ab != null && brokerService.isUseVirtualDestSubs() && config.isUseVirtualDestSubs()) {
    for (ConsumerInfo info : ab.getVirtualDestinationConsumers().keySet()) {
      if (NetworkBridgeUtils.isForcedDurable(info, config.getDynamicallyIncludedDestinations())) {
origin: apache/activemq

/**
 * @returns the ObjectName of the Connection that created this subscription
 */
@Override
public ObjectName getConnection() {
  ObjectName result = null;
  if (clientId != null && subscription != null) {
    ConnectionContext ctx = subscription.getContext();
    if (ctx != null && ctx.getBroker() != null && ctx.getBroker().getBrokerService() != null) {
      BrokerService service = ctx.getBroker().getBrokerService();
      ManagementContext managementCtx = service.getManagementContext();
      if (managementCtx != null) {
        try {
          ObjectName query = createConnectionQuery(managementCtx, service.getBrokerName());
          Set<ObjectName> names = managementCtx.queryNames(query, null);
          if (names.size() == 1) {
            result = names.iterator().next();
          }
        } catch (Exception e) {
        }
      }
    }
  }
  return result;
}
origin: pierre/meteo

private ProducerBrokerExchange getProducerBrokerExchange(ProducerId id) throws IOException {
  ProducerBrokerExchange result = producerExchanges.get(id);
  if (result == null) {
    synchronized (producerExchanges) {
      result = new ProducerBrokerExchange();
      TransportConnectionState state = lookupConnectionState(id);              
      context = state.getContext();
      if (context.isReconnect()) {
        result.setLastStoredSequenceId(broker.getBrokerService().getPersistenceAdapter().getLastProducerSequenceId(id));
      }
      result.setConnectionContext(context);
      SessionState ss = state.getSessionState(id.getParentId());
      if (ss != null) {
        result.setProducerState(ss.getProducerState(id));
        ProducerState producerState = ss.getProducerState(id);
        if (producerState != null && producerState.getInfo() != null) {
          ProducerInfo info = producerState.getInfo();
          result.setMutable(info.getDestination() == null || info.getDestination().isComposite());
        }
      }
      producerExchanges.put(id, result);
    }
  } else {
    context = result.getConnectionContext();
  }
  return result;
}
origin: apache/activemq

public void removeDestination(ActiveMQDestination destination) throws Exception {
  getBroker().removeDestination(getAdminConnectionContext(), destination, 0);
}
origin: pierre/meteo

public void create(Broker broker, ConnectionContext context, ActiveMQDestination destination) throws Exception {
  if (destination.isQueue() && destination.isPattern() && broker.getDestinations(destination).isEmpty()) {
    DestinationFilter filter = DestinationFilter.parseFilter(new ActiveMQQueue(prefix + DestinationFilter.ANY_DESCENDENT));
    if (filter.matches(destination)) {
      broker.addDestination(context, destination, false);
    }
  }
}
origin: apache/activemq

@Override
public void start() throws Exception {
  super.start();
  if (location == null) {
    location = new File(getBrokerService().getBrokerDataDirectory(), "destinations");
  }
  importDestinations();
  destinations.addAll(Arrays.asList(getBrokerService().getBroker().getDestinations()));
}
origin: apache/activemq

    if (config.isSyncDurableSubs() && protocolVersion.get() >= CommandTypes.PROTOCOL_VERSION_DURABLE_SYNC) {
      LOG.debug("SyncDurableSubs is enabled, Sending BrokerSubscriptionInfo");
      dispatchSync(NetworkBridgeUtils.getBrokerSubscriptionInfo(this.broker.getBrokerService(), config));
    config.setBrokerName(broker.getBrokerName());
      dispatchSync(NetworkBridgeUtils.getBrokerSubscriptionInfo(this.broker.getBrokerService(), config));
    Transport localTransport = NetworkBridgeFactory.createLocalTransport(config, broker.getVmConnectorURI());
    Transport remoteBridgeTransport = transport;
    if (! (remoteBridgeTransport instanceof ResponseCorrelator)) {
      duplexName = duplexName.substring(duplexName.lastIndexOf("#"));
    MBeanNetworkListener listener = new MBeanNetworkListener(brokerService, config, brokerService.createDuplexNetworkConnectorObjectName(duplexName));
    listener.setCreatedByDuplex(true);
    duplexBridge = config.getBridgeFactory().createNetworkBridge(config, localTransport, remoteBridgeTransport, listener);
        broker.getDurableDestinations()));
List<TransportConnectionState> connectionStates = listConnectionStates();
for (TransportConnectionState cs : connectionStates) {
  cs.getContext().setNetworkConnection(true);
origin: powertac/powertac-server

public Set<String> processQueues ()
{
 BrokerService brokerService = getProvider();
 if (brokerService == null) {
  log.debug("processQueues - JMS Server has not been started");
  return null;
 }
 Set<String> badQueues = new HashSet<String>();
 try {
  Broker broker = brokerService.getBroker();
  Map<ActiveMQDestination, Destination> dstMap = broker.getDestinationMap();
  for (Map.Entry<ActiveMQDestination, Destination> entry: dstMap.entrySet()) {
   ActiveMQDestination amqDestination = entry.getKey();
   Destination destination = entry.getValue();
   if (destinationLimitReached(destination)) {
    badQueues.add(destination.getName());
    deleteDestination(broker, amqDestination, destination);
   }
  }
 }
 catch (Exception e) {
  log.error("Encounter exception while getting jms broker", e);
 }
 return badQueues;
}
origin: org.apache.beam/beam-sdks-java-io-mqtt

while (!pipelineConnected) {
 Thread.sleep(1000);
 for (Connection connection : brokerService.getBroker().getClients()) {
  if (!connection.getConnectionId().isEmpty()) {
   pipelineConnected = true;
origin: apache/activemq

networkBridgeStatistics.setEnabled(brokerService.isEnableStatistics());
  duplexInboundLocalBroker = NetworkBridgeFactory.createLocalAsyncTransport(brokerService.getBroker().getVmConnectorURI());
  duplexInboundLocalBroker.setTransportListener(new DefaultTransportListener() {
org.apache.activemq.brokerBroker

Javadoc

The Message Broker which routes messages, maintains subscriptions and connections, acknowledges messages and handles transactions.

Most used methods

  • getAdaptor
    Get a Broker from the Broker Stack that is a particular class
  • getDestinationMap
    return a reference destination map of a region based on the destination type
  • removeDestination
  • commitTransaction
    Commits a transaction.
  • forgetTransaction
    Forgets a transaction.
  • getBrokerService
  • getClients
  • getDestinations
  • getPreparedTransactions
    Gets a list of all the prepared xa transactions.
  • getVmConnectorURI
  • removeConsumer
  • acknowledge
  • removeConsumer,
  • acknowledge,
  • addBroker,
  • addConnection,
  • addConsumer,
  • addDestination,
  • addDestinationInfo,
  • addProducer,
  • addSession,
  • beginTransaction

Popular in Java

  • Updating database using SQL prepared statement
  • notifyDataSetChanged (ArrayAdapter)
  • getSystemService (Context)
  • orElseThrow (Optional)
    Return the contained value, if present, otherwise throw an exception to be created by the provided s
  • HttpServer (com.sun.net.httpserver)
    This class implements a simple HTTP server. A HttpServer is bound to an IP address and port number a
  • Graphics2D (java.awt)
    This Graphics2D class extends the Graphics class to provide more sophisticated control overgraphics
  • Kernel (java.awt.image)
  • Selector (java.nio.channels)
    A controller for the selection of SelectableChannel objects. Selectable channels can be registered w
  • SecureRandom (java.security)
    This class generates cryptographically secure pseudo-random numbers. It is best to invoke SecureRand
  • ZipFile (java.util.zip)
    This class provides random read access to a zip file. You pay more to read the zip file's central di
  • Top 12 Jupyter Notebook extensions
Tabnine Logo
  • Products

    Search for Java codeSearch for JavaScript code
  • IDE Plugins

    IntelliJ IDEAWebStormVisual StudioAndroid StudioEclipseVisual Studio CodePyCharmSublime TextPhpStormVimGoLandRubyMineEmacsJupyter NotebookJupyter LabRiderDataGripAppCode
  • Company

    About UsContact UsCareers
  • Resources

    FAQBlogTabnine AcademyTerms of usePrivacy policyJava Code IndexJavascript Code Index
Get Tabnine for your IDE now