Network Swiftlet
Overview
The Network Swiftlet (sys$net) manages all network connectivity for the SwiftMQ router, including TCP/IP and intra-VM connections. It is responsible for establishing, tracking, and monitoring both incoming and outgoing connections, as well as collecting throughput statistics and enforcing connection policies such as maximum message size and connection timeouts.
Features
TCP/IP Listener and Connector Management
The Network Swiftlet provides mechanisms to create and manage TCP listeners (for accepting incoming network connections) and TCP connectors (for establishing outgoing connections). Each listener or connector is associated with a specific Swiftlet and can be configured to use plain or TLS-encrypted sockets. Listeners and connectors are started either immediately or in a delayed fashion, depending on system state and configuration. The Swiftlet ensures that all listeners and connectors are properly started and stopped during router lifecycle events.
TLS/SSL Support
Listeners and connectors can be configured to use TLS/SSL for secure communication. The SSL context is created based on Java system properties specifying keystore/truststore or certificate/private key files. Client authentication can be required by setting the swiftmq.tls.clientauth.enabled system property to true.
Connection Policy Enforcement
The Swiftlet enforces connection policies such as DNS resolution (optional), server socket reuse, and maximum chunk size (limiting the maximum size of incoming messages). It also supports a configurable timeout for detecting and closing zombi (inactive or unresponsive) connections.
Configuration Example:
<swiftlet name="sys$net" dns-resolve-enabled="true" max-chunk-size="1048576"/>
Intra-VM Connection Handling
Beyond TCP/IP, the Network Swiftlet manages intra-VM (in-process) connections for internal communication between Swiftlets. It provides APIs to create and remove intra-VM listeners, and to connect intra-VM clients to these listeners. Intra-VM connections are tracked and managed similarly to network connections, with support for data chunking and throughput monitoring.
Connection Usage Tracking and Throughput Statistics
The Swiftlet maintains a dynamic list of all active connections, recording metadata such as the owning Swiftlet, connection time, and real-time throughput statistics (input/output KB/s). Throughput is collected at a configurable interval and is only active when the management tool is connected. This allows administrators to monitor network load and identify bottlenecks or abnormal traffic patterns.
Dynamic Connection List
Each connection is represented as an entity in the usage list, with properties for the owning Swiftlet, connection time, and current throughput. Connections are added and removed automatically as they are established or closed.
Throughput Collection Control
Throughput collection is enabled only when the management tool is active, minimizing performance overhead during normal operation. The collection interval can be adjusted via configuration.
Configuration Example:
<swiftlet name="sys$net" collect-interval="5000"/>
Resource and Task Management
The Swiftlet uses a configurable thread pool for handling network events, with the number of selector tasks adjustable to optimize performance for multi-processor systems. All network I/O is handled asynchronously, and the Swiftlet ensures graceful shutdown by waiting for active connections to close and releasing all resources.
Selector Task Configuration
The number of selector tasks (network I/O threads) can be increased to improve throughput on multi-core systems. This is set via the number-selector-tasks property and requires a router reboot to take effect.
Configuration Example:
<swiftlet name="sys$net" number-selector-tasks="20"/>
Configuration Guide
Enable DNS Resolution for Incoming Connections
Enable DNS name resolution for all incoming and outgoing connections, which can be useful for environments where hostnames are preferred over IP addresses for access control or logging.
- Set the
dns-resolve-enabledattribute totrueon thesys$netswiftlet in your routerconfig.xml. - Restart the router for the setting to take effect.
<swiftlet name="sys$net" dns-resolve-enabled="true"/>
Limit Maximum Incoming Message Size
Restrict the maximum allowed size for incoming messages (network chunks) to prevent resource exhaustion or denial-of-service attacks.
- Set the
max-chunk-sizeattribute (in bytes) on thesys$netswiftlet. - Restart the router if the property is not dynamically changeable.
<swiftlet name="sys$net" max-chunk-size="1048576"/>
Increase Network I/O Threads for High-Performance Environments
Increase the number of selector tasks to optimize network throughput on servers with multiple processors.
- Set the
number-selector-tasksattribute to a higher value (e.g., 20) on thesys$netswiftlet. - Reboot the router to apply the change.
<swiftlet name="sys$net" number-selector-tasks="20"/>
Configure Throughput Collection Interval
Adjust how frequently the Swiftlet collects and updates throughput statistics for active connections.
- Set the
collect-intervalattribute (in milliseconds) on thesys$netswiftlet. - No restart is required; the change takes effect dynamically.
<swiftlet name="sys$net" collect-interval="5000"/>
Configuration Reference
The top-level entity in routerconfig.xml is <swiftlet name="sys$net">.
<swiftlet name="sys$net"> Properties
These properties are attributes of the <swiftlet name="sys$net"> entity.
| Parameter | Type | Default | Mandatory | Reboot Required | Description |
|---|---|---|---|---|---|
collect-interval |
Long | 1000 |
No | No | Throughput Collect Interval |
zombi-connection-timeout |
Long | 0 |
No | No | Zombi-Connection Timeout |
dns-resolve-enabled |
Boolean | false |
No | No | Resolve DNS Names during Connect |
reuse-serversockets |
Boolean | true |
No | No | Re-Use Server Sockets |
number-selector-tasks |
Integer | 10 |
No | Yes | Number Selector Tasks. Might be increased for Multi-Processor Machines. (min: 4) |
max-chunk-size |
Long | -1 |
No | No | Maximum size of a network chunk (chunk = message in JMS) to limit the incoming message size router-wide. |
<swiftlet name="sys$net" collect-interval="1000" zombi-connection-timeout="0" dns-resolve-enabled="false" reuse-serversockets="true" number-selector-tasks="10" max-chunk-size="-1"/>