32 lines
765 B
Kotlin
32 lines
765 B
Kotlin
package drills.drill07.exercise1.point1
|
|
|
|
import org.apache.activemq.ActiveMQConnectionFactory
|
|
import javax.jms.QueueConnectionFactory
|
|
import javax.jms.Session
|
|
|
|
fun main() {
|
|
val url = "tcp://localhost:61616"
|
|
val factory: QueueConnectionFactory = ActiveMQConnectionFactory(url)
|
|
|
|
val connection = factory.createQueueConnection()
|
|
connection.start()
|
|
|
|
val session = connection.createQueueSession(
|
|
false,
|
|
Session.CLIENT_ACKNOWLEDGE
|
|
)
|
|
|
|
val queue = session.createQueue("ack")
|
|
val receiver = session.createReceiver(queue)
|
|
|
|
repeat(100) {
|
|
val msg = receiver.receive()
|
|
val value = msg.getIntProperty("value")
|
|
println(value)
|
|
msg.acknowledge()
|
|
}
|
|
|
|
session.close()
|
|
connection.close()
|
|
}
|