A Swift NIO based STOMP v1.0, v1.1 and v1.2 client.
Heavily inspired by Adam Fowler's work on MQTT NIO and valkey-swift.
Simple (or Streaming) Text Oriented Message Protocol (STOMP) is a simple interoperable protocol designed for asynchronous message passing between clients via mediating servers. It defines a text based wire-format for messages passed between these clients and servers. STOMP has been in active use for several years and is supported by many message brokers and client libraries.
STOMPNIO is a Swift NIO based implementation of a STOMP client. It supports:
- STOMP versions 1.0, 1.1, and 1.2
- Unencrypted and encrypted (via TLS) connections
- WebSocket connections
- POSIX sockets
- Apple's Network framework via NIOTransportServices (required for iOS)
- Unix domain sockets
You can create a connection to a STOMP broker and send and receive messages from it using STOMPConnection.withConnection.
try await STOMPConnection.withConnection(address: .hostname("localhost"), logger: logger) { connection in
try await connection.send(ByteBuffer(string: "Hello, STOMP over NIO!"), to: "/queue/a")
}try await STOMPConnection.withConnection(address: .hostname("localhost"), logger: logger) { connection in
try await connection.subscribe(to: "/queue/a") { subscription in
for try await frame in subscription {
print(String(buffer: frame.body))
}
}
}User guides and reference documentation for STOMP NIO can be found on the Swift Package Index.