client code for pulsar(https://github.com/apache/incubator-pulsar).
This code is using following gems.
gem install digest-crc
gem install ruby_protobuf
- Clone proto file(PulsarApi.proto) from Pulsar Project page.
git clone https://github.com/apache/incubator-pulsar.git
(The proto file path is at pulsar-common/src/main/proto/PulsarApi.proto)
- Compile the proto file using rprotoc
rprotoc PulsarApi.proto
- Move PulsarApi.pb.rb to your project directory.
require './ruby-pulsar-client/lib/PulsarClient'
client = Message::PulsarClient.new()
client.connect('localhost', 6650)
client.send('persistent://sample/standalone/ns1/my-topic', 'hello!')
client.close()
require './ruby-pulsar-client/lib/PulsarClient'
client = Message::PulsarClient.new()
client.connect('localhost', 6650)
client.subscribe('persistent://sample/standalone/ns1/my-topic', 'sub', 1)
while true do
m = client.get_message()
print(m.message)
print("\n")
client.ack(m.client_created_id, m.message_ledger_id, m.message_entry_id)
end