本文整理匯總了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;
}
示例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;
}
示例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;
}
示例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;
}
示例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;
}
示例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;
}
示例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();
}
}
}
示例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;
}
示例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);
}
示例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);
}
示例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);
}