package cn.sagacloud.server.algorithm.services.activemq

import org.springframework.jms.annotation.JmsListener
import org.springframework.stereotype.Service

@Service
class JMSComsumer {

//    @JmsListener(destination = "model.manage")
//    fun receiveTopic(message : String){
//        println(message)
//    }

//    var conn : Connection? = null
//    var consumer : MessageConsumer? = null
//    private fun init(){
//        val connFactory = ActiveMQConnectionFactory("admin", "admin", "tcp://192.168.20.225:61616")
//        conn = connFactory.createConnection()
//        val session = conn!!.createSession(false, Session.AUTO_ACKNOWLEDGE)
//        val dest = session.createTopic("myprivate")
//        consumer = session.createConsumer(dest)
//
//    }
//
//    fun receiveMessage(){
//        init()
//        conn!!.start()
//        consumer!!.messageListener = this
//    }
//
//    override fun onMessage(message: Message?) {
//        try{
//            when (message) {
//                is TextMessage -> {
//                    print(message.text)
//                }
//            }
//        }catch (e : Exception){
//            print("error : ${e.message}")
//        }
//    }
}