Ejemplo n.º 1
0
BOOL Util::InsertSVMQ(CString strQueueName, CString strMessage, CString strLabel)
{
      MutexLock lock(g_InsertMQLock);
      if(strLabel.isEmpty())
         strLabel="SVMQ";

      void *pqueue=NULL;
      int err=0;
      CString strError="";
      if((err=OpenQueue(g_SVMQAddress.getText(), (char *)strQueueName, &pqueue))>0)
      {
           if((err=Push(pqueue, strLabel, strMessage))>0)
	   {
	       CloseQueue(pqueue);
	       return TRUE;
	   }else
	   {
	      CloseQueue(pqueue);
	      strError.Format("Send Message error errorid:%d",err);
	      throw MSException((char *)strError);
	      
	   }
	   
          
      }else
      {
          puts("Open queue failed");
          strError.Format("Open queue failed errorid:%d",err);
	  throw MSException(strError.getText());
      }
      
      return TRUE;

}
Ejemplo n.º 2
0
int Client(int argc, char** argv)
{
    long type = CLIENT_TO_SERVER;
    char request[BUFF];

    Mesg snd;

    if(OpenQueue() < 0){
        return 1;
    }

    done = 1;

    if(CreateReadThread() < 0)
        return -1;

    while (running)
    {
        if(done) {

            rc = ReadArguments(request, argc, argv);
            if(rc < 0)
            {

                return 0;
            } 
            else if(rc == 1)
            {

                continue;
            }

            done = 0;

            strncpy(snd.mesg_data, request, BUFF);

            snd.mesg_type = type;
            if(SendMessage(msgQueue, &snd) < 0)
            {
              return -1;
            }

        }
        
    }

    return 0;
}