I am a F# and programming newbie and I need some guidance on an issue reading data into F# from a RabbitMQ message queue.
I have been able to write a F# script which subscribes to a message queue(s) and receives data in a similar format to the below.
Received onData;FeedQ1;7.488;7.48813;1427315602762;8.61;8.31
I now need to learn how to split the 'string' message received from the message queue into Variables or an Array which can then be stored and/or used within my F# script. As you can see, the message above actually contains 7 fields which are separated by ; characters.
I have tried searching the web and RabbitMQs resources but everything I have found seems to just detail making the actual connection to RabbiTMQ from F# and it doesn't go any further in terms of information on processing message data received from the MQ queue....
Any help is very much appreciated, Thank you!
Actual F# fsx script shown below:
#r "RabbitMQ.Client.dll"
open System
open RabbitMQ.Client
open RabbitMQ.Client.Events
open System.Text
let factory = new ConnectionFactory(HostName = "localhost")
(
use connection = factory.CreateConnection()
use channel = connection.CreateModel()
use channel1 = connection.CreateModel()
channel.QueueDeclare("FeedQ1", false, false, false, null) |> ignore
channel1.QueueDeclare("FeedQ2", false, false, false, null) |> ignore
let consumer = new QueueingBasicConsumer(channel)
channel.BasicConsume("FeedQ1", true, consumer) |> ignore
channel.BasicConsume("FeedQ2", true, consumer) |> ignore
printfn " [*] Waiting for messages. To exit press CTRL+C"
let rec loop () : unit =
let ea = consumer.Queue.Dequeue();
let body = ea.Body
let message = Encoding.UTF8.GetString(body)
printfn " [x] Received %s" message
loop ()
loop ()
)