Example #1
0
        public void SendEnvelope(ImmutableEnvelope envelope)
        {
            var queue = GetOutboundQueue();

            if (Transaction.Current == null)
            {
                SystemObserver.Notify(
                    new EnvelopeSent(queue.Name, envelope.EnvelopeId, false,
                                     envelope.Items.Select(x => x.MappedType.Name).ToArray(), envelope.GetAllAttributes()));

                queue.PutMessage(envelope);
            }
            else
            {
                var action = new CommitActionEnlistment(() =>
                {
                    SystemObserver.Notify(
                        new EnvelopeSent(
                            queue.Name,
                            envelope.EnvelopeId,
                            true,
                            envelope.Items.Select(x => x.MappedType.Name).ToArray(), envelope.GetAllAttributes()
                            ));

                    queue.PutMessage(envelope);
                });

                Transaction.Current.EnlistVolatile(action, EnlistmentOptions.None);
            }
        }
Example #2
0
        public void PutMessage(ImmutableEnvelope envelope)
        {
            using (var stream = new MemoryStream())
            {
                var formatter = new BinaryFormatter();
                formatter.Serialize(stream, envelope);

                File.WriteAllBytes(GenerateFileName(), stream.ToArray());
            }
        }
Example #3
0
 public EnvelopeQuarantined(Exception lastException, string dispatcher, ImmutableEnvelope envelope)
 {
     LastException = lastException;
     Dispatcher = dispatcher;
     Envelope = envelope;
 }