Contents

fpseverino/stomp-nio

A Swift NIO based STOMP v1.0, v1.1 and v1.2 client.

Overview

The STOMP NIO project uses a connection pool, which requires a background process to manage it. You can either run it using a TaskGroup or async let. Below we are using async let to run the connection pool background process.

let stompClient = STOMPClient(.hostname("localhost"), logger: logger)
async let _ = stompClient.run()
// use STOMP client

Or you can use STOMPClient with swift-service-lifecycle.

Once you have a STOMP client setup and running you can send STOMP frames directly from the STOMPClient.

try await stompClient.send("Hello, STOMP over NIO!", to: "/queue/a")

Or you can create a connection and subscribe to destinations from that connection using STOMPClient.withConnection().

try await stompClient.withConnection { connection in
    try await connection.subscribe(to: "/queue/a") { subscription in
        for try await frame in subscription {
            print(String(buffer: frame.body))
        }
    }
}

Documentation

User guides and reference documentation for STOMP NIO can be found on the Swift Package Index.

Package Metadata

Repository: fpseverino/stomp-nio

Default branch: main

README: README.md