30 lines
705 B
Kotlin
30 lines
705 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()
|
|
|
|
val session = connection.createQueueSession(
|
|
false,
|
|
Session.AUTO_ACKNOWLEDGE
|
|
)
|
|
|
|
val queue = session.createQueue("ack")
|
|
val sender = session.createSender(queue)
|
|
|
|
val msg = session.createMessage()
|
|
|
|
repeat(100) {
|
|
msg.setIntProperty("value", it)
|
|
sender.send(msg)
|
|
}
|
|
|
|
session.close()
|
|
connection.close()
|
|
}
|