public ConnectionContext copy() { ConnectionContext rc = new ConnectionContext(this.messageEvaluationContext); rc.connection = this.connection; rc.connector = this.connector; rc.broker = this.broker; rc.inRecoveryMode = this.inRecoveryMode; rc.transaction = this.transaction; rc.transactions = this.transactions; rc.securityContext = this.securityContext; rc.connectionId = this.connectionId; rc.clientId = this.clientId; rc.userName = this.userName; rc.reconnect = this.reconnect; rc.wireFormatInfo = this.wireFormatInfo; rc.longTermStoreContext = this.longTermStoreContext; rc.producerFlowControl = this.producerFlowControl; rc.messageAuthorizationPolicy = this.messageAuthorizationPolicy; rc.networkConnection = this.networkConnection; rc.faultTolerant = this.faultTolerant; rc.stopping.set(this.stopping.get()); rc.dontSendReponse = this.dontSendReponse; rc.clientMaster = this.clientMaster; return rc; }
private void doDispose(Destination dest) { ConnectionContext context = new ConnectionContext(); try { dest.dispose(context); dest.stop(); } catch (Exception e) { LOG.warn("Failed to dispose of {}", dest, e); } }
/** * Factory method to create the new administration connection context * object. Note this method is here rather than inside a default broker * implementation to ensure that the broker reference inside it is the outer * most interceptor */ protected static ConnectionContext createAdminConnectionContext(Broker broker) { ConnectionContext context = new ConnectionContext(); context.setBroker(broker); context.setSecurityContext(SecurityContext.BROKER_SECURITY_CONTEXT); return context; } }
public JournalMessageStore(JournalPersistenceAdapter adapter, MessageStore checkpointStore, ActiveMQDestination destination) { super(destination); this.peristenceAdapter = adapter; this.transactionStore = adapter.getTransactionStore(); this.longTermStore = checkpointStore; this.transactionTemplate = new TransactionTemplate(adapter, new ConnectionContext(new NonCachedMessageEvaluationContext())); }
@Override public final void start() throws Exception { started = true; Set<ActiveMQDestination> inactiveDests = getInactiveDestinations(); for (Iterator<ActiveMQDestination> iter = inactiveDests.iterator(); iter.hasNext();) { ActiveMQDestination dest = iter.next(); ConnectionContext context = new ConnectionContext(); context.setBroker(broker.getBrokerService().getBroker()); context.setSecurityContext(SecurityContext.BROKER_SECURITY_CONTEXT); context.getBroker().addDestination(context, dest, false); } destinationsLock.readLock().lock(); try{ for (Iterator<Destination> i = destinations.values().iterator(); i.hasNext();) { Destination dest = i.next(); dest.start(); } } finally { destinationsLock.readLock().unlock(); } }
/** * @throws IOException */ public void commit() throws IOException { ConnectionContext ctx = new ConnectionContext(); persistenceAdapter.beginTransaction(ctx); try { // Do all the message adds. for (Iterator<AddMessageCommand> iter = messages.iterator(); iter.hasNext();) { AddMessageCommand cmd = iter.next(); cmd.run(ctx); } // And removes.. for (Iterator<RemoveMessageCommand> iter = acks.iterator(); iter.hasNext();) { RemoveMessageCommand cmd = iter.next(); cmd.run(ctx); } persistenceAdapter.commitTransaction(ctx); } catch (IOException e) { persistenceAdapter.rollbackTransaction(ctx); throw e; } } }
private ConnectionContext getConnectionContext() { ConnectionContext context; if (broker == null) { context = new ConnectionContext(); } else { ConnectionContext sharedContext = BrokerSupport.getConnectionContext(broker.getContextBroker()); // Make a local copy of the sharedContext. We do this because we do // not want to set a clientId on the // global sharedContext. Taking a copy of the sharedContext is a // good way to make sure that we are not // messing up the shared context context = sharedContext.copy(); } return context; } }
ConnectionContext ctx = new ConnectionContext();
private void discardExpiredMessage(MessageReference reference) { LOG.debug("Discarding expired message {}", reference); if (reference.isExpired() && broker.isExpired(reference)) { ConnectionContext context = new ConnectionContext(); context.setBroker(broker); ((Destination)reference.getRegionDestination()).messageExpired(context, null, new IndirectMessageReference(reference.getMessage())); } }
public ConnectionContext createConnectionContext() { ConnectionContext answer = new ConnectionContext(); answer.setBroker(this.broker); answer.getMessageEvaluationContext().setDestination(getActiveMQDestination()); answer.setSecurityContext(SecurityContext.BROKER_SECURITY_CONTEXT); return answer; }
public void doCleanup() { long now = System.currentTimeMillis(); for (Map.Entry<SubscriptionKey, DurableTopicSubscription> entry : durableSubscriptions.entrySet()) { DurableTopicSubscription sub = entry.getValue(); if (!sub.isActive()) { long offline = sub.getOfflineTimestamp(); if (offline != -1 && now - offline >= broker.getBrokerService().getOfflineDurableSubscriberTimeout()) { LOG.info("Destroying durable subscriber due to inactivity: {}", sub); try { RemoveSubscriptionInfo info = new RemoveSubscriptionInfo(); info.setClientId(entry.getKey().getClientId()); info.setSubscriptionName(entry.getKey().getSubscriptionName()); ConnectionContext context = new ConnectionContext(); context.setBroker(broker); context.setClientId(entry.getKey().getClientId()); removeSubscription(context, info); } catch (Exception e) { LOG.error("Failed to remove inactive durable subscriber", e); } } } } }
if (tx != null) { ConnectionContext ctx = new ConnectionContext(); persistenceAdapter.beginTransaction(ctx); try {
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); } } }
@Override public void networkBridgeStopped(BrokerInfo brokerInfo) { try { if (brokerInfo != null) { ActiveMQMessage advisoryMessage = new ActiveMQMessage(); advisoryMessage.setBooleanProperty("started", false); networkBridges.remove(brokerInfo); ActiveMQTopic topic = AdvisorySupport.getNetworkBridgeAdvisoryTopic(); ConnectionContext context = new ConnectionContext(); context.setSecurityContext(SecurityContext.BROKER_SECURITY_CONTEXT); context.setBroker(getBrokerService().getBroker()); fireAdvisory(context, topic, brokerInfo, null, advisoryMessage); } } catch (Exception e) { handleFireFailure("network bridge stopped", e); } }
/** * Destroys the durable subscription so that messages will no longer be * stored for this subscription */ public void destroy() throws Exception { RemoveSubscriptionInfo info = new RemoveSubscriptionInfo(); info.setClientId(clientId); info.setSubscriptionName(subscriptionName); ConnectionContext context = new ConnectionContext(); context.setBroker(broker); context.setClientId(clientId); brokerService.getBroker().removeSubscription(context, info); }
/** * Destroys the durable subscription so that messages will no longer be * stored for this subscription */ @Override public void destroy() throws Exception { RemoveSubscriptionInfo info = new RemoveSubscriptionInfo(); info.setClientId(clientId); info.setSubscriptionName(subscriptionInfo.getSubscriptionName()); ConnectionContext context = new ConnectionContext(); context.setBroker(broker); context.setClientId(clientId); brokerService.getBroker().removeSubscription(context, info); }
@Override public void networkBridgeStarted(BrokerInfo brokerInfo, boolean createdByDuplex, String remoteIp) { try { if (brokerInfo != null) { ActiveMQMessage advisoryMessage = new ActiveMQMessage(); advisoryMessage.setBooleanProperty("started", true); advisoryMessage.setBooleanProperty("createdByDuplex", createdByDuplex); advisoryMessage.setStringProperty("remoteIp", remoteIp); networkBridges.putIfAbsent(brokerInfo, advisoryMessage); ActiveMQTopic topic = AdvisorySupport.getNetworkBridgeAdvisoryTopic(); ConnectionContext context = new ConnectionContext(); context.setSecurityContext(SecurityContext.BROKER_SECURITY_CONTEXT); context.setBroker(getBrokerService().getBroker()); fireAdvisory(context, topic, brokerInfo, null, advisoryMessage); } } catch (Exception e) { handleFireFailure("network bridge started", e); } }
@Override public void nowMasterBroker() { super.nowMasterBroker(); try { ActiveMQTopic topic = AdvisorySupport.getMasterBrokerAdvisoryTopic(); ActiveMQMessage advisoryMessage = new ActiveMQMessage(); ConnectionContext context = new ConnectionContext(); context.setSecurityContext(SecurityContext.BROKER_SECURITY_CONTEXT); context.setBroker(getBrokerService().getBroker()); fireAdvisory(context, topic, null, null, advisoryMessage); } catch (Exception e) { handleFireFailure("now master broker", e); } }
/** * Re-inject into the Broker chain */ void injectMessage(ProducerBrokerExchange producerExchange, final Message messageSend) throws Exception { ProducerBrokerExchange pe = producerExchange; if (pe == null) { pe = new ProducerBrokerExchange(); ConnectionContext cc = new ConnectionContext(); cc.setBroker(this.getRoot()); pe.setConnectionContext(cc); pe.setMutable(true); pe.setProducerState(new ProducerState(new ProducerInfo())); } super.send(pe, messageSend); }
ConnectionContext context = new ConnectionContext();