当前位置: 首页>>代码示例>>Java>>正文


Java ConnectionContext.isNetworkConnection方法代码示例

本文整理汇总了Java中org.apache.activemq.broker.ConnectionContext.isNetworkConnection方法的典型用法代码示例。如果您正苦于以下问题:Java ConnectionContext.isNetworkConnection方法的具体用法?Java ConnectionContext.isNetworkConnection怎么用?Java ConnectionContext.isNetworkConnection使用的例子?那么, 这里精选的方法代码示例或许可以为您提供帮助。您也可以进一步了解该方法所在org.apache.activemq.broker.ConnectionContext的用法示例。


在下文中一共展示了ConnectionContext.isNetworkConnection方法的4个代码示例,这些例子默认根据受欢迎程度排序。您可以为喜欢或者感觉有用的代码点赞,您的评价将有助于系统推荐出更棒的Java代码示例。

示例1: addSubscription

import org.apache.activemq.broker.ConnectionContext; //导入方法依赖的package包/类
public void addSubscription(ConnectionContext context, Subscription sub) throws Exception {
    // Only consumers on the same connection can consume from
    // the temporary destination
    // However, we could have failed over - and we do this
    // check client side anyways ....
    if (!context.isFaultTolerant()
            && (!context.isNetworkConnection() && !tempDest
                    .getConnectionId().equals(
                            sub.getConsumerInfo().getConsumerId()
                                    .getConnectionId()))) {

        tempDest.setConnectionId(sub.getConsumerInfo().getConsumerId().getConnectionId());
        if (LOG.isDebugEnabled()) {
            LOG.debug(" changed ownership of " + this + " to "+ tempDest.getConnectionId());
        }
    }
    super.addSubscription(context, sub);
}
 
开发者ID:DiamondLightSource,项目名称:daq-eclipse,代码行数:19,代码来源:TempTopic.java

示例2: addSubscription

import org.apache.activemq.broker.ConnectionContext; //导入方法依赖的package包/类
@Override
public void addSubscription(ConnectionContext context, Subscription sub) throws Exception {
    // Only consumers on the same connection can consume from
    // the temporary destination
    // However, we could have failed over - and we do this
    // check client side anyways ....
    if (!context.isFaultTolerant()
            && (!context.isNetworkConnection() && !tempDest
                    .getConnectionId().equals(
                            sub.getConsumerInfo().getConsumerId()
                                    .getConnectionId()))) {

        tempDest.setConnectionId(sub.getConsumerInfo().getConsumerId().getConnectionId());
        LOG.debug("changed ownership of {} to {}", this, tempDest.getConnectionId());
    }
    super.addSubscription(context, sub);
}
 
开发者ID:DiamondLightSource,项目名称:daq-eclipse,代码行数:18,代码来源:TempQueue.java

示例3: waitForSpace

import org.apache.activemq.broker.ConnectionContext; //导入方法依赖的package包/类
protected final void waitForSpace(ConnectionContext context, ProducerBrokerExchange producerBrokerExchange, Usage<?> usage, int highWaterMark, String warning) throws IOException, InterruptedException, ResourceAllocationException {
    if (!context.isNetworkConnection() && systemUsage.isSendFailIfNoSpace()) {
        getLog().debug("sendFailIfNoSpace, forcing exception on send, usage: {}: {}", usage, warning);
        throw new ResourceAllocationException(warning);
    }
    if (!context.isNetworkConnection() && systemUsage.getSendFailIfNoSpaceAfterTimeout() != 0) {
        if (!usage.waitForSpace(systemUsage.getSendFailIfNoSpaceAfterTimeout(), highWaterMark)) {
            getLog().debug("sendFailIfNoSpaceAfterTimeout expired, forcing exception on send, usage: {}: {}", usage, warning);
            throw new ResourceAllocationException(warning);
        }
    } else {
        long start = System.currentTimeMillis();
        long nextWarn = start;
        producerBrokerExchange.blockingOnFlowControl(true);
        destinationStatistics.getBlockedSends().increment();
        while (!usage.waitForSpace(1000, highWaterMark)) {
            if (context.getStopping().get()) {
                throw new IOException("Connection closed, send aborted.");
            }

            long now = System.currentTimeMillis();
            if (now >= nextWarn) {
                getLog().info("{}: {} (blocking for: {}s)", new Object[]{ usage, warning, new Long(((now - start) / 1000))});
                nextWarn = now + blockedProducerWarningInterval;
            }
        }
        long finish = System.currentTimeMillis();
        long totalTimeBlocked = finish - start;
        destinationStatistics.getBlockedTime().addTime(totalTimeBlocked);
        producerBrokerExchange.incrementTimeBlocked(this,totalTimeBlocked);
        producerBrokerExchange.blockingOnFlowControl(false);
    }
}
 
开发者ID:DiamondLightSource,项目名称:daq-eclipse,代码行数:34,代码来源:BaseDestination.java

示例4: doMessageSend

import org.apache.activemq.broker.ConnectionContext; //导入方法依赖的package包/类
/**
 * do send the message - this needs to be synchronized to ensure messages
 * are stored AND dispatched in the right order
 *
 * @param producerExchange
 * @param message
 * @throws IOException
 * @throws Exception
 */
synchronized void doMessageSend(final ProducerBrokerExchange producerExchange, final Message message)
        throws IOException, Exception {
    final ConnectionContext context = producerExchange.getConnectionContext();
    message.setRegionDestination(this);
    message.getMessageId().setBrokerSequenceId(getDestinationSequenceId());
    Future<Object> result = null;

    if (topicStore != null && message.isPersistent() && !canOptimizeOutPersistence()) {
        if (systemUsage.getStoreUsage().isFull(getStoreUsageHighWaterMark())) {
            final String logMessage = "Persistent store is Full, " + getStoreUsageHighWaterMark() + "% of "
                    + systemUsage.getStoreUsage().getLimit() + ". Stopping producer (" + message.getProducerId()
                    + ") to prevent flooding " + getActiveMQDestination().getQualifiedName() + "."
                    + " See http://activemq.apache.org/producer-flow-control.html for more info";
            if (!context.isNetworkConnection() && systemUsage.isSendFailIfNoSpace()) {
                throw new javax.jms.ResourceAllocationException(logMessage);
            }

            waitForSpace(context,producerExchange, systemUsage.getStoreUsage(), getStoreUsageHighWaterMark(), logMessage);
        }
        result = topicStore.asyncAddTopicMessage(context, message,isOptimizeStorage());
    }

    message.incrementReferenceCount();

    if (context.isInTransaction()) {
        context.getTransaction().addSynchronization(new Synchronization() {
            @Override
            public void afterCommit() throws Exception {
                // It could take while before we receive the commit
                // operation.. by that time the message could have
                // expired..
                if (broker.isExpired(message)) {
                    getDestinationStatistics().getExpired().increment();
                    broker.messageExpired(context, message, null);
                    message.decrementReferenceCount();
                    return;
                }
                try {
                    dispatch(context, message);
                } finally {
                    message.decrementReferenceCount();
                }
            }
        });

    } else {
        try {
            dispatch(context, message);
        } finally {
            message.decrementReferenceCount();
        }
    }

    if (result != null && !result.isCancelled()) {
        try {
            result.get();
        } catch (CancellationException e) {
            // ignore - the task has been cancelled if the message
            // has already been deleted
        }
    }
}
 
开发者ID:DiamondLightSource,项目名称:daq-eclipse,代码行数:72,代码来源:Topic.java


注:本文中的org.apache.activemq.broker.ConnectionContext.isNetworkConnection方法示例由纯净天空整理自Github/MSDocs等开源代码及文档管理平台,相关代码片段筛选自各路编程大神贡献的开源项目,源码版权归原作者所有,传播和使用请参考对应项目的License;未经允许,请勿转载。