Get started with Togo MQ in just a few minutes. This guide will walk you through creating an account, generating an API token, and sending your first message.
{info} Already have an account? Simply log in to access your dashboard.
To use Togo MQ, you need an API authentication token:
{danger} Keep your tokens secure! Never commit API tokens to version control or share them publicly. Treat them like passwords.
Currently, we provide an official SDK for Go with more languages coming soon.
go get github.com/TogoMQ/togomq-sdk-go
Requirements:
Here's a simple example to publish your first message:
package main
import (
"context"
"log"
"github.com/TogoMQ/togomq-sdk-go"
)
func main() {
// Create client with your token
config := togomq.NewConfig(
togomq.WithToken("your-token-here"),
)
client, err := togomq.NewClient(config)
if err != nil {
log.Fatal(err)
}
defer client.Close()
// Create a message
msg := togomq.NewMessage("my-first-topic", []byte("Hello, Togo MQ!"))
// Publish the message
resp, err := client.PubBatch(context.Background(), []*togomq.Message{msg})
if err != nil {
log.Fatal(err)
}
log.Printf("Published %d messages successfully!\n", resp.MessagesReceived)
}
Here's how to subscribe and receive messages:
package main
import (
"context"
"log"
"github.com/TogoMQ/togomq-sdk-go"
)
func main() {
// Create client
config := togomq.NewConfig(togomq.WithToken("your-token-here"))
client, err := togomq.NewClient(config)
if err != nil {
log.Fatal(err)
}
defer client.Close()
// Subscribe to your topic
opts := togomq.NewSubscribeOptions("my-first-topic")
msgChan, errChan, err := client.Sub(context.Background(), opts)
if err != nil {
log.Fatal(err)
}
// Process incoming messages
for {
select {
case msg := <-msgChan:
if msg == nil {
return
}
log.Printf("Received: %s\n", string(msg.Body))
case err := <-errChan:
log.Printf("Error: %v\n", err)
return
}
}
}
Congratulations! You've sent your first message with Togo MQ. Here's what to explore next:
{success} Need help? Contact our support team at support@togomq.io