Messaging and Queuing API

Scaleway Messaging and Queuing is a message broker tool that allows you to transfer messages between different platforms and port your microservice applications to the cloud. Messaging and Queuing offers notifications, queues, FIFOs and streams, and includes all major features of a modern message broker (such as message persistence).

Currently, two protocol options are available for your namespaces (brokers): NATS and SQS/SNS.

Note:

Messaging and Queuing is currently in Public Beta

Concepts

Refer to our dedicated concepts page to find definitions of all terminology related to Messaging and Queuing.

Quickstart

Creating a namespace and credentials

  1. Configure your environment variables.

    Note:

    This is an optional step that seeks to simplify your usage of the API.

    export SCW_ACCESS_KEY="<API access key>"
    export SCW_SECRET_KEY="<API secret key>"
    export SCW_PROJECT_ID="<Scaleway Project ID>
  2. Create a namespace. Run the following command to create a namespace. You can customize the details in the payload to your needs (e.g. to create a NATS or SQS/SNS namespace): use the information in the table below to help you.

    curl -X POST \
    -H 'X-Auth-Token: '$SCW_SECRET_KEY \
    -H 'Content-Type: application/json' \
    'https://api.scaleway.com/mnq/v1alpha1/regions/fr-par/namespaces' \
    -d '{
    "name": "my-broker",
    "project_id": "'$SCW_PROJECT_ID'",
    "protocol": "nats"
    }'
    ParameterRequired value for a NATS namespaceRequired value for an SQS/SNS namespace
    protocolnatssqs_sns
  3. Create credentials. These are necessary to connect to your namespace. Modify the command shown below as necessary:

    • For namespace_id, use the ID of the namespace you created in the previous step.
    • If you are creating credentials for a NATS namespace, delete the permissions object from the payload, as it is only applicable for SQS/SNS namespaces.
    • If you are creating credentials for a SQS/SNS namespace, you can customize the permissions values to your needs, using true or false.

    Use the following command to create credentials:

    curl -X POST \
    -H 'X-Auth-Token: '$SCW_SECRET_KEY \
    -H 'Content-Type: application/json' \
    'https://api.scaleway.com/mnq/v1alpha1/regions/fr-par/credentials' \
    -d '{
    "name": "my-credentials",
    "namespace_id": "AARYMIB9CGRRTS7ZZ2JUFQNS9ROJYQVX7RMWWPBSPRUZEMVOPMQESFUZI",
    "permissions": {
    "can_publish": true,
    "can_receive": true,
    "can_manage": true
    }
    }' | tee my-credentials.json
    Tip:

    Adding | tee my-credentials.json to the end of the command saves the JSON object returned by the API to a file, for use in later steps.

Publishing and subscribing to messages with NATS

Make sure you have jq installed on your machine, and that you have installed the NATS CLI

If you created a NATS namespace and credentials, follow these steps to publish and subscribe to your first messages.

  1. Execute the following command to save the credentials from step 3 above to the required file format:

    `jq -r .nats_credentials.content my-credentials.json > nats.creds`
  2. Open two terminals, one to subscribe to a subject and another to publish a message on this subject.

  3. In the first terminal, execute the following command to subscribe to a subject:

    nats sub -s $(jq -r .endpoint nats-broker.json) --creds nats.creds my-subject
  4. In the second terminal, execute the following command to publish a message:

    nats pub -s $(jq -r .endpoint nats-broker.json) --creds nats.creds my-subject 'Hi there!'

Creating queues and sending/receiving messages with SQS/SNS

  1. Follow the steps in our dedicated documentation to connect your namespace to the AWS CLI.

  2. Follow the steps in our dedicated documentation to start creating queues and sending and receiving messages with SQS or SNS.

Deleting a namespace

Use the following command to delete your namespace when you're finished with it. Ensure you replace the {namespace_id} parameter in the path with your own namespace ID.

curl -X DELETE \
-H "X-Auth-Token: $SCW_SECRET_KEY" \
-H "Content-Type: application/json" \
"https://api.scaleway.com/mnq/v1alpha1/regions/fr-par/namespaces/{namespace_id}"
Requirements:

Technical limitations

The following limitations apply when using Messaging and Queuing:

  • Scaleway Messaging and Queuing does not fully support all AWS SQS/SNS actions. See the compatibility matrices for SNS and SQS for more information.
  • SNS currently supports subscriptions with the following protocols:
    • sqs
    • http
    • https (self-signed certificate are not supported)
    • lambda (used to call a Scaleway Serverless function)
  • The maximum message size is currently 256 kB.
  • The maximum storage capacity is currently 100 MB per namespace, across all its streams.
  • The product is currently in Public Beta, we do not guarantee performance or stability. Use with care, as you may encounter data loss.

Technical information

Regional availability

Scaleway Messaging and Queuing is currently available only in the Paris, France region (fr-par).

Credentials

Note the following when creating credentials:

  • NATS credentials give full access to the messaging namespace
  • SQS/SNS credentials use a simplified permissions system: each credential created by the gives permissions to the whole namespace. There are 3 permissions:
    • can_publish : Allows to send messages to a Queue/Topic.
    • can_receive : Allows to receive and acknowledge (delete) messages and to subscribe to a Topic.
    • can_manage : Allows all other actions (Creating, Listing, Updating, Deleting Queues/Topics).

Going further

For more help using Scaleway Messaing and Queuing, check out the following resources:

Going further with NATS

Going further with SQS/SNS

Messaging and Queuing namespaces are brokers which set a scope for your queues, topics and credentials. Credentials are specific to a given namespace. Each namespace has a protocol: either NATS or SQS/SNS

GET
/mnq/v1alpha1/regions/{region}/namespaces
POST
/mnq/v1alpha1/regions/{region}/namespaces
PATCH
/mnq/v1alpha1/regions/{region}/namespaces
GET
/mnq/v1alpha1/regions/{region}/namespaces/{namespace_id}
DELETE
/mnq/v1alpha1/regions/{region}/namespaces/{namespace_id}

Messaging and Queuing credentials give services and platforms access to your Messaging and Queuing namespace, allowing them to connect ot the host system. Credentials are protocol-specific: for SQS/SNS credentials different levels of permissions can be defined, whereas NATS credentials give full access to the messaging namespace

GET
/mnq/v1alpha1/regions/{region}/credentials
POST
/mnq/v1alpha1/regions/{region}/credentials
GET
/mnq/v1alpha1/regions/{region}/credentials/{credential_id}
PATCH
/mnq/v1alpha1/regions/{region}/credentials/{credential_id}
DELETE
/mnq/v1alpha1/regions/{region}/credentials/{credential_id}