public AMQConnectionContext() { this.messageEvaluationContext = new MessageEvaluationContext(); }
public ConnectionContext() { this.messageEvaluationContext = new MessageEvaluationContext(); }
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); } }
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 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; }
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; }
/** * Browses the current destination with the given selector returning a list * of messages */ 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]; if (selectorExpression == null) { answer.add(OpenTypeSupport.convert(message)); } else { ctx.setMessageReference(message); if (selectorExpression.matches(ctx)) { answer.add(message); } } } catch (Throwable e) { LOG.warn("exception browsing destination", e); } } return answer; }
public boolean hasNext() { try { this.nextLocation = reader.getNextMessage(currentLocation); Message next = nextLocation != null ? nextLocation.getMessage() : null; if (expression == null) { return next != null; } else { while (next != null) { MessageEvaluationContext context = new MessageEvaluationContext(); context.setMessageReference((MessageReference) next); if (expression.matches(context)) { return true; } this.nextLocation = reader.getNextMessage(currentLocation); next = nextLocation != null ? nextLocation.getMessage() : null; } valid=false; return false; } } catch (Exception e) { throw new RuntimeException( "Failed to get next message from reader ", e); } }
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; }
MessageEvaluationContext context = new MessageEvaluationContext(); context.setMessageReference(dummyMessage);
MessageEvaluationContext context = new MessageEvaluationContext(); context.setMessageReference(dummyMessage);
private boolean suppressMessageDispatch(MessageDispatch md, DemandSubscription sub) throws Exception { // See if this consumer's brokerPath tells us it came from the broker at the other end // of the bridge. I think we should be making this decision based on the message's // broker bread crumbs and not the consumer's? However, the message's broker bread // crumbs are null, which is another matter. boolean suppress = false; Object consumerInfo = md.getMessage().getDataStructure(); if (consumerInfo != null && (consumerInfo instanceof ConsumerInfo)) { suppress = contains(((ConsumerInfo) consumerInfo).getBrokerPath(), remoteBrokerInfo.getBrokerId()); } // for durable subs, suppression via filter leaves dangling acks so we need to // check here and allow the ack irrespective if (!suppress && sub.getLocalInfo().isDurable()) { MessageEvaluationContext messageEvalContext = new MessageEvaluationContext(); messageEvalContext.setMessageReference(md.getMessage()); suppress = !createNetworkBridgeFilter(null).matches(messageEvalContext); } return suppress; }