summaryrefslogtreecommitdiff
path: root/qpid/java/broker/src/main/java/org/apache/qpid/server/queue/AMQQueueMBean.java
blob: b0d4cb34868b578ca1afae06539aab740136a47f (plain)
1
2
3
4
5
6
7
8
9
10
11
12
13
14
15
16
17
18
19
20
21
22
23
24
25
26
27
28
29
30
31
32
33
34
35
36
37
38
39
40
41
42
43
44
45
46
47
48
49
50
51
52
53
54
55
56
57
58
59
60
61
62
63
64
65
66
67
68
69
70
71
72
73
74
75
76
77
78
79
80
81
82
83
84
85
86
87
88
89
90
91
92
93
94
95
96
97
98
99
100
101
102
103
104
105
106
107
108
109
110
111
112
113
114
115
116
117
118
119
120
121
122
123
124
125
126
127
128
129
130
131
132
133
134
135
136
137
138
139
140
141
142
143
144
145
146
147
148
149
150
151
152
153
154
155
156
157
158
159
160
161
162
163
164
165
166
167
168
169
170
171
172
173
174
175
176
177
178
179
180
181
182
183
184
185
186
187
188
189
190
191
192
193
194
195
196
197
198
199
200
201
202
203
204
205
206
207
208
209
210
211
212
213
214
215
216
217
218
219
220
221
222
223
224
225
226
227
228
229
230
231
232
233
234
235
236
237
238
239
240
241
242
243
244
245
246
247
248
249
250
251
252
253
254
255
256
257
258
259
260
261
262
263
264
265
266
267
268
269
270
271
272
273
274
275
276
277
278
279
280
281
282
283
284
285
286
287
288
289
290
291
292
293
294
295
296
297
298
299
300
301
302
303
304
305
306
307
308
309
310
311
312
313
314
315
316
317
318
319
320
321
322
323
324
325
326
327
328
329
330
331
332
333
334
335
336
337
338
339
340
341
342
343
344
345
346
347
348
349
350
351
352
353
354
355
356
357
358
359
360
361
362
363
364
365
366
367
368
369
370
371
372
373
374
375
376
377
378
379
380
381
382
383
384
385
386
387
388
389
390
391
392
393
394
395
396
397
398
399
400
401
402
403
404
405
406
407
408
409
410
411
412
413
414
415
416
417
418
419
420
421
422
423
424
425
426
427
428
429
430
431
432
433
434
435
436
437
438
439
440
441
442
443
444
445
446
447
448
449
450
451
452
453
454
455
456
457
458
459
460
461
462
463
464
465
466
467
468
469
470
471
472
473
474
475
476
477
478
479
480
481
482
483
484
485
486
487
488
489
490
491
492
493
494
495
496
497
498
499
500
501
502
503
504
505
506
507
508
509
510
511
512
513
514
515
516
517
518
519
520
521
522
523
524
525
526
527
528
529
530
531
532
533
534
535
536
537
538
539
540
541
542
543
544
545
546
547
548
549
550
551
552
553
554
555
556
557
558
559
560
561
562
563
564
565
566
567
568
569
570
571
572
573
574
575
576
577
578
579
580
581
582
583
584
585
586
587
588
589
590
591
592
593
594
595
596
597
598
599
600
601
602
603
604
605
606
607
608
609
610
611
612
613
614
615
616
617
618
619
620
621
622
623
624
625
626
627
628
629
630
631
632
633
634
635
636
637
638
639
640
641
642
643
644
645
646
647
648
649
650
651
652
653
654
655
656
657
658
659
660
661
662
663
664
/*
 *
 * Licensed to the Apache Software Foundation (ASF) under one
 * or more contributor license agreements.  See the NOTICE file
 * distributed with this work for additional information
 * regarding copyright ownership.  The ASF licenses this file
 * to you under the Apache License, Version 2.0 (the
 * "License"); you may not use this file except in compliance
 * with the License.  You may obtain a copy of the License at
 *
 *   http://www.apache.org/licenses/LICENSE-2.0
 *
 * Unless required by applicable law or agreed to in writing,
 * software distributed under the License is distributed on an
 * "AS IS" BASIS, WITHOUT WARRANTIES OR CONDITIONS OF ANY
 * KIND, either express or implied.  See the License for the
 * specific language governing permissions and limitations
 * under the License.
 *
 */
package org.apache.qpid.server.queue;

