Created
September 27, 2019 11:49
-
-
Save massakam/ebd169caff3db802eee5001b0d06c980 to your computer and use it in GitHub Desktop.
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
#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