1 18 package org.apache.activemq.broker.jmx; 19 20 import javax.management.openmbean.CompositeData ; 21 import javax.management.openmbean.OpenDataException ; 22 23 import org.apache.activemq.broker.ConnectionContext; 24 import org.apache.activemq.broker.region.Queue; 25 import org.apache.activemq.command.ActiveMQDestination; 26 import org.apache.activemq.command.Message; 27 28 31 public class QueueView extends DestinationView implements QueueViewMBean{ 32 public QueueView(ManagedRegionBroker broker, Queue destination){ 33 super(broker, destination); 34 } 35 36 public CompositeData getMessage(String messageId) throws OpenDataException { 37 Message rc=((Queue) destination).getMessage(messageId); 38 if(rc==null) 39 return null; 40 return OpenTypeSupport.convert(rc); 41 } 42 43 public void purge() throws Exception { 44 ((Queue) destination).purge(); 45 } 46 47 public boolean removeMessage(String messageId) throws Exception { 48 return ((Queue) destination).removeMessage(messageId); 49 } 50 51 public int removeMatchingMessages(String selector) throws Exception { 52 return ((Queue) destination).removeMatchingMessages(selector); 53 } 54 55 public int removeMatchingMessages(String selector, int maximumMessages) throws Exception { 56 return ((Queue) destination).removeMatchingMessages(selector, maximumMessages); 57 } 58 59 public boolean copyMessageTo(String messageId, String destinationName) throws Exception { 60 ConnectionContext context = BrokerView.getConnectionContext(broker.getContextBroker()); 61 ActiveMQDestination toDestination = ActiveMQDestination.createDestination(destinationName, ActiveMQDestination.QUEUE_TYPE); 62 return ((Queue) destination).copyMessageTo(context, messageId, toDestination); 63 } 64 65 public int copyMatchingMessagesTo(String selector, String destinationName) throws Exception { 66 ConnectionContext context = BrokerView.getConnectionContext(broker.getContextBroker()); 67 ActiveMQDestination toDestination = ActiveMQDestination.createDestination(destinationName, ActiveMQDestination.QUEUE_TYPE); 68 return ((Queue) destination).copyMatchingMessagesTo(context, selector, toDestination); 69 } 70 71 public int copyMatchingMessagesTo(String selector, String destinationName, int maximumMessages) throws Exception { 72 ConnectionContext context = BrokerView.getConnectionContext(broker.getContextBroker()); 73 ActiveMQDestination toDestination = ActiveMQDestination.createDestination(destinationName, ActiveMQDestination.QUEUE_TYPE); 74 return ((Queue) destination).copyMatchingMessagesTo(context, selector, toDestination, maximumMessages); 75 } 76 77 public boolean moveMessageTo(String messageId, String destinationName) throws Exception { 78 ConnectionContext context = BrokerView.getConnectionContext(broker.getContextBroker()); 79 ActiveMQDestination toDestination = ActiveMQDestination.createDestination(destinationName, ActiveMQDestination.QUEUE_TYPE); 80 return ((Queue) destination).moveMessageTo(context, messageId, toDestination); 81 } 82 83 public int moveMatchingMessagesTo(String selector, String destinationName) throws Exception { 84 ConnectionContext context = BrokerView.getConnectionContext(broker.getContextBroker()); 85 ActiveMQDestination toDestination = ActiveMQDestination.createDestination(destinationName, ActiveMQDestination.QUEUE_TYPE); 86 return ((Queue) destination).moveMatchingMessagesTo(context, selector, toDestination); 87 } 88 89 public int moveMatchingMessagesTo(String selector, String destinationName, int maximumMessages) throws Exception { 90 ConnectionContext context = BrokerView.getConnectionContext(broker.getContextBroker()); 91 ActiveMQDestination toDestination = ActiveMQDestination.createDestination(destinationName, ActiveMQDestination.QUEUE_TYPE); 92 return ((Queue) destination).moveMatchingMessagesTo(context, selector, toDestination, maximumMessages); 93 } 94 95 } 96 | Popular Tags |