Exemplo n.º 1
0
    void onMsg(TibrvListener* listener, TibrvMsg& msg)
    {
        const char* msgString = NULL;

        // Convert the incoming message to a string
        msg.convertToString(msgString);

        // Report we are processing the message
        printf("Processing message %s\n",msgString);
        fflush(stdout);

        // Imitate delay of one second
        waitQueue.timedDispatch((tibrv_f64)1.0);

        /* Increase count of processed messages. In real world
         * access to this variable should be guarded
         * because we may be changing it from multiple
         * dispatcher threads at the same time.
         */
        processedMessageCount++;

        /* If we have processed all messages then report it
         * and create a timer on the trigger queue so the
         * dispatch call on that queue returns.
         */
        if (processedMessageCount == TOTAL_MESSAGES)
        {
            /* we don't need to keep the timer here */
            TibrvTimer* timer = new TibrvTimer();
            timer->create(&triggerQueue,
                          new TimerCallback(),
                          (tibrv_f64)0, /* no delay */
                          NULL);
        }
    }
Exemplo n.º 2
0
    void onMsg(TibrvListener* listener, TibrvMsg& msg)
    {
        const char* sendSubject  = NULL;
        const char* msgString    = NULL;

        // Get the subject name to which this message was sent
        msg.getSendSubject(sendSubject);

        // Convert the incoming message to a string
        msg.convertToString(msgString);

        printf("Received message on subject %s: %s\n",
                   sendSubject, msgString);

        fflush(stdout);
    }