當前位置: 首頁>>代碼示例>>Java>>正文


Java MessageEvaluationContext.setMessageReference方法代碼示例

本文整理匯總了Java中org.apache.activemq.filter.MessageEvaluationContext.setMessageReference方法的典型用法代碼示例。如果您正苦於以下問題:Java MessageEvaluationContext.setMessageReference方法的具體用法?Java MessageEvaluationContext.setMessageReference怎麽用?Java MessageEvaluationContext.setMessageReference使用的例子?那麽, 這裏精選的方法代碼示例或許可以為您提供幫助。您也可以進一步了解該方法所在org.apache.activemq.filter.MessageEvaluationContext的用法示例。


在下文中一共展示了MessageEvaluationContext.setMessageReference方法的11個代碼示例,這些例子默認根據受歡迎程度排序。您可以為喜歡或者感覺有用的代碼點讚,您的評價將有助於係統推薦出更棒的Java代碼示例。

示例1: matchesSomeConsumer

import org.apache.activemq.filter.MessageEvaluationContext; //導入方法依賴的package包/類
private boolean matchesSomeConsumer(final Broker broker, Message message, Destination dest) throws IOException {
    boolean matches = false;
    MessageEvaluationContext msgContext = new NonCachedMessageEvaluationContext();
    msgContext.setDestination(dest.getActiveMQDestination());
    msgContext.setMessageReference(message);
    List<Subscription> subs = dest.getConsumers();
    for (Subscription sub : subs) {
        if (sub.matches(message, msgContext)) {
            matches = true;
            break;

        }
    }
    if (matches == false && subs.size() == 0) {
        matches = tryMatchingCachedSubs(broker, dest, msgContext);
    }
    return matches;
}
 
開發者ID:DiamondLightSource,項目名稱:daq-eclipse,代碼行數:19,代碼來源:SelectorAwareVirtualTopicInterceptor.java

示例2: addRecoveredMessage

import org.apache.activemq.filter.MessageEvaluationContext; //導入方法依賴的package包/類
@Override
public boolean addRecoveredMessage(ConnectionContext context, MessageReference message) throws Exception {
    boolean result = false;
    MessageEvaluationContext msgContext = context.getMessageEvaluationContext();
    try {
        Destination regionDestination = (Destination) message.getRegionDestination();
        msgContext.setDestination(regionDestination.getActiveMQDestination());
        msgContext.setMessageReference(message);
        result = matches(message, msgContext);
        if (result) {
            doAddRecoveredMessage(message);
        }

    } finally {
        msgContext.clear();
    }
    return result;
}
 
開發者ID:DiamondLightSource,項目名稱:daq-eclipse,代碼行數:19,代碼來源:AbstractSubscription.java

示例3: suppressMessageDispatch

import org.apache.activemq.filter.MessageEvaluationContext; //導入方法依賴的package包/類
private boolean suppressMessageDispatch(MessageDispatch md, DemandSubscription sub) throws Exception {
    boolean suppress = false;
    // for durable subs, suppression via filter leaves dangling acks so we
    // need to check here and allow the ack irrespective
    if (sub.getLocalInfo().isDurable()) {
        MessageEvaluationContext messageEvalContext = new MessageEvaluationContext();
        messageEvalContext.setMessageReference(md.getMessage());
        messageEvalContext.setDestination(md.getDestination());
        suppress = !sub.getNetworkBridgeFilter().matches(messageEvalContext);
    }
    return suppress;
}
 
開發者ID:DiamondLightSource,項目名稱:daq-eclipse,代碼行數:13,代碼來源:DemandForwardingBridgeSupport.java

示例4: browse

