How do you manage concurrent messages ? As far as I understand how instance subscription works you'll end up with two instances subscribed to the same message type, so both will handle it, and two sent messages will return back with the same reply that comes first. Other reply will be discarded as no one will no longer be blocked on the wait handle
2010/5/6 bjarte <[email protected]> > Hi, > I've made an extension class I'm using as a bridge between RSB and a > WCF service. Thought I'd share it. Feel free to use it or comment it. > > Typical usage: > var res = bus.SendAndWaitForReply<S3DownloadUrlResponse>(new > RequestS3DownloadUrl() > { > CorrelationId = Guid.NewGuid(), > Token = orderToken > }); > > > using System.Collections.Generic; > using System.Linq; > using System.Text; > using Rhino.ServiceBus.Sagas; > using Rhino.ServiceBus; > using System.Threading; > using Rhino.ServiceBus.Internal; > > namespace Rhino.ServiceBus > { > public static class ReplyExtension > { > class ESBResult<R> : OccasionalConsumerOf<R>, IDisposable > { > ManualResetEvent waithandle; > IServiceBus bus; > IDisposable subscription; > TimeSpan patience; > > public ESBResult(IServiceBus bus, ISagaMessage message, > TimeSpan patience) > { > this.bus = bus; > > this.patience = patience; > waithandle = new ManualResetEvent(false); > subscription = bus.AddInstanceSubscription(this); > bus.Send(message); > } > > public ESBResult(IServiceBus bus, ISagaMessage message) > : this(bus, message, TimeSpan.FromSeconds(5)) > { > } > > public R Reply > { > get > { > waithandle.WaitOne(patience); > return m_Reply; > } > } > > #region ConsumerOf<R> Members > > R m_Reply = default(R); > public void Consume(R message) > { > m_Reply = message; > waithandle.Set(); > } > > #endregion > > #region IDisposable Members > > public void Dispose() > { > var b = bus; > subscription.Dispose(); > } > > #endregion > } > > public static R SendAndWaitForReply<R>(this IServiceBus bus, > ISagaMessage message) > { > using (var result = new ESBResult<R>(bus, message)) > return result.Reply; > } > } > } > > -- > You received this message because you are subscribed to the Google Groups > "Rhino Tools Dev" group. > To post to this group, send email to [email protected]. > To unsubscribe from this group, send email to > [email protected]<rhino-tools-dev%[email protected]> > . > For more options, visit this group at > http://groups.google.com/group/rhino-tools-dev?hl=en. > > -- You received this message because you are subscribed to the Google Groups "Rhino Tools Dev" group. To post to this group, send email to [email protected]. To unsubscribe from this group, send email to [email protected]. For more options, visit this group at http://groups.google.com/group/rhino-tools-dev?hl=en.
