Skip to content

Instantly share code, notes, and snippets.

@michael-newton-15below
Created January 14, 2013 21:20
Show Gist options
  • Save michael-newton-15below/4533619 to your computer and use it in GitHub Desktop.
Save michael-newton-15below/4533619 to your computer and use it in GitHub Desktop.
Error handler builder usage
open EasyNetQ
type IService =
abstract member Start : unit -> unit
type Service (log : ILog, bus : IBus, indexer : IIndex, audit : IErrorHandlerBuilder) =
member this.Start () =
bus.Subscribe<PasngrEmail>("Archive",
fun (email : PasngrEmail) ->
audit {
log.Debug <| sprintf "Email message %s from recipient %d received for archiving." email.MailUid email.Id
let! mail = Some email
return indexer.Add email } |> ignore)
bus.Respond<RetrieveEmailContentRequest, RetrieveEmailContentResponse>(fun request ->
let mimeData = audit {
log.Debug <| sprintf "Request for content of email %A received." request
let! req = Some request
return indexer.Retrieve(req)
}
match mimeData with
| Some content -> { Content = content }
| None -> { Content = "No email found" })
interface IService with
member x.Start () = x.Start ()
Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment