34 lines
799 B
C++
34 lines
799 B
C++
#include <Void/Messaging/Queue.hpp>
|
|
|
|
#include <cstdlib>
|
|
|
|
int main()
|
|
{
|
|
Void::Messaging::InMemoryQueue q{};
|
|
if (!q.create_queue(Void::Messaging::QueueConfig{.name = "q"}).has_value()) {
|
|
return EXIT_FAILURE;
|
|
}
|
|
if (!q.create_group("q", Void::Messaging::GroupConfig{.name = "g"})
|
|
.has_value()) {
|
|
return EXIT_FAILURE;
|
|
}
|
|
Void::Messaging::Message m{};
|
|
m.id = "m1";
|
|
m.payload = {std::byte{0x41}};
|
|
auto pub = q.publish("q", m, Void::Messaging::PublishDurability::Memory);
|
|
if (!pub.has_value()) {
|
|
return EXIT_FAILURE;
|
|
}
|
|
auto del = q.try_receive("q", "g");
|
|
if (!del.has_value() || !del->has_value()) {
|
|
return EXIT_FAILURE;
|
|
}
|
|
if (!q.ack((*del)->receipt).has_value()) {
|
|
return EXIT_FAILURE;
|
|
}
|
|
if (!q.close_and_join().has_value()) {
|
|
return EXIT_FAILURE;
|
|
}
|
|
return EXIT_SUCCESS;
|
|
}
|