Skip to content

Instantly share code, notes, and snippets.

@forki
Created December 12, 2018 13:02
Show Gist options
  • Star 0 You must be signed in to star a gist
  • Fork 0 You must be signed in to fork a gist
  • Save forki/c24f8a9adf2181641f4ab7c39d0d2e79 to your computer and use it in GitHub Desktop.
Save forki/c24f8a9adf2181641f4ab7c39d0d2e79 to your computer and use it in GitHub Desktop.
let queue1 = // ..
let chunkSize = 100
[<FunctionName("Start")>]
let run([<QueueTrigger("start")>]content:string, log:ILogger) =
let t = task {
let msgs =
[1..5000]
|> Seq.map (fun i -> createMsg ...)
|> Seq.map Newtonsoft.Json.JsonConvert.SerializeObject
|> Seq.chunkBySize chunkSize
|> Seq.map (fun msgs -> CloudQueueMessage(Newtonsoft.Json.JsonConvert.SerializeObject (Seq.toArray msgs)))
for msg in msgs do
do! queue1.AddMessageAsync msg
}
t.Wait()
let queue2 = // ..
[<FunctionName("Expand")>]
let run([<QueueTrigger("expand")>]content:string, log:ILogger) =
let t = task {
let msgs = Newtonsoft.Json.JsonConvert.DeserializeObject<string []>(content)
for msg in msgs do
let message = CloudQueueMessage(Newtonsoft.Json.JsonConvert.SerializeObject msg)
do! queue2.AddMessageAsync message
}
t.Wait()
@tforkmann
Copy link

tforkmann commented Dec 12, 2018

´´´let chunkSize = 100

[<FunctionName("Start")>]
let run([<QueueTrigger(StartQueue)>]content:string, log:ILogger) =
let t = task {
let msgs =
[1..5000]
|> Seq.map (fun i -> {
MeterId = i |> string
VuPeriode = "2014001"} )
|> Seq.map Newtonsoft.Json.JsonConvert.SerializeObject
|> Seq.chunkBySize chunkSize
|> Seq.map (fun msgs -> CloudQueueMessage(Newtonsoft.Json.JsonConvert.SerializeObject (Seq.toArray msgs)))

    for msg in msgs do
        do! startQueue.AddMessageAsync msg
}
t.Wait()´´´

@tforkmann
Copy link

let chunkSize = 100

[<FunctionName("Start")>]
let run([<QueueTrigger(StartQueue)>]content:string, log:ILogger) =
let t = task {
let msgs =
[1..5000]
|> Seq.map (fun i -> {
MeterId = i |> string
VuPeriode = "2014001"} )
|> Seq.chunkBySize chunkSize
|> Seq.map Newtonsoft.Json.JsonConvert.SerializeObject
|> Seq.map (fun msgs -> CloudQueueMessage(Newtonsoft.Json.JsonConvert.SerializeObject (Seq.toArray msgs)))

    for msg in msgs do
        do! expandQueue.AddMessageAsync msg
}
t.Wait()

[<FunctionName("Expand")>]
let run([<QueueTrigger(ExpandQueue)>]content:string, log:ILogger) =
let t = task {
let msgs = Newtonsoft.Json.JsonConvert.DeserializeObject<string []>(content)
for msg in msgs do
let message = CloudQueueMessage(Newtonsoft.Json.JsonConvert.SerializeObject msg)
do! aggregationQueue.AddMessageAsync message
}
t.Wait()

Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment