lm-sistemi-software-distrib.../src/main/kotlin/drills/drill07/exercise4/Requestor.kt

22 lines
584 B
Kotlin
Raw Normal View History

2020-04-22 09:59:55 +00:00
package drills.drill07.exercise4
2020-04-24 16:58:13 +00:00
import util.jms.requestor.ActiveMQRequestor
import util.jms.requestor.Requestor
2020-04-22 09:59:55 +00:00
fun main() {
2020-04-24 16:58:13 +00:00
val requestor: Requestor =
ActiveMQRequestor("factorial", shared = true)
2020-04-22 09:59:55 +00:00
println("Enter the number of which you want to calculate the factorial:")
val n = readLine()?.toInt()
val sendMessage = requestor.createMessage()
2020-04-22 16:01:59 +00:00
.also { it.setIntProperty("value", n!!) }
2020-04-22 09:59:55 +00:00
val replyMessage = requestor.request(sendMessage)
println("The factorial of $n is ${replyMessage.getLongProperty("result")}")
requestor.close()
}