public boolean matches(MessageEvaluationContext context) throws JMSException { BooleanExpression booleanExpression = getFilter(); if (booleanExpression == null) { return false; } return booleanExpression.matches(context); }
private boolean tryMatchingCachedSubs(final Broker broker, Destination dest, MessageEvaluationContext msgContext) { boolean matches = false; LOG.debug("No active consumer match found. Will try cache if configured..."); if (selectorCachePlugin != null) { final Set<String> selectors = selectorCachePlugin.getSelector(dest.getActiveMQDestination().getQualifiedName()); if (selectors != null) { for (String selector : selectors) { try { final BooleanExpression expression = getExpression(selector); matches = expression.matches(msgContext); if (matches) { return true; } } catch (Exception e) { LOG.error(e.getMessage(), e); } } } } return matches; }
@Override public CompositeData[] browse(String selector) throws OpenDataException, InvalidSelectorException { Message[] messages = destination.browse(); ArrayList<CompositeData> c = new ArrayList<CompositeData>(); NonCachedMessageEvaluationContext ctx = new NonCachedMessageEvaluationContext(); 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) { LOG.warn("exception browsing destination", e); } } CompositeData rc[] = new CompositeData[c.size()]; c.toArray(rc); return rc; }
@Override public boolean matches(MessageReference node, MessageEvaluationContext context) throws IOException { ConsumerId targetConsumerId = node.getTargetConsumerId(); if (targetConsumerId != null) { if (!targetConsumerId.equals(info.getConsumerId())) { return false; } } try { return (selectorExpression == null || selectorExpression.matches(context)) && this.context.isAllowedToConsume(node); } catch (JMSException e) { LOG.info("Selector failed to evaluate: {}", e.getMessage(), e); return false; } }
/** * 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>(); NonCachedMessageEvaluationContext ctx = new NonCachedMessageEvaluationContext(); 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; }
@Override public boolean evaluate(ConnectionContext context, MessageReference r) throws JMSException { MessageEvaluationContext messageEvaluationContext = context.getMessageEvaluationContext(); messageEvaluationContext.setMessageReference(r); if (messageEvaluationContext.getDestination() == null) { messageEvaluationContext.setDestination(getActiveMQDestination()); } return selectorExpression.matches(messageEvaluationContext); } };
@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); NonCachedMessageEvaluationContext ctx = new NonCachedMessageEvaluationContext(); 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; }
public boolean matches(MessageEvaluationContext context) throws JMSException { BooleanExpression booleanExpression = getFilter(); if (booleanExpression == null) { return false; } return booleanExpression.matches(context); }
public boolean matches(MessageEvaluationContext context) throws JMSException { BooleanExpression booleanExpression = getFilter(); if (booleanExpression == null) { return false; } return booleanExpression.matches(context); }
public boolean matches(MessageEvaluationContext context) throws JMSException { BooleanExpression booleanExpression = getFilter(); if (booleanExpression == null) { return false; } return booleanExpression.matches(context); }
public boolean matches(MessageEvaluationContext context) throws JMSException { BooleanExpression booleanExpression = getFilter(); if (booleanExpression == null) { return false; } return booleanExpression.matches(context); }
public boolean accept(Message message) { try { MessageEvaluationContext context = new MessageEvaluationContext(); MessageAdapter ma = new MessageAdapter(message); context.setMessageReference(ma); return expression.matches(context); } catch (Exception e) { throw new RuntimeException("ActiveMQ selector accept error " + message, e); } }
private boolean tryMatchingCachedSubs(final Broker broker, Destination dest, MessageEvaluationContext msgContext) { boolean matches = false; LOG.debug("No active consumer match found. Will try cache if configured..."); if (selectorCachePlugin != null) { final Set<String> selectors = selectorCachePlugin.getSelector(dest.getActiveMQDestination().getQualifiedName()); if (selectors != null) { for (String selector : selectors) { try { final BooleanExpression expression = getExpression(selector); matches = expression.matches(msgContext); if (matches) { return true; } } catch (Exception e) { LOG.error(e.getMessage(), e); } } } } return matches; }
private boolean tryMatchingCachedSubs(final Broker broker, Destination dest, MessageEvaluationContext msgContext) { boolean matches = false; LOG.debug("No active consumer match found. Will try cache if configured..."); if (selectorCachePlugin != null) { final Set<String> selectors = selectorCachePlugin.getSelector(dest.getActiveMQDestination().getQualifiedName()); if (selectors != null) { for (String selector : selectors) { try { final BooleanExpression expression = getExpression(selector); matches = expression.matches(msgContext); if (matches) { return true; } } catch (Exception e) { LOG.error(e.getMessage(), e); } } } } return matches; }
private boolean tryMatchingCachedSubs(final Broker broker, Destination dest, MessageEvaluationContext msgContext) { boolean matches = false; LOG.debug("No active consumer match found. Will try cache if configured..."); if (selectorCachePlugin != null) { final Set<String> selectors = selectorCachePlugin.getSelector(dest.getActiveMQDestination().getQualifiedName()); if (selectors != null) { for (String selector : selectors) { try { final BooleanExpression expression = getExpression(selector); matches = expression.matches(msgContext); if (matches) { return true; } } catch (Exception e) { LOG.error(e.getMessage(), e); } } } } return matches; }
public boolean recoverMessageReference(MessageId ref) throws Exception { if (selectorExpression != null) { MessageEvaluationContext ctx = new MessageEvaluationContext(); ctx.setMessageReference(store.getMessage(ref)); if (selectorExpression.matches(ctx)) { count++; } } else { count ++; } return true; }
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; }
@Override public CompositeData[] browse(String selector) throws OpenDataException, InvalidSelectorException { Message[] messages = destination.browse(); ArrayList<CompositeData> c = new ArrayList<CompositeData>(); NonCachedMessageEvaluationContext ctx = new NonCachedMessageEvaluationContext(); 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) { LOG.warn("exception browsing destination", e); } } CompositeData rc[] = new CompositeData[c.size()]; c.toArray(rc); return rc; }
public boolean recoverMessage(Message message) throws Exception { if (selectorExpression != null) { MessageEvaluationContext ctx = new MessageEvaluationContext(); ctx.setMessageReference(store.getMessage(message.getMessageId())); if (selectorExpression.matches(ctx)) { count++; } } else { count++; } return true; }
@Override public boolean matches(MessageReference node, MessageEvaluationContext context) throws IOException { ConsumerId targetConsumerId = node.getTargetConsumerId(); if (targetConsumerId != null) { if (!targetConsumerId.equals(info.getConsumerId())) { return false; } } try { return (selectorExpression == null || selectorExpression.matches(context)) && this.context.isAllowedToConsume(node); } catch (JMSException e) { LOG.info("Selector failed to evaluate: {}", e.getMessage(), e); return false; } }