centrifugal / centrifugo

Scalable real-time messaging server in a language-agnostic way. Self-hosted alternative to Pubnub, Pusher, Ably. Set up once and forever.
https://centrifugal.dev
Apache License 2.0
8.45k stars 598 forks source link

add pulsar as a broker #792

Open paulm17 opened 8 months ago

paulm17 commented 8 months ago

Proposed changes

This update adds pulsar as a broker.

Docker.yml: https://pastebin.com/raw/nr85SxdS Instructions: https://pastebin.com/raw/Swwk9LcR

Run 3 centrifugo instances:

West:

  "port": 8000,
  "broker": "pulsar",
  "pulsar_url": "pulsar://127.0.0.1:6650",
  "pulsar_tenant": "my-tenant",
  "pulsar_namespace": "my-namespace",

Cent:

  "port": 8001,
  "pulsar_url": "pulsar://127.0.0.1:6651",

East:

  "port": 8002,
  "pulsar_url": "pulsar://127.0.0.1:6652",

Run 3 instances of the app:

git clone https://github.com/paulm17/centrifugo_app centrifugo_west
git clone https://github.com/paulm17/centrifugo_app centrifugo_cent
git clone https://github.com/paulm17/centrifugo_app centrifugo_east

Update

Cent:

NEXT_PUBLIC_URL=http://localhost:3001
NEXT_PUBLIC_CENTRIFUGE_URL=http://localhost:8001
NEXT_PUBLIC_CENTRIFUGE_WEBSOCKET_URL='localhost:8001'

East:

NEXT_PUBLIC_URL=http://localhost:3002
NEXT_PUBLIC_CENTRIFUGE_URL=http://localhost:8002
NEXT_PUBLIC_CENTRIFUGE_WEBSOCKET_URL='localhost:8002'

Change APIKEY + APISECRET for all 3 apps.

Ensure all 3 apps have their Ids unique: West = A Cent = B East = C

/src/app/components/sendMessage.tsx

const serverId = "1234"
const userId = "A-1234"

To test:

Launch all 3 app instances, should run on each individual port. Click hitme button and should see all 3 instances with the same message. Test each instance and you should see the message coming from A, B or C.