Skip to content

Instantly share code, notes, and snippets.

@massakam
Created September 27, 2019 11:49
Show Gist options
  • Save massakam/ebd169caff3db802eee5001b0d06c980 to your computer and use it in GitHub Desktop.
Save massakam/ebd169caff3db802eee5001b0d06c980 to your computer and use it in GitHub Desktop.
#include <iostream>
#include <pulsar/Client.h>
using namespace std;
using namespace pulsar;
int main() {
for (int i = 0; i < 100; i++) {
Client client("pulsar://localhost:6650");
Producer producer;
Result result = client.createProducer("persistent://public/default/test", producer);
if (result != ResultOk) {
cerr << "Failed to create producer: " << result << endl;
return -1;
}
Message msg = MessageBuilder().setContent("my-message").build();
Result res = producer.send(msg);
if (res == ResultOk) {
cout << "Send: " << msg.getDataAsString() << endl;
} else {
cerr << "Failed to send message: " << res << endl;
}
producer.close();
client.close();
}
}
Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment