I need your help regarding the message acknowledgement in the queue when the message reaches at the queue. Any help would be highly appreciated.
the code for my queue class is;
struct ListNode
{
ListNode(gcroot<message^> msg);
gcroot<message^> msg;
ListNode* next;
};
ListNode::ListNode(gcroot<message^> msg): msg(msg), next(nullptr) {}
public class queue
{
public:
queue();
~queue();
bool Empty() const;
void Enqueue(message^);
void Dequeue();
void DisplayAll() const;
private:
// Disable copying to keep the example simple
gcroot<String^> bindingkey;
queue(queue const& obj);
ListNode* head;
ListNode* tail;
gcroot<String^> name; // Added this
};
queue::queue():head(nullptr), tail(nullptr) {}
queue::~queue()
{
while (head != nullptr)
{
Dequeue();
}
}
void queue::Enqueue(message^ key)
{
if (head == nullptr)
{
head = tail = new ListNode(key);
}
else
{
tail->next = new ListNode(key);
tail = tail->next;
}
}
void queue::Dequeue()
{
ListNode* temp = head->next;
delete head;
head = temp;
}
void queue::DisplayAll() const
{
for (ListNode* p = head; p; p = p->next)
{
Console::WriteLine("the element is {0}", p->msg->routingk);
}
}
Message.h;
public ref class message
{
public:
property System::String^ routingk;
message(String^ Id)
{
routingk = Id;
}
System::String^ message::getType()
{
return routingk;
}
};