|
18 | 18 | import org.graylog2.syslog4j.SyslogConfigIF; |
19 | 19 | import org.graylog2.syslog4j.SyslogIF; |
20 | 20 | import org.graylog2.syslog4j.SyslogRuntimeException; |
| 21 | +import org.graylog2.syslog4j.impl.AbstractSyslogConfigIF; |
21 | 22 | import org.graylog2.syslog4j.impl.message.processor.SyslogMessageProcessor; |
22 | 23 | import org.graylog2.syslog4j.impl.message.processor.structured.StructuredSyslogMessageProcessor; |
23 | 24 | import org.graylog2.syslog4j.impl.net.tcp.TCPNetSyslogConfig; |
@@ -92,13 +93,23 @@ public SyslogOutput(@Assisted Stream stream, @Assisted Configuration conf) { |
92 | 93 | format = "plain"; |
93 | 94 | } |
94 | 95 |
|
| 96 | + int maxQueueSize = 500; |
| 97 | + String queueSizeStr = conf.getString("maxQueueSize"); |
| 98 | + if (queueSizeStr != null && !queueSizeStr.trim().isEmpty()) { |
| 99 | + maxQueueSize = Integer.parseInt(queueSizeStr); |
| 100 | + } |
| 101 | + |
95 | 102 | log.info("Creating syslog output " + protocol + "://" + host + ":" + port + ", format " + format); |
96 | 103 | SyslogConfigIF config = null; |
97 | 104 | if (protocol.toLowerCase().equals("udp")) { |
98 | | - config = new UDPNetSyslogConfig(); |
| 105 | + UDPNetSyslogConfig udpConfig = new UDPNetSyslogConfig(); |
| 106 | + udpConfig.setMaxQueueSize(maxQueueSize); |
| 107 | + config = udpConfig; |
99 | 108 | } else |
100 | 109 | if (protocol.toLowerCase().equals("tcp")) { |
101 | | - config = new TCPNetSyslogConfig(); |
| 110 | + TCPNetSyslogConfig tcpConfig = new TCPNetSyslogConfig(); |
| 111 | + tcpConfig.setMaxQueueSize(maxQueueSize); |
| 112 | + config = tcpConfig; |
102 | 113 | } else |
103 | 114 | if (protocol.toLowerCase().equals("tcp-ssl")) { |
104 | 115 | CustomSSLSyslogConfig sslConfig = new CustomSSLSyslogConfig(); |
@@ -128,6 +139,7 @@ public SyslogOutput(@Assisted Stream stream, @Assisted Configuration conf) { |
128 | 139 | sslConfig.setKeyStorePassword(ksp); |
129 | 140 | sslConfig.setTrustStore(ts); |
130 | 141 | sslConfig.setTrustStorePassword(tsp); |
| 142 | + sslConfig.setMaxQueueSize(maxQueueSize); |
131 | 143 | } else { |
132 | 144 | throw new IllegalArgumentException("Unknown protocol: " + protocol); |
133 | 145 | } |
@@ -320,6 +332,8 @@ public ConfigurationRequest getRequestedConfiguration() { |
320 | 332 |
|
321 | 333 | configurationRequest.addField(new TextField("maxlen", "Maximum message length", "", "Maximum message (body) length. Longer messages will be truncated. If not specified defaults to 16384 bytes.", ConfigurationField.Optional.OPTIONAL)); |
322 | 334 |
|
| 335 | + configurationRequest.addField(new TextField("maxQueueSize", "Maximum queue size", "500", "Maximum number of messages to queue internally. Set to -1 for unlimited. Default is 500.", ConfigurationField.Optional.OPTIONAL)); |
| 336 | + |
323 | 337 | configurationRequest.addField(new TextField("keystore", "Key store", "", "Path to Java keystore (required for SSL over TCP). Must contain private key and cert for this client.", ConfigurationField.Optional.OPTIONAL)); |
324 | 338 | configurationRequest.addField(new TextField("keystorePassword", "Key store password", "", "", ConfigurationField.Optional.OPTIONAL)); |
325 | 339 |
|
|
0 commit comments