tags:

views:

184

answers:

1

Hi All,

I have a nServicebus application,now my application reads messages from handler and remove the messages from bus automatically. But what I want is that after retriving messages from Handler it should not remove messages from bus.And after my message processing which is done by my code, I will remove the message from bus. It means I have to control the messages.

Thank in advance

Susanta Samanta

A: 

NServiceBus runs all handlers in a TransactionScope, that means that if your code throws an exception the message will be put back in the queue and retried later. So you shouldn't worry about catching any exceptions/managing how messages get removed from the queue, NSB takes care of that for you.

If you can provide some more info on what you're trying to do I might be able to help you some more?

Andreas
I have a indexing service which index some messages, my problem arrises when the service is stopped unexpectedly. Suppose at that time I had already 100 messages out of 500 processed but not indexed(because index writer did not close at that time). Next time when the machine restarts, those 100 messages get lost. So, how can I retain all those messages. And I want to destroy these 500 messages at once after indexing complete as a whole.
Susanta Samanta
To solve this kind of problem you should take a look at "sagas"* http://nservicebus.com/Sagas.aspx* http://sourceforge.net/apps/mediawiki/nservicebus/index.php?title=Sagas* The manufacturing and starbucks sample displays this featureIe you use a saga to keep track of all messages to write/that are written to the index. Hope this helps!/Andreas
Andreas