Quick reference for common integration commands.
1
2
3
4
5
6
7
8
9
10
11
12
13
14
15
16
17
18
# Server health
nats server ping
nats server info
# Streams
nats stream ls
nats stream info SEA_EVENTS
nats stream add SEA_EVENTS --subjects "sea.event.>" --retention limits
# Consumers
nats consumer ls SEA_EVENTS
nats consumer info SEA_EVENTS sea__default
nats consumer add SEA_EVENTS my_consumer --pull --ack explicit
# Messages
nats pub sea.event.test.v1 '{"test": true}'
nats sub "sea.event.>"
nats consumer next SEA_EVENTS sea__default --count 10
1
2
3
4
5
6
7
8
9
10
11
# Connection
pg_isready -h localhost -p 5432
psql $DATABASE_URL
# Outbox
psql -c "SELECT COUNT(*) FROM outbox_events WHERE published_at IS NULL;"
psql -c "SELECT * FROM outbox_events ORDER BY occurred_at DESC LIMIT 5;"
# Inbox
psql -c "SELECT COUNT(*) FROM inbox_messages WHERE processed_at IS NULL;"
psql -c "SELECT * FROM inbox_messages WHERE last_error IS NOT NULL;"
1
2
3
4
5
6
7
8
9
10
11
# Start services
docker-compose up -d nats postgres
docker-compose ps
# Logs
docker logs sea-nats --tail 100
docker logs sea-mq-worker -f
# Shell access
docker exec -it sea-nats sh
docker exec -it sea-postgres psql -U postgres
1
2
3
4
5
6
7
8
9
10
11
12
13
14
# Basic request
curl http://localhost:8000/api/v1/cases
# With headers
curl -v -H "Authorization: Bearer $TOKEN" http://localhost:8000/api/v1/cases
# POST with JSON
curl -X POST http://localhost:8000/api/v1/cases \
-H "Content-Type: application/json" \
-H "X-Idempotency-Key: $(uuidgen)" \
-d '{"title": "New Case"}'
# Timing
curl -w "@curl-timing.txt" -o /dev/null -s http://localhost:8000/health
1
2
3
4
5
6
7
8
9
# Run worker
just run-mq-worker
# Database
just db-migrate
just db-seed
# Testing
just test-integration
1
2
3
4
5
6
7
# Required
DATABASE_URL=postgresql://user:pass@localhost:5432/sea_db
NATS_URL=nats://localhost:4222
# Optional
NATS_CREDS_FILE=/path/to/creds
LOG_LEVEL=debug
| Error | Solution |
|---|---|
connection refused :4222 |
Start NATS: docker-compose up nats |
stream not found |
Create stream: nats stream add ... |
duplicate key in inbox |
Already processed (idempotent) |
outbox backlog growing |
Check publish_error column |