import org.apache.activemq.filter.MessageEvaluationContext; //導入方法依賴的package包/類
@Override
public CompositeData[] browse(String selector) throws OpenDataException, InvalidSelectorException {
    Message[] messages = destination.browse();
    ArrayList<CompositeData> c = new ArrayList<CompositeData>();

    MessageEvaluationContext ctx = new MessageEvaluationContext();
    ctx.setDestination(destination.getActiveMQDestination());
    BooleanExpression selectorExpression = selector == null ? null : SelectorParser.parse(selector);

    for (int i = 0; i < messages.length; i++) {
        try {

            if (selectorExpression == null) {
                c.add(OpenTypeSupport.convert(messages[i]));
            } else {
                ctx.setMessageReference(messages[i]);
                if (selectorExpression.matches(ctx)) {
                    c.add(OpenTypeSupport.convert(messages[i]));
                }
            }

        } catch (Throwable e) {
            // TODO DELETE ME
            System.out.println(e);
            e.printStackTrace();
            // TODO DELETE ME
            LOG.warn("exception browsing destination", e);
        }
    }

    CompositeData rc[] = new CompositeData[c.size()];
    c.toArray(rc);
    return rc;
}
 
開發者ID:DiamondLightSource,項目名稱:daq-eclipse,代碼行數:35,代碼來源:DestinationView.java

示例5: browseMessages

import org.apache.activemq.filter.MessageEvaluationContext; //導入方法依賴的package包/類
/**
 * Browses the current destination with the given selector returning a list
 * of messages
 */
@Override
public List<Object> browseMessages(String selector) throws InvalidSelectorException {
    Message[] messages = destination.browse();
    ArrayList<Object> answer = new ArrayList<Object>();

    MessageEvaluationContext ctx = new MessageEvaluationContext();
    ctx.setDestination(destination.getActiveMQDestination());
    BooleanExpression selectorExpression = selector == null ? null : SelectorParser.parse(selector);

    for (int i = 0; i < messages.length; i++) {
        try {
            Message message = messages[i];
            message.setReadOnlyBody(true);
            if (selectorExpression == null) {
                answer.add(message);
            } else {
                ctx.setMessageReference(message);
                if (selectorExpression.matches(ctx)) {
                    answer.add(message);
                }
            }

        } catch (Throwable e) {
            LOG.warn("exception browsing destination", e);
        }
    }
    return answer;
}
 
開發者ID:DiamondLightSource,項目名稱:daq-eclipse,代碼行數:33,代碼來源:DestinationView.java

示例6: browseAsTable

import org.apache.activemq.filter.MessageEvaluationContext; //導入方法依賴的package包/類
@Override
public TabularData browseAsTable(String selector) throws OpenDataException, InvalidSelectorException {
    OpenTypeFactory factory = OpenTypeSupport.getFactory(ActiveMQMessage.class);
    Message[] messages = destination.browse();
    CompositeType ct = factory.getCompositeType();
    TabularType tt = new TabularType("MessageList", "MessageList", ct, new String[] { "JMSMessageID" });
    TabularDataSupport rc = new TabularDataSupport(tt);

    MessageEvaluationContext ctx = new MessageEvaluationContext();
    ctx.setDestination(destination.getActiveMQDestination());
    BooleanExpression selectorExpression = selector == null ? null : SelectorParser.parse(selector);

    for (int i = 0; i < messages.length; i++) {
        try {
            if (selectorExpression == null) {
                rc.put(new CompositeDataSupport(ct, factory.getFields(messages[i])));
            } else {
                ctx.setMessageReference(messages[i]);
                if (selectorExpression.matches(ctx)) {
                    rc.put(new CompositeDataSupport(ct, factory.getFields(messages[i])));
                }
            }
        } catch (Throwable e) {
            LOG.warn("exception browsing destination", e);
        }
    }

    return rc;
}
 
開發者ID:DiamondLightSource,項目名稱:daq-eclipse,代碼行數:30,代碼來源:DestinationView.java

示例7: dispatch

import org.apache.activemq.filter.MessageEvaluationContext; //導入方法依賴的package包/類
protected void dispatch(final ConnectionContext context, Message message) throws Exception {
    // AMQ-2586: Better to leave this stat at zero than to give the user
    // misleading metrics.
    // destinationStatistics.getMessages().increment();
    destinationStatistics.getEnqueues().increment();
    destinationStatistics.getMessageSize().addSize(message.getSize());
    MessageEvaluationContext msgContext = null;

    dispatchLock.readLock().lock();
    try {
        if (!subscriptionRecoveryPolicy.add(context, message)) {
            return;
        }
        synchronized (consumers) {
            if (consumers.isEmpty()) {
                onMessageWithNoConsumers(context, message);
                return;
            }
        }
        msgContext = context.getMessageEvaluationContext();
        msgContext.setDestination(destination);
        msgContext.setMessageReference(message);
        if (!dispatchPolicy.dispatch(message, msgContext, consumers)) {
            onMessageWithNoConsumers(context, message);
        }

    } finally {
        dispatchLock.readLock().unlock();
        if (msgContext != null) {
            msgContext.clear();
        }
    }
}
 
開發者ID:DiamondLightSource,項目名稱:daq-eclipse,代碼行數:34,代碼來源:Topic.java

示例8: recoverMessage

import org.apache.activemq.filter.MessageEvaluationContext; //導入方法依賴的package包/類
@Override
public synchronized boolean recoverMessage(Message message, boolean cached) throws Exception {
    LOG.trace("recover: {}, priority: {}", message.getMessageId(), message.getPriority());
    boolean recovered = false;
    MessageEvaluationContext messageEvaluationContext = new NonCachedMessageEvaluationContext();
    messageEvaluationContext.setMessageReference(message);
    if (this.subscription.matches(message, messageEvaluationContext)) {
        recovered = super.recoverMessage(message, cached);
        if (recovered && !cached) {
            lastRecoveredPriority = message.getPriority();
        }
    }
    return recovered;      
}
 
開發者ID:DiamondLightSource,項目名稱:daq-eclipse,代碼行數:15,代碼來源:TopicStorePrefetch.java

示例9: assertSelector

import org.apache.activemq.filter.MessageEvaluationContext; //導入方法依賴的package包/類
protected void assertSelector(String text, boolean matches) throws JMSException {
   BooleanExpression selector = SelectorParser.parse(text);
   assertTrue("Created a valid selector", selector != null);
   MessageEvaluationContext context = new MessageEvaluationContext();
   context.setMessageReference((org.apache.activemq.command.Message) message);
   boolean value = selector.matches(context);
   assertEquals("Selector for: " + text, matches, value);
}
 
開發者ID:apache,項目名稱:activemq-artemis,代碼行數:9,代碼來源:UnknownHandlingSelectorTest.java

示例10: assertSelector

import org.apache.activemq.filter.MessageEvaluationContext; //導入方法依賴的package包/類
protected void assertSelector(Message message, String text, boolean expected) throws JMSException {
   BooleanExpression selector = SelectorParser.parse(text);
   assertTrue("Created a valid selector", selector != null);
   MessageEvaluationContext context = new MessageEvaluationContext();
   context.setMessageReference((org.apache.activemq.command.Message) message);
   boolean value = selector.matches(context);
   assertEquals("Selector for: " + text, expected, value);
}
 
開發者ID:apache,項目名稱:activemq-artemis,代碼行數:9,代碼來源:SelectorTest.java

示例11: canDispatch

import org.apache.activemq.filter.MessageEvaluationContext; //導入方法依賴的package包/類
public boolean canDispatch(Subscription subscription, MessageReference node) throws Exception {
    MessageEvaluationContext msgContext = new NonCachedMessageEvaluationContext();
    msgContext.setDestination(this.destination);
    msgContext.setMessageReference(node);
    return subscription.matches(node, msgContext);
}
 
開發者ID:DiamondLightSource,項目名稱:daq-eclipse,代碼行數:7,代碼來源:SimpleDispatchSelector.java


注:本文中的org.apache.activemq.filter.MessageEvaluationContext.setMessageReference方法示例由純淨天空整理自Github/MSDocs等開源代碼及文檔管理平台,相關代碼片段篩選自各路編程大神貢獻的開源項目,源碼版權歸原作者所有,傳播和使用請參考對應項目的License;未經允許,請勿轉載。