Skip to main content

Extend Asynchronous Messaging

Last updated on July 22, 2026

Overview

Extend Asynchronous Messaging allows Extend apps to publish and consume custom events across the platform. With this capability, different Extend apps can communicate with one another in a loosely coupled, event-driven manner. Any Extend app can publish custom events to signal that something has happened, such as a data update or user action. These events can then be received and processed by your Extend Event Handler app, which listens for specific custom events and performs the appropriate actions in response.

Create and delete event topics

  1. In Admin Portal, open the Extend menu, and click Event Topics.

    Create topic menu

  2. Click Create Topic to add a new topic.

    Create topic landing

  3. If you have existing topics, they will be listed in the same page and you are able to delete topics from here.

    Create topic list

Subscribe and unsubscribe to event topics

  1. On the App Details page of your Extend Event Handler app, open the Event Topics tab and click Subscribe Event Topic.

    Subscribe topic list

  2. In the Subscribe Event Topic popup, select the event topics you want to subscribe to.

    Subscribe topic modal

    note

    When subscribing to event topics for the first time, you may need to restart your Extend Event Handler app for the changes to take effect.

    Subscribe topic restart

  3. To unsubscribe from a topic, go to the Event List section in the Event Topics tab and click Unsubscribe next to the corresponding event topic.

Publish custom events from your Extend app

  1. In your Extend app project, create pkg/proto/async_messaging folder and put publisher_service.proto there.

  2. Run make proto to generate publisher client code from publisher_service.proto.

  3. Initialize the publisher client. Use ASYNC_MESSAGING_PUBLISHER_GRPC_PORT environment variable value for the localhost port to connect to.

    publisherServiceAddr := "localhost:" + common.GetEnv("ASYNC_MESSAGING_PUBLISHER_GRPC_PORT", "7474")
    publisherConn, err := grpc.NewClient(
    publisherServiceAddr,
    grpc.WithTransportCredentials(insecure.NewCredentials()),
    )
    if err != nil {
    logrus.Fatalf("Failed to connect to publisher service at %s: %v", publisherServiceAddr, err)
    }
    defer publisherConn.Close()
  4. Publish custom events using the publisher client.

    topic := "PlayerJoined"
    event := PlayerJoinedEvent{
    EventType: "PlayerJoined",
    PlayerId: req.PlayerId,
    Timestamp: time.Now().UTC().Format(time.RFC3339),
    }

    bodyBytes, err := json.Marshal(event)
    if err != nil {
    return nil, status.Errorf(codes.Internal, "failed to marshal event: %v", err)
    }

    msg := &asyncMessaging.PublishMessageRequest{
    Body: string(bodyBytes),
    Topic: topic,
    Metadata: map[string]string{}, // Empty metadata
    }

Consume custom events in your Extend Event Handler app

  1. In your Extend Event Handler app project, create pkg/proto/async_messaging folder and put consumer_service.proto there.

  2. Run make proto to generate consumer server code from consumer_service.proto.

  3. Implement the OnMessage handler for the custom events.

    package service

    import (
    "context"

    "github.com/sirupsen/logrus"
    "google.golang.org/protobuf/types/known/emptypb"

    pb "extend-async-messaging/pkg/pb/async_messaging"
    )

    type AsyncMessagingHandler struct {
    pb.UnimplementedAsyncMessagingConsumerServiceServer
    }

    func NewAsyncMessagingHandler() *AsyncMessagingHandler {
    return &AsyncMessagingHandler{}
    }

    func (h *AsyncMessagingHandler) OnMessage(ctx context.Context, msg *pb.ReceivedMessage) (*emptypb.Empty, error) {
    if msg.Topic == "" {
    logrus.Error("received a message with empty topic")
    } else {
    logrus.Infof("received message from topic: %s, body: %s", msg.Topic, msg.Body)
    }
    return &emptypb.Empty{}, nil
    }
  4. Register the handler.

    asyncHandler := service.NewAsyncMessagingHandler()
    pb.RegisterAsyncMessagingConsumerServiceServer(s, asyncHandler)

Samples

The sample Extend apps below includes an Extend Service Extension app that publishes a custom event, along with an Extend Event Handler app that consumes that event.

git clone https://github.com/AccelByte/extend-service-extension-with-am-publisher-go.git

git clone https://github.com/AccelByte/extend-event-handler-with-am-consumer-go.git