-
Notifications
You must be signed in to change notification settings - Fork 61
/
Copy pathDisconnectedBufferOptions.java
91 lines (76 loc) · 2.65 KB
/
DisconnectedBufferOptions.java
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
/*******************************************************************************
* Copyright (c) 2016 IBM Corp.
*
* All rights reserved. This program and the accompanying materials
* are made available under the terms of the Eclipse Public License v1.0
* and Eclipse Distribution License v1.0 which accompany this distribution.
*
* The Eclipse Public License is available at
* http://www.eclipse.org/legal/epl-v10.html
* and the Eclipse Distribution License is available at
* http://www.eclipse.org/org/documents/edl-v10.php.
*
* Contributors:
* James Sutton - Initial Contribution for Automatic Reconnect & Offline Buffering
*/
package org.eclipse.paho.client.mqttv3;
/**
* Holds the set of options that govern the behaviour
* of Offline (or Disconnected) buffering of messages
*/
public class DisconnectedBufferOptions {
/**
* The default size of the disconnected buffer
*/
public static final int DISCONNECTED_BUFFER_SIZE_DEFAULT = 5000;
public static final boolean DISCONNECTED_BUFFER_ENABLED_DEFAULT = false;
public static final boolean PERSIST_DISCONNECTED_BUFFER_DEFAULT = false;
public static final boolean DELETE_OLDEST_MESSAGES_DEFAULT = false;
private int bufferSize = DISCONNECTED_BUFFER_SIZE_DEFAULT;
private boolean bufferEnabled = DISCONNECTED_BUFFER_ENABLED_DEFAULT;
private boolean persistBuffer = PERSIST_DISCONNECTED_BUFFER_DEFAULT;
private boolean deleteOldestMessages = DELETE_OLDEST_MESSAGES_DEFAULT;
/**
* Constructs a new <code>DisconnectedBufferOptions</code> object using the
* default values.
*
* The defaults are:
* <ul>
* <li>The disconnected buffer is disabled</li>
* <li>The buffer holds 5000 messages</li>
* <li>The buffer is not persisted</li>
* <li>Once the buffer is full, old messages are not deleted</li>
* </ul>
* More information about these values can be found in the setter methods.
*/
public DisconnectedBufferOptions() {
// Do Nothing.
}
public int getBufferSize() {
return bufferSize;
}
public void setBufferSize(int bufferSize) {
if (bufferSize < 1) {
throw new IllegalArgumentException();
}
this.bufferSize = bufferSize;
}
public boolean isBufferEnabled() {
return bufferEnabled;
}
public void setBufferEnabled(boolean bufferEnabled) {
this.bufferEnabled = bufferEnabled;
}
public boolean isPersistBuffer() {
return persistBuffer;
}
public void setPersistBuffer(boolean persistBuffer) {
this.persistBuffer = persistBuffer;
}
public boolean isDeleteOldestMessages() {
return deleteOldestMessages;
}
public void setDeleteOldestMessages(boolean deleteOldestMessages) {
this.deleteOldestMessages = deleteOldestMessages;
}
}