Service: Really Simple Message Queue - EyevinnOSC/community GitHub Wiki

Really Simple Message Queue

Really Simple Message Queue (serviceId smrchy-rest-rsmq) is a lightweight message queue with a REST API, backed by Redis. In Eyevinn Open Source Cloud (OSC) it is a long-running service instance. License: MIT.

What it can do

  • Create named queues, send messages, receive the next message and delete processed messages, all over HTTP.
  • Be used from any platform (PHP, .NET and others) without a client library.
  • Use Valkey as the queue store.

Creating an instance

Create a Valkey instance first (valkey-io-valkey, see Valkey) and confirm it is running. Read its host and port with describe-service-instance; the Redis URL is redis://{host}:{port}. Store it as a service secret with create-service-secret (serviceId smrchy-rest-rsmq, for example name redisurl).

Then call create-service-instance with serviceId: "smrchy-rest-rsmq"; the instance name must be alphanumeric and at most 20 characters.

{ "name": "myqueue", "RedisUrl": "{{secrets.redisurl}}" }

Verify with wait-for-service-ready or get-instance-status; describe-service-instance returns the base URL.

Options

Option Required Type Meaning
name Yes string Name of the instance. Alphanumeric, at most 20 characters.
RedisUrl Yes string, sensitive Redis connection URL where rsmq stores queues, for example redis://host:6379. Only host and port are used; no password or database is applied, so use a Valkey instance without a password. Maps to REDIS_URL; the application default is redis://127.0.0.1:6379.

Store RedisUrl as a service secret and pass it as {{secrets.NAME}}, which only works as the entire field value. Overwriting a secret does not restart a running instance.

Valkey options

Service valkey-io-valkey:

Option Required Type Meaning
name Yes string Name of the instance.
Password No string, sensitive Password clients must supply to authenticate.

Using the instance

Create a queue:

curl -X POST https://{instance-url}/queues/tasks \
  -H 'Content-Type: application/json' \
  -d '{"maxsize": -1, "vt": 30}'

Send a message:

curl -X POST https://{instance-url}/queues/tasks/messages \
  -H 'Content-Type: application/json' \
  -d '{"message": "{\"job\":\"resize\",\"file\":\"photo.jpg\"}"}'

Receive the next message (invisible for vt seconds):

curl https://{instance-url}/queues/tasks/messages/pop

Delete a processed message:

curl -X DELETE https://{instance-url}/queues/tasks/messages/{id}

JavaScript:

const BASE = 'https://myqueue.smrchy-rest-rsmq.auto.prod-se.osaas.io';

async function enqueue(job) {
  await fetch(`${BASE}/queues/jobs/messages`, {
    method: 'POST',
    headers: { 'Content-Type': 'application/json' },
    body: JSON.stringify({ message: JSON.stringify(job) })
  });
}

async function dequeue() {
  const res = await fetch(`${BASE}/queues/jobs/messages/pop`);
  return res.ok ? res.json() : null;
}

CLI:

# Create the Valkey instance first
osc create valkey-io-valkey msgstore

# Then create RSMQ pointing at it
osc create smrchy-rest-rsmq myqueue -o RedisUrl="redis://{valkey-host}:{valkey-port}"

Limitations

  • Only host and port of RedisUrl are used; Redis passwords and database numbers are not applied.

Resources