import org.apache.commons.lang.time.FastDateFormat;
import org.apache.log4j.Logger;

import org.apache.qpid.AMQException;
import org.apache.qpid.framing.BasicContentHeaderProperties;
import org.apache.qpid.framing.ContentHeaderBody;
import org.apache.qpid.management.common.mbeans.ManagedQueue;
import org.apache.qpid.management.common.mbeans.annotations.MBeanConstructor;
import org.apache.qpid.management.common.mbeans.annotations.MBeanDescription;
import org.apache.qpid.server.exchange.Exchange;
import org.apache.qpid.server.management.AMQManagedObject;
import org.apache.qpid.server.management.ManagedObject;
import org.apache.qpid.server.message.AMQMessage;
import org.apache.qpid.server.message.AMQMessageHeader;
import org.apache.qpid.server.message.MessageTransferMessage;
import org.apache.qpid.server.message.ServerMessage;
import org.apache.qpid.transport.MessageProperties;

import javax.management.JMException;
import javax.management.MBeanException;
import javax.management.MBeanNotificationInfo;
import javax.management.Notification;
import javax.management.ObjectName;
import javax.management.OperationsException;
import javax.management.monitor.MonitorNotification;
import javax.management.openmbean.ArrayType;
import javax.management.openmbean.CompositeData;
import javax.management.openmbean.CompositeDataSupport;
import javax.management.openmbean.CompositeType;
import javax.management.openmbean.OpenDataException;
import javax.management.openmbean.OpenType;
import javax.management.openmbean.SimpleType;
import javax.management.openmbean.TabularData;
import javax.management.openmbean.TabularDataSupport;
import javax.management.openmbean.TabularType;
import java.util.ArrayList;
import java.util.List;
import java.util.Set;


/**
 * AMQQueueMBean is the management bean for an {@link AMQQueue}.
 *
 * <p/><table id="crc"><caption>CRC Caption</caption>
 * <tr><th> Responsibilities <th> Collaborations
 * </table>
 */
@MBeanDescription("Management Interface for AMQQueue")
public class AMQQueueMBean extends AMQManagedObject implements ManagedQueue, QueueNotificationListener
{

    /** Used for debugging purposes. */
    private static final Logger LOGGER = Logger.getLogger(AMQQueueMBean.class);

    /** Date/time format used for message expiration and message timestamp formatting */
    public static final String JMSTIMESTAMP_DATETIME_FORMAT = "MM-dd-yy HH:mm:ss.SSS z";

    private static final FastDateFormat FAST_DATE_FORMAT = FastDateFormat.getInstance(JMSTIMESTAMP_DATETIME_FORMAT);

    private final AMQQueue _queue;
    private final String _queueName;
    // OpenMBean data types for viewMessages method

    private static OpenType[] _msgAttributeTypes = new OpenType[6]; // AMQ message attribute types.
    private static CompositeType _messageDataType = null; // Composite type for representing AMQ Message data.
    private static TabularType _messagelistDataType = null; // Datatype for representing AMQ messages list.

    // OpenMBean data types for viewMessageContent method
    private static CompositeType _msgContentType = null;
    private static OpenType[] _msgContentAttributeTypes = new OpenType[4];

    private final long[] _lastNotificationTimes = new long[NotificationCheck.values().length];
    private Notification _lastNotification = null;




    @MBeanConstructor("Creates an MBean exposing an AMQQueue")
    public AMQQueueMBean(AMQQueue queue) throws JMException
    {
        super(ManagedQueue.class, ManagedQueue.TYPE);
        _queue = queue;
        _queueName = queue.getName();
    }

    public ManagedObject getParentObject()
    {
        return _queue.getVirtualHost().getManagedObject();
    }

    static
    {
        try
        {
            init();
        }
        catch (JMException ex)
        {
            // This is not expected to ever occur.
            throw new RuntimeException("Got JMException in static initializer.", ex);
        }
    }

    /**
     * initialises the openmbean data types
     */
    private static void init() throws OpenDataException
    {
        _msgContentAttributeTypes[0] = SimpleType.LONG; // For message id
        _msgContentAttributeTypes[1] = SimpleType.STRING; // For MimeType
        _msgContentAttributeTypes[2] = SimpleType.STRING; // For Encoding
        _msgContentAttributeTypes[3] = new ArrayType(1, SimpleType.BYTE); // For message content
        _msgContentType = new CompositeType("Message Content", "AMQ Message Content",
                    VIEW_MSG_CONTENT_COMPOSITE_ITEM_NAMES_DESC.toArray(new String[VIEW_MSG_CONTENT_COMPOSITE_ITEM_NAMES_DESC.size()]),
                    VIEW_MSG_CONTENT_COMPOSITE_ITEM_NAMES_DESC.toArray(new String[VIEW_MSG_CONTENT_COMPOSITE_ITEM_NAMES_DESC.size()]),
                    _msgContentAttributeTypes);

        _msgAttributeTypes[0] = SimpleType.LONG; // For message id
        _msgAttributeTypes[1] = new ArrayType(1, SimpleType.STRING); // For header attributes
        _msgAttributeTypes[2] = SimpleType.LONG; // For size
        _msgAttributeTypes[3] = SimpleType.BOOLEAN; // For redelivered
        _msgAttributeTypes[4] = SimpleType.LONG; // For queue position
        _msgAttributeTypes[5] = SimpleType.INTEGER; // For delivery count

        _messageDataType = new CompositeType("Message", "AMQ Message", 
                VIEW_MSGS_COMPOSITE_ITEM_NAMES_DESC.toArray(new String[VIEW_MSGS_COMPOSITE_ITEM_NAMES_DESC.size()]),
                VIEW_MSGS_COMPOSITE_ITEM_NAMES_DESC.toArray(new String[VIEW_MSGS_COMPOSITE_ITEM_NAMES_DESC.size()]), _msgAttributeTypes);
        _messagelistDataType = new TabularType("Messages", "List of messages", _messageDataType,
                                                VIEW_MSGS_TABULAR_UNIQUE_INDEX.toArray(new String[VIEW_MSGS_TABULAR_UNIQUE_INDEX.size()]));
    }

    public String getObjectInstanceName()
    {
        return ObjectName.quote(_queueName);
    }

    public String getName()
    {
        return _queueName;
    }

    public boolean isDurable()
    {
        return _queue.isDurable();
    }

    public String getOwner()
    {
        return String.valueOf(_queue.getOwner());
    }

    public boolean isAutoDelete()
    {
        return _queue.isAutoDelete();
    }

    public Integer getMessageCount()
    {
        return _queue.getMessageCount();
    }

    public Integer getMaximumDeliveryCount()
    {
        return _queue.getMaximumDeliveryCount();
    }

    public Long getMaximumMessageSize()
    {
        return _queue.getMaximumMessageSize();
    }

    public Long getMaximumMessageAge()
    {
        return _queue.getMaximumMessageAge();
    }

    public void setMaximumMessageAge(Long maximumMessageAge)
    {
        _queue.setMaximumMessageAge(maximumMessageAge);
    }

    public void setMaximumMessageSize(Long value)
    {
        _queue.setMaximumMessageSize(value);
    }

    public Integer getConsumerCount()
    {
        return _queue.getConsumerCount();
    }

    public Integer getActiveConsumerCount()
    {
        return _queue.getActiveConsumerCount();
    }

    public Long getReceivedMessageCount()
    {
        return _queue.getReceivedMessageCount();
    }

    public Long getMaximumMessageCount()
    {
        return _queue.getMaximumMessageCount();
    }

    public void setMaximumMessageCount(Long value)
    {
        _queue.setMaximumMessageCount(value);
    }

    /**
     * returns the maximum total size of messages(bytes) in the queue.
     */
    public Long getMaximumQueueDepth()
    {
        return _queue.getMaximumQueueDepth();
    }

    public void setMaximumQueueDepth(Long value)
    {
        _queue.setMaximumQueueDepth(value);
    }

    /**
     * returns the total size of messages(bytes) in the queue.
     */
    public Long getQueueDepth() throws JMException
    {
        return _queue.getQueueDepth();
    }

    public Long getCapacity()
    {
        return _queue.getCapacity();
    }

    public void setCapacity(Long capacity) throws IllegalArgumentException
    {
        if( _queue.getFlowResumeCapacity() > capacity )
        {
            throw new IllegalArgumentException("Capacity must not be less than FlowResumeCapacity");
        }

    	_queue.setCapacity(capacity);
    }

    public Long getFlowResumeCapacity()
    {
        return _queue.getFlowResumeCapacity();
    }

    public void setFlowResumeCapacity(Long flowResumeCapacity) throws IllegalArgumentException
    {
        if( _queue.getCapacity() < flowResumeCapacity )
        {
            throw new IllegalArgumentException("FlowResumeCapacity must not exceed Capacity");
        }

        _queue.setFlowResumeCapacity(flowResumeCapacity);
    }

