Beispiel #1
0
/*
FUNCTION : received()
DESC : function to process the new message listened to from the qpid broker queue
*/
void Listener::received(Message& message) {

  char* prevStateFileName = "tempLRM.dat";
  ofstream prevStateFile ;
  prevStateFile.open(prevStateFileName,ios::out);
  prevStateFile << message.getData();
  prevStateFile.close();
  rename(prevStateFileName,"LRM.dat");
  string msgTxt = message.getData();
  newMessage = message.getData();

  if (message.getData() == "") {
    std::cout << "Shutting down listener for " << message.getDestination() << std::endl;
    subscriptions.cancel(message.getDestination());
  }
  subscriptions.stop();
  subscriptions.cancel(message.getDestination());

}
Beispiel #2
0
bool Listener::initListen() {
  // Receive messages
  //Added to test for init on recovery ***********************
  subscriptions.subscribe(local_queue, string("condor_queue"),SubscriptionSettings(FlowControl::unlimited(), ACCEPT_MODE_NONE, ACQUIRE_MODE_NOT_ACQUIRED));   
  Message lMsg;
  // sleep so that the local queue can get the message from the main condor
  // queue
  sleep(2);
  int size = 10;
  size = local_queue.size();
  local_queue.get(lMsg,10000);
  newMessage = lMsg.getData();
  subscriptions.stop();
  subscriptions.cancel(lMsg.getDestination());
  cout << "\n initListen(): size of the queue is : " << size <<endl;
  if(size > 0){
    //message queue has unprocessed message
    return false;
  }
  else{
    // message queue is empty:read from the file and send to the main condor_queue
    return true;
  }
}