Ejemplo n.º 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);
            }
        }
Ejemplo n.º 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());
            }
        }
Ejemplo n.º 3
0
 public EnvelopeQuarantined(Exception lastException, string dispatcher, ImmutableEnvelope envelope)
 {
     LastException = lastException;
     Dispatcher = dispatcher;
     Envelope = envelope;
 }