コード例 #1
0
        override public IAsyncResult BeginSubmitMessages(
            IBaseMessage[]                                  messages,
            AsyncCallback cb,
            Object asyncState)
        {
            if (false == _initialized)
            {
                InternalInitialize(null, messages[0], null);
            }

            EpmAsyncResult ar = new EpmAsyncResult(cb, asyncState);
            // Get a new Transport Proxy Batch
            IBTTransportBatch batch = _tp.GetBatch(ar.BatchCallback, null);

            for (int c = 0; c < messages.Length; c++)
            {
                // Submit the message
                batch.SubmitMessage(messages[c]);
            }

            // Commit the batch
            batch.Done(null);

            return(ar);
        }
コード例 #2
0
        private void EndpointTask()
        {
            //Stream readonlystream = null;
            object provider      = null;
            object taskArguments = null;

            try
            {
                try
                {
                    Assembly streamProviderAssembly = Assembly.Load(this.properties.StreamProviderAssemblyName);
                    provider = streamProviderAssembly.CreateInstance(this.properties.StreamProviderTypeName);
                }
                catch (Exception provderException)
                {
                    transportProxy.SetErrorInfo(new ApplicationException("Error creating IScheduledTaskStreamProvider interface", provderException));
                }
                if (provider != null)
                {
                    //create GetStream argument object
                    object [] args   = new object [] {};
                    object    result = provider.GetType().InvokeMember("GetParameterType", BindingFlags.InvokeMethod, null, provider, args);
                    if (result != null)
                    {
                        StringReader  strReader  = new StringReader(this.properties.StreamProviderArguments);
                        XmlSerializer serializer = new XmlSerializer((System.Type)result);
                        taskArguments = serializer.Deserialize(strReader);
                    }
                    //call GetStream
                    args   = new object[] { taskArguments };
                    result = provider.GetType().InvokeMember("GetStream", BindingFlags.InvokeMethod, null, provider, args);

                    if (result != null)
                    {
                        Stream readonlystream = new ReadOnlySeekableStream((Stream)result);

                        IBaseMessageFactory messageFactory = this.transportProxy.GetMessageFactory();
                        IBTTransportBatch   batch          = transportProxy.GetBatch(this, null);

                        IBaseMessage message = this.CreateMessage(messageFactory, readonlystream, this.properties.Name);

                        batch.SubmitMessage(message);
                        batch.Done(null);
                        this.batchFinished.WaitOne();
                    }
                }
            }
            catch (Exception exception)
            {
                string errorMessage = exception.Message;
                //transportProxy.SetErrorInfo(exception);
                while (exception.InnerException != null)
                {
                    exception     = exception.InnerException;
                    errorMessage += "\r\n" + exception.Message;
                }
                transportProxy.ReceiverShuttingdown(this.uri, new ScheduledException(errorMessage));
            }
        }