Receiving messages synchronously

To receive messages synchronously, your application explicitly polls the queue for messages. It may poll the queue periodically, or when a user initiates a particular action such as clicking a Refresh button.

 To receive messages synchronously (.NET)
  1. Declare message objects to hold the incoming messages.

    QAMessage msg;
    QATextMessage text_msg;
  2. Poll the message queue, collecting messages:

    for(;;) {
        msg = mgr.GetMessageNoWait("queue-name");
        if( msg == null ) {
          break;
        }
        addMessage( msg );
      }

    See GetMessageNoWait method.

 To receive messages synchronously (C++)
  1. Declare message objects to hold the incoming messages.

    QAMessage * msg;
    QATextMessage * text_msg;
  2. Poll the message queue, collecting messages:

    for( ;; ) {
        msg = mgr->getMessageNoWait( "queue-name" );
        if( msg == NULL ) {
          break;
        }
        addMessage(msg);
      }

    See getMessageNoWait method.

 To receive messages synchronously (Java)
  1. Declare message objects to hold the incoming messages.

    QAMessage msg;
    QATextMessage text_message;
  2. Poll the message queue, collecting messages:



    if(mgr.start()) {
      for ( ;; ) {
        msg = mgr.getMessageNoWait("queue-name");
        if ( msg == null ) {
          break;
        }
        addMessage(msg);
      }
      mgr.stop();
    }

    See getMessageNoWait method.

 To receive messages synchronously (SQL)
  1. Declare an object to hold the message ID.

    begin
        declare @msgid varchar(128);
    
  2. Poll the message queue, collecting messages.

        loop
            set @msgid = ml_qa_getmessagenowait( 'myaddress' );
            if @msgid is null then leave end if;
            message 'a message with content ' || ml_qa_gettextcontent( @msgid ) || ' has been received';
        end loop;
        commit;
    end

    See: