11.08., 9:00 - 11:00: Due to updates GitLab will be unavailable for some minutes between 09:00 and 11:00.

Commit 815f5dd7 authored by Alessio Netti's avatar Alessio Netti

dcdbslurmjob: waiting for the MQTT message to be actually published

parent 5ead00a6
......@@ -35,6 +35,18 @@
#include <iostream>
#include <mosquitto.h>
#define SLURMJOBTIMEOUT 60000000000
int msgId = -1;
bool done = false;
void publishCallback(struct mosquitto *mosq, void *obj, int mid) {
if(msgId != -1 && mid == msgId)
done = true;
}
/*
* Print usage information
*/
......@@ -300,18 +312,22 @@ int main(int argc, char** argv) {
//std::cout << "Payload:\n" << payload << std::endl;
mosquitto_publish_callback_set(_mosq, publishCallback);
uint64_t startTs = getTimestamp();
//send it to broker
if (mosquitto_publish(_mosq, NULL, topic.c_str(), payload.length(), payload.c_str(), 1, false) != MOSQ_ERR_SUCCESS) {
if (mosquitto_publish(_mosq, &msgId, topic.c_str(), payload.length(), payload.c_str(), 1, false) != MOSQ_ERR_SUCCESS) {
std::cerr << "Broker not reachable! Job data was not published." << std::endl;
retCode = 1;
goto exit;
}
do {
if (mosquitto_loop(_mosq, -1, 1) != MOSQ_ERR_SUCCESS) {
std::cerr << "Error in mosquitto_loop!" << std::endl;
retCode = 1;
goto exit;
}
} while(!done && getTimestamp() - startTs < SLURMJOBTIMEOUT);
}
//hasta la vista
......
Markdown is supported
0%
or
You are about to add 0 people to the discussion. Proceed with caution.
Finish editing this message first!
Please register or to comment