⚠️ v0.7.0
is a pre-release version — feel free to test and report issues!
📚 Full documentation available in the GitHub Wiki
- Multiple Transports: AMQP (RabbitMQ), In-Memory (sync)
- Middleware Chain: Extensible middleware system for message processing
- Event-Driven: Built-in event dispatcher for lifecycle hooks
- Retry Mechanism: Configurable retry strategies with exponential backoff
- Message Routing: Flexible routing system for message distribution
- Stamps System: Metadata attachment for message tracking
- YAML Configuration: Easy configuration management with
%env(...)%
support
Requires Go 1.24+
go get github.com/gerfey/messenger@v0.7.0
package main
type HelloMessage struct {
Text string
}
package main
type HelloHandler struct{}
func (h *HelloHandler) Handle(ctx context.Context, msg *HelloMessage) error {
fmt.Println("Hello:", msg.Text)
return nil
}
default_bus: default
buses:
default: ~
💡 If no transport is configured for a message, it will be executed synchronously by default (inline handler execution).
cfg, errConfig := config.LoadConfig("messenger.yaml")
if errConfig != nil {
fmt.Println("ERROR load config", "error", errConfig)
return
}
b := builder.NewBuilder(cfg, slog.Default())
b.RegisterHandler(&HelloHandler{})
m, _ := b.Build()
ctx := context.Background()
go m.Run(ctx)
bus, _ := m.GetDefaultBus()
_, _ = bus.Dispatch(ctx, &HelloMessage{Text: "World"})
- ✅ Commands with void return
- ✅ Queries with return value access
- ✅ Retry and Dead Letter Queue
- ✅ Custom Middleware and Transports
- ✅ Event Listeners and Lifecycle Hooks
See Usage Scenarios for commands, queries, return values and advanced use-cases.
- Fork the repository
- Create your feature branch (
git checkout -b feature/amazing-feature
) - Commit your changes (
git commit -m 'Add some amazing feature'
) - Push to the branch (
git push origin feature/amazing-feature
) - Open a Pull Request
This project is licensed under the MIT License - see the LICENSE file for details.
If you find this project useful, please consider starring ⭐️ it and sharing with others!
- Inspired by Symfony Messenger
- Built with ❤️ for the Go community