Exemplo n.º 1
0
 public void Commit(Message msg)
 {
     if (session.IsTransacted)
     {
         Commit();
     }
     else
     {
         msg.Acknowledge();
     }
 }
Exemplo n.º 2
0
        public override void OnMessage(TIBCO.EMS.Message msg)
        {
            /*
             * Herein will lie the call to AMT report , to pass on  the msg consumed from EMS Queue .
             * Also, any response returned from AMT report call can be sent back to requestor
             * as the reply-queue and correlation-id are avaible as part of JMS Header of msg .
             * Not to be confused with void return .Also bear in mind , as many max. concurrent
             * invocations of Onmessage will be allowed ,as specfied in NoOfSessions parameter passed to
             * constructor as shown above.In other words ,If NoOfSessions=5 , 5  threads will be
             * created to excute as many instances of OnMessage, at a time.
             */


            try {
                Messaging.EMS.CommonUtils.ProcessEMSMessage(msg);
            }

            catch (EMSException e)
            {
                Console.Write("\n\n(******** Exception :\n" + e.StackTrace);
                msg.Acknowledge();
            }
        }
 /// <summary>
 /// Perform a commit or message acknowledgement, as appropriate
 /// </summary>
 /// <param name="session">The session to commit.</param>
 /// <param name="message">The message to acknowledge.</param>
 /// <exception cref="EMSException">In case of commit failure</exception>
 protected virtual void CommitIfNecessary(ISession session, Message message)
 {
     // Commit session or acknowledge message
     if (session.Transacted)
     {
         // Commit necessary - but avoid commit call is Session transaction is externally coordinated.
         if (IsSessionLocallyTransacted(session))
         {
             EmsUtils.CommitIfNecessary(session);
         }
     }
     else if (IsClientAcknowledge(session))
     {
         message.Acknowledge();
     }
 }
Exemplo n.º 4
0
        public void Consumer()
        {
            int ackMode = Session.AUTO_ACKNOWLEDGE;

            TIBCO.EMS.Message msg = null;

            while (true)
            {
                try
                {
                    // receive the message
                    msg = msgConsumer.Receive();
                }
                catch (EMSException EMSex)
                {
                    LogTextBox.Invoke((MethodInvoker) delegate() { LogTextBox.Text = LogTextBox.Text + EMSex.Message; });
                    logger.Error(EMSex.Message);
                }
                if (msg == null)
                {
                    break;
                }

                if (ackMode == Session.CLIENT_ACKNOWLEDGE ||
                    ackMode == Session.EXPLICIT_CLIENT_ACKNOWLEDGE ||
                    ackMode == Session.EXPLICIT_CLIENT_DUPS_OK_ACKNOWLEDGE)
                {
                    msg.Acknowledge();
                }

                LogTextBox.Invoke((MethodInvoker) delegate() { LogTextBox.Text = LogTextBox.Text + "\nReceived message: " + msg; });
                logger.Info("Received message: " + msg);

                if (msg is TextMessage)
                {
                    TextMessage tm = (TextMessage)msg;
                    //ReceveMsgTextBox.Text = tm.Text;
                    ReceveMsgTextBox.Invoke((MethodInvoker) delegate() { ReceveMsgTextBox.Text = tm.Text; });
                    logger.Info(tm.Text);
                }
                if (msg is BytesMessage)
                {
                    BytesMessage bm = (BytesMessage)msg;
                    LogTextBox.Invoke((MethodInvoker) delegate() { LogTextBox.Text = LogTextBox.Text + "\n" + bm.ReadBoolean(); });
                    LogTextBox.Invoke((MethodInvoker) delegate() { LogTextBox.Text = LogTextBox.Text + "\n" + bm.ReadChar(); });
                    LogTextBox.Invoke((MethodInvoker) delegate() { LogTextBox.Text = LogTextBox.Text + "\n" + bm.ReadShort(); });
                    LogTextBox.Invoke((MethodInvoker) delegate() { LogTextBox.Text = LogTextBox.Text + "\n" + bm.ReadInt(); });
                    LogTextBox.Invoke((MethodInvoker) delegate() { LogTextBox.Text = LogTextBox.Text + "\n" + bm.ReadLong(); });
                    LogTextBox.Invoke((MethodInvoker) delegate() { LogTextBox.Text = LogTextBox.Text + "\n" + bm.ReadFloat(); });
                    LogTextBox.Invoke((MethodInvoker) delegate() { LogTextBox.Text = LogTextBox.Text + "\n" + bm.ReadDouble(); });
                }

                if (msg is MapMessage)
                {
                    MapMessage mm       = (MapMessage)msg;
                    var        mapNames = mm.GetMapNames();
                    LogTextBox.Invoke((MethodInvoker) delegate() { LogTextBox.Text = LogTextBox.Text + "\n" + mm.ToString(); });

                    /*   foreach (String name in mapNames)
                     * {
                     *     LogTextBox.Invoke((MethodInvoker)delegate() { LogTextBox.Text = LogTextBox.Text + "\n" + mm.GetBoolean(name); });
                     *     LogTextBox.Invoke((MethodInvoker)delegate() { LogTextBox.Text = LogTextBox.Text + "\n" + mm.GetByte(name); });
                     *     LogTextBox.Invoke((MethodInvoker)delegate() { LogTextBox.Text = LogTextBox.Text + "\n" + mm.GetBytes(name); });
                     *     LogTextBox.Invoke((MethodInvoker)delegate() { LogTextBox.Text = LogTextBox.Text + "\n" + mm.GetChar(name); });
                     *     LogTextBox.Invoke((MethodInvoker)delegate() { LogTextBox.Text = LogTextBox.Text + "\n" + mm.GetShort(name); });
                     *     LogTextBox.Invoke((MethodInvoker)delegate() { LogTextBox.Text = LogTextBox.Text + "\n" + mm.GetInt(name); });
                     *     LogTextBox.Invoke((MethodInvoker)delegate() { LogTextBox.Text = LogTextBox.Text + "\n" + mm.GetLong(name); });
                     *     LogTextBox.Invoke((MethodInvoker)delegate() { LogTextBox.Text = LogTextBox.Text + "\n" + mm.GetFloat(name); });
                     *     LogTextBox.Invoke((MethodInvoker)delegate() { LogTextBox.Text = LogTextBox.Text + "\n" + mm.GetDouble(name); });
                     *     LogTextBox.Invoke((MethodInvoker)delegate() { LogTextBox.Text = LogTextBox.Text + "\n" + mm.GetString(name); });
                     *     LogTextBox.Invoke((MethodInvoker)delegate() { LogTextBox.Text = LogTextBox.Text + "\n" + mm.GetObject(name); });
                     * }*/
                }
            }
        }