    public boolean isFlowOverfull()
    {
        return _queue.isOverfull();
    }

    public boolean isExclusive()
    {
        return _queue.isExclusive();
    }

    public void setExclusive(boolean exclusive) throws JMException
    {
        try
        {
            _queue.setExclusive(exclusive);
        }
        catch (AMQException e)
        {
            throw new JMException(e.toString());
        }
    }

    public void setAlternateExchange(String exchangeName)
    {
        _queue.setAlternateExchange(exchangeName);
    }

    public String getAlternateExchange()
    {
        Exchange exchange = _queue.getAlternateExchange();
        String name = exchange == null ? null : exchange.getName();
        return name == null ? null : name;
    }

    /**
     * Checks if there is any notification to be send to the listeners
     */
    public void checkForNotification(ServerMessage msg) throws AMQException
    {

        final Set<NotificationCheck> notificationChecks = _queue.getNotificationChecks();

        if(!notificationChecks.isEmpty())
        {
            final long currentTime = System.currentTimeMillis();
            final long thresholdTime = currentTime - _queue.getMinimumAlertRepeatGap();

            for (NotificationCheck check : notificationChecks)
            {
                if (check.isMessageSpecific() || (_lastNotificationTimes[check.ordinal()] < thresholdTime))
                {
                    if (check.notifyIfNecessary(msg, _queue, this))
                    {
                        _lastNotificationTimes[check.ordinal()] = currentTime;
                    }
                }
            }
        }

    }

    /**
     * Sends the notification to the listeners
     */
    public void notifyClients(NotificationCheck notification, AMQQueue queue, String notificationMsg)
    {
        // important : add log to the log file - monitoring tools may be looking for this
        LOGGER.info(notification.name() + " On Queue " + queue.getNameShortString() + " - " + notificationMsg);
        notificationMsg = notification.name() + " " + notificationMsg;

        _lastNotification =
            new Notification(MonitorNotification.THRESHOLD_VALUE_EXCEEDED, this, incrementAndGetSequenceNumber(),
                System.currentTimeMillis(), notificationMsg);

        getBroadcaster().sendNotification(_lastNotification);
    }

    public Notification getLastNotification()
    {
        return _lastNotification;
    }

    /**
     * @see AMQQueue#deleteMessageFromTop
     */
    public void deleteMessageFromTop() throws JMException
    {
        _queue.deleteMessageFromTop();
    }

    /**
     * Clears the queue of non-acquired messages
     *
     * @return the number of messages deleted
     * @see AMQQueue#clearQueue
     */
    public Long clearQueue() throws JMException
    {
        try
        {
            return _queue.clearQueue();
        }
        catch (AMQException ex)
        {
            throw new MBeanException(ex, "Error clearing queue " + _queueName);
        }
    }

    /**
     * returns message content as byte array and related attributes for the given message id.
     */
    public CompositeData viewMessageContent(long msgId) throws JMException
    {
        QueueEntry entry = _queue.getMessageOnTheQueue(msgId);

        if (entry == null)
        {
            throw new OperationsException("AMQMessage with message id = " + msgId + " is not in the " + _queueName);
        }

        ServerMessage serverMsg = entry.getMessage();
        final int bodySize = (int) serverMsg.getSize();


        List<Byte> msgContent = new ArrayList<Byte>();

        java.nio.ByteBuffer buf = java.nio.ByteBuffer.allocate(bodySize);
        int position = 0;

        while(position < bodySize)
        {
            position += serverMsg.getContent(buf, position);
            buf.flip();
            for(int i = 0; i < buf.limit(); i++)
            {
                msgContent.add(buf.get(i));
            }
            buf.clear();
        }

        AMQMessageHeader header = serverMsg.getMessageHeader();

        String mimeType = null, encoding = null;
        if (header != null)
        {
            mimeType = header.getMimeType();

            encoding = header.getEncoding();
        }


        Object[] itemValues = { msgId, mimeType, encoding, msgContent.toArray(new Byte[0]) };

        return new CompositeDataSupport(_msgContentType,
                VIEW_MSG_CONTENT_COMPOSITE_ITEM_NAMES_DESC.toArray(
                        new String[VIEW_MSG_CONTENT_COMPOSITE_ITEM_NAMES_DESC.size()]), itemValues);

    }

