1 18 package org.apache.activemq.console.util; 19 20 import org.apache.activemq.console.filter.QueryFilter; 21 import org.apache.activemq.console.filter.WildcardToMsgSelectorTransformFilter; 22 import org.apache.activemq.console.filter.PropertiesViewFilter; 23 import org.apache.activemq.console.filter.StubQueryFilter; 24 import org.apache.activemq.console.filter.MapTransformFilter; 25 import org.apache.activemq.console.filter.GroupPropertiesViewFilter; 26 import org.apache.activemq.console.filter.AmqMessagesQueryFilter; 27 28 import javax.jms.Destination ; 29 import java.net.URI ; 30 import java.util.List ; 31 import java.util.Set ; 32 33 public class AmqMessagesUtil { 34 public static final String JMS_MESSAGE_HEADER_PREFIX = "JMS_HEADER_FIELD:"; 35 public static final String JMS_MESSAGE_CUSTOM_PREFIX = "JMS_CUSTOM_FIELD:"; 36 public static final String JMS_MESSAGE_BODY_PREFIX = "JMS_BODY_FIELD:"; 37 38 public static List getAllMessages(URI brokerUrl, Destination dest) throws Exception { 39 return getMessages(brokerUrl, dest, ""); 40 } 41 42 public static List getMessages(URI brokerUrl, Destination dest, String selector) throws Exception { 43 return createMessageQueryFilter(brokerUrl, dest).query(selector); 44 } 45 46 public static List getMessages(URI brokerUrl, Destination dest, List selectors) throws Exception { 47 return createMessageQueryFilter(brokerUrl, dest).query(selectors); 48 } 49 50 public static List filterMessagesView(List messages, Set groupViews, Set attributeViews) throws Exception { 51 return (new PropertiesViewFilter(attributeViews, 52 new GroupPropertiesViewFilter(groupViews, 53 new MapTransformFilter( 54 new StubQueryFilter(messages) 55 ) 56 ) 57 )).query(""); 58 } 59 60 public static QueryFilter createMessageQueryFilter(URI brokerUrl, Destination dest) { 61 return new WildcardToMsgSelectorTransformFilter( 62 new AmqMessagesQueryFilter(brokerUrl, dest) 63 ); 64 } 65 } 66 | Popular Tags |