MassTransit/MassTransit — pull request #153 by eswann (2012-11-15 19:01:20+00:00)
Title: Added support for setting up publisher confirms for Rabbit MQ

Did the following to enable publisher confirms with external tracking:
1) Added publisher-confirm ack/nack support to RabbitMqProducer
2) Added PublisherConfirmSettings class to store the following:
- UsePublisherConfirms - Determines whether or not publisher confirms are used.
- RegisterMessageAction - Action called before a publish so that external app can register the message in the buffer of their choice. Provides the Rabbit publish/confirm sequence number.
- Acktion - Action called when a publisher confirm Ack is returned by the broker.
- Nacktion - Action called when a publisher confirm Nack is returned by the broker.
3) Updated RabbitMqTransportFactoryBuilder and Impl to allow setting of publisher confirm settings.
4) Added PublisherConfirmFactoryConfigurator and Impl to configure these settings
5) Updated RabbitMqTransportFactoryExtensions to add "UsePublisherConfirms" extension method.
6) Updated OutboundRabbitMqTransport send method to assign the Context.CorrelationId to the Rabbit IBasicProperties.CorrelationId so that it is accessible in the RabbitMqProducer.Publish method.

Configure as follows:
builder.Register(c => ServiceBusFactory.New(sbc =>
{
sbc.UseRabbitMq(conf => conf.UsePublisherConfirms(RegisterMessageAction, Acktion, Nacktion));

})).SingleInstance();
}

public void RegisterMessageAction(ulong sequenceNumber, string correlationId)
{
//TODO: store in buffer
}

public void Acktion(ulong sequenceNumber, bool isMultiple)
{
//TODO: Remove from buffer
}

public void Nacktion(ulong sequenceNumber, bool isMultiple)
{
//TODO: Store unacked messages to a more permanent place for reprocessing
}

Please let me know if there's a better way to accomplish this. Thanks,
Eric