Org.Openengsb.Loom.CSharp.Bridge.Implementation.Communication.Jms.JmsIncomingPort.Receive C# (CSharp) Method

Receive() public method

Waits for a message on the preconfigured queue. Blocks until a message in received or the connection is closed.
public Receive ( ) : string
return string
        public string Receive()
        {
            ITextMessage message = null;
            try
            {
                logger.Info("wait for new message");
                message = consumer.Receive() as ITextMessage;
                logger.Info("recieved new message. Processing...");
            }
            catch (Exception e)
            {
                logger.WarnFormat("Exception caught in receivethread. Maybe OpenEngSB terminated - {0} ({1}).", e.Message, e.GetType().Name);
                Handling.Changed += delegate(object[] obj)
                {
                    return Receive();
                };
                return Handling.HandleException(e).ToString();
            }

            if (message == null)
            {
                return null;
            }

            logger.DebugFormat("recieved message: {0}", message.Text);
            return message.Text;
        }

Usage Example

Ejemplo n.º 1
0
        public void TestACustomCreatedExceptionHandlerWhichReturnsAValueAsResultThatGetsInvokedWithIcomingPort()
        {
            string destination = TcpUrlOpenEngSB + tmpGuid.ToString();

            IIncomingPort inPort = new JmsIncomingPort(destination, new TestCustomExceptionHandler(), ConnectorId);
            inPort.Close();

            Assert.AreEqual<String>(inPort.Receive(), "TestCase");
        }