Thank you for replying.
It pretty much needs to be done via EnlistVolatile because I'm
planning on publishing to the queue from within a WCF service that
gets a distributed transaction from its caller. The initial caller
then decides whether to commit the transaction or not.
I already wrote an email sender library that I'm using for this which
works similarly, keeping all messages in a queue until the transaction
is committed. Only at that point the emails are being actually sent
out.
So, in order to get the publish to happen on commit, I basically need
to make a wrapper around the Bus that keeps all the messages in memory
until the transaction completes.
Or - I could patch MT somewhere, and perhaps allow it as a
configuration option when setting up the Bus, something like:
Bus.Initialize(sbc =>
{
sbc.UseTransactionalPublishing()
});
Does that look worthwhile? If it does, I could submit it as a pull
request later on.
-Andrei
On Apr 12, 8:27 pm, Travis Smith <
tra...@legomaster.net> wrote:
> So implementing transactions around RabbitMQ shouldn't be difficult.
> Distributed Transactions will likely require more magic. You can do
> this unquestionably with MSMQ, though configuring all the pieces for
> DTC makes everyone cry. It's really a huge pain to debug.
>
> EnlistVolatile seems like a good choice here, otherwise you could
> handle something similar in your own code. Collect messages to be
> published and just publish at the last step of your transaction. That
> would require pretty much zero MT knowledge and could be done within
> your application.
>
> -Travis
>
>
>
>
>
>
>
> On Thu, Apr 12, 2012 at 12:53 PM, Henrik Feldt <
logi...@gmail.com> wrote:
> > Hello Andrei,
>
> > If the publish-on-commit is your only concern with regards to transactions,
> > then yes, all you have to do is to do:
>
> > Transaction.Current.EnlistVolatile( ... )
> >
http://msdn.microsoft.com/en-us/library/system.transactions.transacti...
>
> > You simply then do the publish on commit.
>
> > That said, what transactions are mostly used for is the fact that they are
> > 2PC, and in conjunction with queues, that you have once-and-only-once
> > semantics on writes in conjunction with consume from the queue.
>
> > RabbitMQ does support distributed transactions, but only through the
> > XA-based API. I have never used it, and there's no support currently in MT
> > for it; that said; it should be the same interfaces as what MSMQ transport
> > uses since the LTM (lightweight transaction manager in .net) only is usable
> > through the System.Transactions API. As such, you could pretty IN THEORY
> > much copy-n-paste the transactional behaviour from the MSMQ transport, add
> > the API enlistment calls to the durable resource that is the RMQ Broker and
> > off you go.
>