현재 하나의 큐 "devQueue"로 메시지를 보낼 수 있습니다. 메시지가 "devQueue"에 도착하면 "localQueue"로 보내야합니다. 나는이 구현이 어렵다는 것을 알고있다. "local1"클래스에서 "local_send"라는 다른 클래스를 호출하여 "localQueue"(아래 코드에서와 같이)이지만 다른 행운과 연결할 수 있습니다. 유용한 양성자 함수가 있습니까? 아니면 v_message() 함수에서 "class1"클래스의 on_connection_open()에서 참조 변수를 사용할 수 있습니까? 이 방향에서 어떤 도움이나 아이디어라도 크게 감사 할 것입니다.Qpid Proton : 두 목적지에 메시지 보내기
현재 코드가 "local_send"클래스에 들어 가지 않아서 메시지가 "localQueue"로 전송되지 않습니다.
class class1 : public proton::messaging_handler {
std::string url;
std::string devQueue;
std::string localQueue;
std::vector<proton::message> msgVector;
local_send snd;
std::vector<proton::message> msgV;
public:
class1(const std::string& u, const std::string& devQueue, const std::string& localQueue) :
url(u), devQueue(devQueue), localQueue(localQueue), snd(msgVector, localQueue) {}
void on_container_start(proton::container& c) override {
c.connect(url);
}
void on_connection_open(proton::connection& c) override {
c.open_receiver(devQueue);
}
void on_message(proton::delivery &d, proton::message &msg) override {
msgV.push_back(msg);
// Here, the messages are checked if they have a valid format or not and v_message() is called
}
void v_message(const pack& msg){
this->msgVector.push_back(msg);
//I need to send the message to localQueue and hence we are running another class from here (but that is not working :()
local_send snd(msgVector, localQueue);
proton::container(snd).run();
}
void on_sendable(proton::sender &s) override {
for(auto msg: msgVector){
s.send(msg);
}
}
};
// Do I even need this class to send message to another destination?
class local_send : public proton::messaging_handler {
std::string localQueue;
std::vector<proton::message> msgVector;
public:
local_send(std::vector<proton::message> msgVector, const std::string& localQueue) :
msgVector(msgVector), localQueue(localQueue) {}
void on_connection_open(proton::connection& c) override {
c.open_receiver(localQueue);
}
void on_sendable(proton::sender &s) override {
for(auto msg: msgVector){
s.send(msg);
}
}
};
감사합니다 저스틴! 이것은 매우 도움이되었고 효과적이었습니다. 리팩토링하는 동안 메시지 구성에 대한 통찰력이 필요합니다. 이 게시물을 통해 확장하는 방법을 알아낼 수 없으므로 다른 게시물에 게시됩니다. – Mooni