View Javadoc
1   /*
2    * Copyright (c) MuleSoft, Inc.  All rights reserved.  http://www.mulesoft.com
3    * The software in this package is published under the terms of the CPAL v1.0
4    * license, a copy of which has been included with this distribution in the
5    * LICENSE.txt file.
6    */
7   package org.mule.config;
8   
9   import org.mule.api.lifecycle.InitialisationException;
10  import org.mule.util.queue.QueueConfiguration;
11  import org.mule.util.queue.QueueManager;
12  
13  /**
14   * <code>QueueProfile</code> determines how an internal queue for a service will
15   * behave
16   */
17  
18  public class QueueProfile
19  {
20      private int maxOutstandingMessages = 0;
21      private boolean persistent = false;
22  
23      public QueueProfile()
24      {
25          super();
26      }
27  
28      public QueueProfile(int maxOutstandingMessages, boolean persistent)
29      {
30          this.maxOutstandingMessages = maxOutstandingMessages;
31          this.persistent = persistent;
32      }
33  
34      public QueueProfile(QueueProfile queueProfile)
35      {
36          this.maxOutstandingMessages = queueProfile.getMaxOutstandingMessages();
37          this.persistent = queueProfile.isPersistent();
38      }
39  
40      /**
41       * This specifies the number of messages that can be queued before it starts
42       * blocking.
43       * 
44       * @return the max number of messages that will be queued
45       */
46      public int getMaxOutstandingMessages()
47      {
48          return maxOutstandingMessages;
49      }
50  
51      /**
52       * This specifies the number of messages that can be queued before it starts
53       * blocking.
54       * 
55       * @param maxOutstandingMessages the max number of messages that will be queued
56       */
57      public void setMaxOutstandingMessages(int maxOutstandingMessages)
58      {
59          this.maxOutstandingMessages = maxOutstandingMessages;
60      }
61  
62      public boolean isPersistent()
63      {
64          return persistent;
65      }
66  
67      public void setPersistent(boolean persistent)
68      {
69          this.persistent = persistent;
70      }
71  
72      public void configureQueue(String component, QueueManager queueManager) throws InitialisationException
73      {
74          QueueConfiguration qc = new QueueConfiguration(maxOutstandingMessages, persistent);
75          queueManager.setQueueConfiguration(component, qc);
76      }
77  
78      public String toString()
79      {
80          return "QueueProfile{maxOutstandingMessage=" + maxOutstandingMessages + ", persistent="
81                 + persistent + "}";
82      }
83  }