Skip to content

About

No description, website, or topics provided.

Resources

Stars

3 stars

Watchers

0 watching

Forks

Repository files navigation

gopipe-azservicebus

Go Reference License: MIT

Azure Service Bus adapter for gopipe — publish and subscribe with batching, backpressure, lock renewal, and OpenTelemetry metrics.

Quick Start

import (
    "github.com/fxsml/gopipe-azservicebus"
    "github.com/fxsml/gopipe/message"
)

client, _ := azservicebus.NewClient("Endpoint=sb://...")

Publish

pub := azservicebus.NewPublisher(client, "my-topic", azservicebus.PublisherConfig{})

// Stream from a channel — batches automatically
pub.Publish(ctx, messages)

// Or send a single batch
pub.PublishBatch(ctx, batch)

Subscribe

sub := azservicebus.NewSubscriber(client, "my-topic", "my-subscription", azservicebus.SubscriberConfig{
    MaxInFlight: 50,
})

ch, _ := sub.Subscribe(ctx)
for msg := range ch {
    // process msg
    msg.Ack()
}

Features

Feature Details
Batching Configurable batch size and flush timeout
Backpressure Semaphore-based in-flight limiting
Lock renewal Auto-detected from broker; configurable override
Reconnection Automatic receiver/sender recreation on failure
Graceful shutdown Drains in-flight messages before closing
Telemetry OpenTelemetry counters and histograms
CloudEvents Preserves CloudEvents AMQP properties
Auth Connection string or DefaultAzureCredential

Installation

go get github.com/fxsml/gopipe-azservicebus

CLI

A command-line tool for publishing and subscribing to Azure Service Bus using JSONL (JSON Lines).

Install

go install github.com/fxsml/gopipe-azservicebus/cmd/gopipe-azservicebus@latest

Connection

Pass the Service Bus connection string via flag or environment variable:

export SERVICEBUS_CONNECTION="Endpoint=sb://..."
# or per-command: --connection "Endpoint=sb://..."
# or via env file: --env-file .env.local

Publish

Read JSONL from stdin or a file and publish to a topic:

# from stdin
echo '{"specversion":"1.0","type":"com.example.event","source":"/test","id":"1"}' \
  | gopipe-azservicebus pub --topic my-topic

# from file
gopipe-azservicebus pub --topic my-topic --input-file events.jsonl

Subscribe

Receive messages and write them as JSONL to stdout or a file:

# to stdout (Ctrl+C to stop)
gopipe-azservicebus sub --subscription my-topic/my-subscription

# to file, stop after 100 messages or 30 seconds
gopipe-azservicebus sub --subscription my-topic/my-subscription \
  --output-file out.jsonl --limit 100 --timeout 30s

# non-destructive peek (messages are not acknowledged)
gopipe-azservicebus sub --subscription my-topic/my-subscription --peek

Known Issues

See KNOWN-ISSUES.md for documented edge cases and mitigations.

License

MIT

About

No description, website, or topics provided.

Resources

Stars

3 stars

Watchers

0 watching

Forks

Releases

Packages

Contributors

Languages