Skip to content

Instantly share code, notes, and snippets.

@wklm wklm/heya.fs
Created Jun 7, 2017

Embed
What would you like to do?
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
You can’t perform that action at this time.