Ecosyste.ms: Awesome
An open API service indexing awesome lists of open source software.
https://github.com/hiroakiwater/ruby-pulsar-client
client code for pulsar.
https://github.com/hiroakiwater/ruby-pulsar-client
Last synced: about 2 months ago
JSON representation
client code for pulsar.
- Host: GitHub
- URL: https://github.com/hiroakiwater/ruby-pulsar-client
- Owner: hiroakiwater
- License: apache-2.0
- Created: 2017-07-01T22:52:08.000Z (over 7 years ago)
- Default Branch: master
- Last Pushed: 2017-09-11T11:30:12.000Z (over 7 years ago)
- Last Synced: 2024-08-04T04:01:06.383Z (5 months ago)
- Language: Ruby
- Size: 6.84 KB
- Stars: 5
- Watchers: 0
- Forks: 1
- Open Issues: 0
-
Metadata Files:
- Readme: README.md
- License: LICENSE
Awesome Lists containing this project
- awesome-pulsar - ruby-pulsar-client
README
# ruby-pulsar-client
client code for pulsar(https://github.com/apache/incubator-pulsar).# Usage
This code is using following gems.
```
gem install digest-crc
``````
gem install ruby_protobuf
```# Setup
## Compile Pulsar API protocol buffer
1. 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)2. Compile the proto file using rprotoc
```
rprotoc PulsarApi.proto
```3. Move PulsarApi.pb.rb to your project directory.
# Examples
## Producer
```
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()
```## Consumer
```
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
```