    /**
     * Returns the header contents of the messages stored in this queue in tabular form.
     * Deprecated as of Qpid JMX API 1.3
     */
    @Deprecated
    public TabularData viewMessages(int beginIndex, int endIndex) throws JMException
    {
        return viewMessages((long)beginIndex,(long)endIndex);
    }


    /**
     * Returns the header contents of the messages stored in this queue in tabular form.
     * @param startPosition The queue position of the first message to be viewed
     * @param endPosition The queue position of the last message to be viewed
     */
    public TabularData viewMessages(long startPosition, long endPosition) throws JMException
    {
        if ((startPosition > endPosition) || (startPosition < 1))
        {
            throw new OperationsException("From Index = " + startPosition + ", To Index = " + endPosition
                + "\n\"From Index\" should be greater than 0 and less than \"To Index\"");
        }

        if ((endPosition - startPosition) > Integer.MAX_VALUE)
        {
            throw new OperationsException("Specified MessageID interval is too large. Intervals must be less than 2^31 in size");
        }

        List<QueueEntry> list = _queue.getMessagesRangeOnTheQueue(startPosition,endPosition);
        TabularDataSupport _messageList = new TabularDataSupport(_messagelistDataType);

        try
        {
            // Create the tabular list of message header contents
            int size = list.size();

            for (int i = 0; i < size ; i++)
            {
                long position = startPosition + i;
                final QueueEntry queueEntry = list.get(i);
                ServerMessage serverMsg = queueEntry.getMessage();
                
                String[] headerAttributes = null;
                Object[] itemValues = null;
                
                if(serverMsg instanceof AMQMessage)
                {
                    AMQMessage msg = (AMQMessage) serverMsg;
                    ContentHeaderBody headerBody = msg.getContentHeaderBody();
                    // Create header attributes list
                    headerAttributes = getMessageHeaderProperties(headerBody);
                    itemValues = new Object[]{msg.getMessageId(), headerAttributes, headerBody.getBodySize(), queueEntry.isRedelivered(), position, queueEntry.getDeliveryCount()};
                }
                else if(serverMsg instanceof MessageTransferMessage)
                {
                    // We have a 0-10 message
                    MessageTransferMessage msg = (MessageTransferMessage) serverMsg;

                    // Create header attributes list
                    headerAttributes = getMessageTransferMessageHeaderProps(msg);
                    itemValues = new Object[]{msg.getMessageNumber(), headerAttributes, msg.getSize(), queueEntry.isRedelivered(), position, queueEntry.getDeliveryCount()};
                }
                else
                {
                    //unknown message
                    headerAttributes = new String[]{"N/A"};
                    itemValues = new Object[]{serverMsg.getMessageNumber(), headerAttributes, serverMsg.getSize(), queueEntry.isRedelivered(), position, queueEntry.getDeliveryCount()};
                }
                
                CompositeData messageData = new CompositeDataSupport(_messageDataType, 
                        VIEW_MSGS_COMPOSITE_ITEM_NAMES_DESC.toArray(new String[VIEW_MSGS_COMPOSITE_ITEM_NAMES_DESC.size()]), itemValues);
                _messageList.put(messageData);
            }
        }
        catch (AMQException e)
        {
            JMException jme = new JMException("Error creating message contents: " + e);
            jme.initCause(e);
            throw jme;
        }

        return _messageList;
    }

    private String[] getMessageHeaderProperties(ContentHeaderBody headerBody)
    {
        List<String> list = new ArrayList<String>();
        BasicContentHeaderProperties headerProperties = (BasicContentHeaderProperties) headerBody.getProperties();
        list.add("reply-to = " + headerProperties.getReplyToAsString());
        list.add("propertyFlags = " + headerProperties.getPropertyFlags());
        list.add("ApplicationID = " + headerProperties.getAppIdAsString());
        list.add("ClusterID = " + headerProperties.getClusterIdAsString());
        list.add("UserId = " + headerProperties.getUserIdAsString());
        list.add("JMSMessageID = " + headerProperties.getMessageIdAsString());
        list.add("JMSCorrelationID = " + headerProperties.getCorrelationIdAsString());

        int delMode = headerProperties.getDeliveryMode();
        list.add("JMSDeliveryMode = " +
                ((delMode == BasicContentHeaderProperties.PERSISTENT) ? "Persistent" : "Non_Persistent"));

        list.add("JMSPriority = " + headerProperties.getPriority());
        list.add("JMSType = " + headerProperties.getType());

        final long expirationDate = headerProperties.getExpiration();
        final long timestampDate = headerProperties.getTimestamp();

        addStringifiedJMSTimestamoAndJMSExpiration(list, expirationDate,
                timestampDate);

        return list.toArray(new String[list.size()]);
    }

    private String[] getMessageTransferMessageHeaderProps(MessageTransferMessage msg)
    {
        List<String> list = new ArrayList<String>();

        AMQMessageHeader header = msg.getMessageHeader();
        MessageProperties msgProps = msg.getHeader().getMessageProperties();

        String appID = null;
        String userID = null;

        if(msgProps != null)
        {
            appID = msgProps.getAppId() == null ? "null" : new String(msgProps.getAppId());
            userID = msgProps.getUserId() == null ? "null" : new String(msgProps.getUserId());
        }

        list.add("reply-to = " + header.getReplyTo());
        list.add("propertyFlags = "); //TODO
        list.add("ApplicationID = " + appID);
        list.add("ClusterID = "); //TODO
        list.add("UserId = " + userID);
        list.add("JMSMessageID = " + header.getMessageId());
        list.add("JMSCorrelationID = " + header.getCorrelationId());
        list.add("JMSDeliveryMode = " + (msg.isPersistent() ? "Persistent" : "Non_Persistent"));
        list.add("JMSPriority = " + header.getPriority());
        list.add("JMSType = " + header.getType());

        final long expirationDate = header.getExpiration();
        final long timestampDate = header.getTimestamp();
        addStringifiedJMSTimestamoAndJMSExpiration(list, expirationDate, timestampDate);

        return list.toArray(new String[list.size()]);
    }

    private void addStringifiedJMSTimestamoAndJMSExpiration(final List<String> list,
            final long expirationDate, final long timestampDate)
    {
        final String formattedExpirationDate = (expirationDate != 0) ? FAST_DATE_FORMAT.format(expirationDate) : null;
        final String formattedTimestampDate = (timestampDate != 0) ? FAST_DATE_FORMAT.format(timestampDate) : null;
        list.add("JMSExpiration = " + formattedExpirationDate);
        list.add("JMSTimestamp = " + formattedTimestampDate);
    }

    /**
     * @see ManagedQueue#moveMessages
     * @param fromMessageId
     * @param toMessageId
     * @param toQueueName
     * @throws JMException
     */
    public void moveMessages(long fromMessageId, long toMessageId, String toQueueName) throws JMException
    {
        if ((fromMessageId > toMessageId) || (fromMessageId < 1))
        {
            throw new OperationsException("\"From MessageId\" should be greater than 0 and less than \"To MessageId\"");
        }

        _queue.moveMessagesToAnotherQueue(fromMessageId, toMessageId, toQueueName);
    }

    /**
     * @see ManagedQueue#deleteMessages
     * @param fromMessageId
     * @param toMessageId
     * @throws JMException
     */
    public void deleteMessages(long fromMessageId, long toMessageId) throws JMException
    {
        if ((fromMessageId > toMessageId) || (fromMessageId < 1))
        {
            throw new OperationsException("\"From MessageId\" should be greater than 0 and less than \"To MessageId\"");
        }

        _queue.removeMessagesFromQueue(fromMessageId, toMessageId);
    }

    /**
     * @see ManagedQueue#copyMessages
     * @param fromMessageId
     * @param toMessageId
     * @param toQueueName
     * @throws JMException
     */
    public void copyMessages(long fromMessageId, long toMessageId, String toQueueName) throws JMException
    {
        if ((fromMessageId > toMessageId) || (fromMessageId < 1))
        {
            throw new OperationsException("\"From MessageId\" should be greater than 0 and less than \"To MessageId\"");
        }

        _queue.copyMessagesToAnotherQueue(fromMessageId, toMessageId, toQueueName);
    }

    /**
     * returns Notifications sent by this MBean.
     */
    @Override
    public MBeanNotificationInfo[] getNotificationInfo()
    {
        String[] notificationTypes = new String[] { MonitorNotification.THRESHOLD_VALUE_EXCEEDED };
        String name = MonitorNotification.class.getName();
        String description = "Either Message count or Queue depth or Message size has reached threshold high value";
        MBeanNotificationInfo info1 = new MBeanNotificationInfo(notificationTypes, name, description);

        return new MBeanNotificationInfo[] { info1 };
    }

} // End of AMQQueueMBean class