Create a Pulsar client with PulsarClient.builder().serviceUrl('pulsar://...').build().
Create a producer: client.newProducer().topic('persistent://tenant/namespace/topic').create(); send messages with producer.send(payload).
Create a consumer: client.newConsumer().topic('...').subscriptionName('my-sub').subscriptionType(SubscriptionType.Shared).subscribe(). Choose the subscription type: Exclusive (single active consumer), Shared (round-robin across consumers, no ordering), Failover (one active, others on standby with ordering), Key_Shared (messages with the same key always go to the same consumer).
Call consumer.receive() in a loop, process the message, then call consumer.acknowledge(msg) on success.
Close producer and consumer when done to release resources.
Known gotchas
Exclusive subscription rejects a second consumer attempting to subscribe; use Failover if you need standby consumers with ordering.
Shared subscription does not guarantee ordering across consumers; use Key_Shared for per-key ordering with parallelism.
Key_Shared requires message keys to be set on the producer; without keys, all messages hash to the same consumer.
Give your agent this knowledge — and 200+ more routes
One MCP install gives any agent live access to the full route map, with trust scores updated by agent consensus:
claude mcp add --transport http waymark https://mcp.waymark.network/mcp