Created
June 7, 2017 15:10
-
-
Save wklm/d9140430fa711a6db7592082f92ff1c8 to your computer and use it in GitHub Desktop.
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
open Suave | |
open Suave.Successful | |
open Suave.Filters | |
open Suave.Operators | |
open FSharp.Data | |
open System | |
open Apache.NMS.ActiveMQ | |
let factory = ConnectionFactory "tcp://wk:32779" | |
let connection = factory.CreateConnection ("user", "user") | |
connection.Start() | |
let session = connection.CreateSession() | |
let destination = session.GetTopic "queue/TEST" | |
let consumer = session.CreateConsumer destination | |
let rec listen() = async { | |
do! Async.Sleep(1) | |
let message = consumer.Receive() | |
return! listen() } | |
let run() = async { | |
try | |
do! listen () | |
printfn "slucham " | |
finally | |
printf "ok" } | |
type Investment = | |
{ PurchasePayment : float | |
Lifetime : float | |
TaxWriteoff : float | |
ResidualValue : float } | |
let CoffeMachine = | |
{ PurchasePayment = 13000.0 | |
Lifetime = 4.0 | |
TaxWriteoff = 2000.0 | |
ResidualValue = 500.0 } | |
let routes = | |
choose[ | |
GET >=> choose[ | |
path "/hey" | |
>=> OK ( [ 1.0..CoffeMachine.Lifetime ] | |
|> List.map ( fun x -> CoffeMachine.PurchasePayment ** 2.0 ) | |
|> List.map ( fun x -> x.ToString() ) | |
|> List.toArray | |
|> String.concat " " | |
); | |
]; | |
] | |
[<EntryPoint>] | |
let main argv = | |
startWebServer defaultConfig routes | |
run () |> Async.RunSynchronously | |
0 // return an integer exit code |
Sign up for free
to join this conversation on GitHub.
Already have an account?
Sign in to comment