C# code for the .NETInput node sample

.NETInput node

The content of the class file for the .NETInput node is supplied with the runtime IBM Integration Bus installation. If you have chosen the default installation path, this folder is located at: C:\Program Files\IBM\MQSI\9.0.0.0\sample\DotNet\DotNetInput\VS2010 or C:\Program Files\IBM\MQSI\9.0.0.0\sample\DotNet\DotNetInput\VS2012. The following method is read and delivered by the integration server:

        public override NBPollingResult ReadData(TimeSpan timeout)
        {           
            // If data is available, return it in a new NBPollingResult.
            // The built-in NBByteArrayPollingResult can be used or a new subclass can be created.
            // If no data is available return an NBTimeoutPollingResult.
            try
            {
                // Receive the message
                System.Messaging.Message msmqMsg = this.msgQ.Receive(timeout);

                // Process the message here.
                // When the correlation is empty, then will use input msg id.
                 string msgId = string.IsNullOrEmpty(msmqMsg.CorrelationId) ? msmqMsg.Id : msmqMsg.CorrelationId;
                byte[] msgBolb = System.Text.Encoding.Default.GetBytes(new StreamReader(msmqMsg.BodyStream).ReadToEnd());

                NBPollingResult pollingResult = new MsmqPollingResult(this, msgBolb, msgId);
                return pollingResult;
            }
            catch (MessageQueueException exception)
            {
                if (exception.MessageQueueErrorCode == MessageQueueErrorCode.IOTimeout)
                {
                    return new NBTimeoutPollingResult(this);
                }
                else
                {
                    throw;
                }
            }           
        }

Back to sample home