1
votes

I have a WCF service that is connected to a service bus Queue ready to receive messages. This is working great but i would like to be able to mark the message as a DeadLetter if i have an issue processing the message. Currently if my code throws an exception the message still gets removed from the queue, but i want to be able in configuration to specify to not deleted from the queue but mark it as a DeadLetter. I've done some search and I can't figure out on how to do that. I am currently running the service as a windows service

Uri baseAddress = ServiceBusEnvironment.CreateServiceUri("sb", "namespace", "servicequeue"); _serviceHost = new ServiceHost(typeof(PaperlessImportServiceOneWay), baseAddress); _serviceHost.Open();

config:

<services>
      <service name="Enrollment.ServiceOneWay">
        <endpoint name="ServiceOneWay"
                  address="sb://namespace.servicebus.windows.net/servicequeue"
                  binding="netMessagingBinding"
                  bindingConfiguration="messagingBinding"
                  contract="IServiceOneWaySoap"
                  behaviorConfiguration="sbTokenProvider" />
      </service>
</services>
      <netMessagingBinding>
        <binding name="messagingBinding" closeTimeout="00:03:00" openTimeout="00:03:00"
               receiveTimeout="00:03:00" sendTimeout="00:03:00" sessionIdleTimeout="00:01:00"
               prefetchCount="-1">
          <transportSettings batchFlushInterval="00:00:01" />
        </binding>
      </netMessagingBinding>

<behavior name="sbTokenProvider">
          <transportClientEndpointBehavior>
            <tokenProvider>
              <sharedSecret issuerName="owner" issuerSecret="XXXXXXXXXXXXXXXXXXXXXXXX" />
            </tokenProvider>
          </transportClientEndpointBehavior>
        </behavior>
1

1 Answers

1
votes

In your interface for the opertion Contract add this [ReceiveContextEnabled(ManualControl = true)] then you can manage to commit or abandon the message Found it in this link: http://msdn.microsoft.com/en-us/library/windowsazure/hh532034.aspx