Skip to content

Instantly share code, notes, and snippets.

@WilliamBerryiii
Created April 22, 2016 05:05
Show Gist options
  • Save WilliamBerryiii/132d7dc6c0571b5907ea0a9f6ad6949b to your computer and use it in GitHub Desktop.
Save WilliamBerryiii/132d7dc6c0571b5907ea0a9f6ad6949b to your computer and use it in GitHub Desktop.
Simple example of consuming an EasyNetQ Advanced Bus from F#
let messageHandlers () =
new Action<byte[], MessageProperties, MessageReceivedInfo>(fun message props receivedInfo ->
let envelope = message |> Encoding.UTF8.GetString |> Envelope.Parse
match Model.TryParse(envelope.Topic) with
| Some x ->
subject.OnNext ( pushToQueue x )
| None -> ()
)
let queue = bus.Advanced.QueueDeclare(rabbitConfig.Queue, passive = true)
async {
let q = queue
bus.Advanced.Consume(queue = q, onMessage = messageHandlers ()) |> ignore
}
Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment