first commit
This commit is contained in:
@@ -1,5 +1,6 @@
|
||||
package ActiveMQ
|
||||
|
||||
import config
|
||||
import jakarta.jms.BytesMessage
|
||||
import jakarta.jms.Connection
|
||||
import jakarta.jms.MapMessage
|
||||
@@ -14,7 +15,7 @@ import org.tinylog.Logger
|
||||
import java.util.function.Consumer
|
||||
|
||||
@Suppress("unused")
|
||||
class ActiveMQClient(BrokerURL: String, username: String, password: String, queueName: String) {
|
||||
class ActiveMQClient {
|
||||
private lateinit var connection: Connection
|
||||
private lateinit var session: Session
|
||||
private lateinit var destination : Queue
|
||||
@@ -22,10 +23,10 @@ class ActiveMQClient(BrokerURL: String, username: String, password: String, queu
|
||||
var MessageConsumer : Consumer<Message>?= null
|
||||
init{
|
||||
try{
|
||||
connection = ActiveMQConnectionFactory(BrokerURL, username, password).createConnection()
|
||||
connection = ActiveMQConnectionFactory(config.ActiveMQ_BrokerURL, config.ActiveMQ_Username, config.ActiveMQ_Password).createConnection()
|
||||
connection.start()
|
||||
session = connection.createSession(false, Session.AUTO_ACKNOWLEDGE)
|
||||
destination = session.createQueue(queueName)
|
||||
destination = session.createQueue(config.ActiveMQ_QueueName)
|
||||
consumer = session.createConsumer(destination)
|
||||
consumer.messageListener = MessageListener { message ->
|
||||
MessageConsumer?.accept(message)
|
||||
@@ -53,7 +54,7 @@ class ActiveMQClient(BrokerURL: String, username: String, password: String, queu
|
||||
}
|
||||
|
||||
}
|
||||
Logger.info { "ActiveMQ Connection created to Broker : $BrokerURL" }
|
||||
Logger.info { "ActiveMQ Connection created to Broker : ${config.ActiveMQ_BrokerURL}" }
|
||||
} catch (e : Exception){
|
||||
Logger.error { "Failed to create connection, Message : ${e.message}" }
|
||||
}
|
||||
|
||||
16
src/Main.kt
16
src/Main.kt
@@ -4,19 +4,13 @@ import Web.WebUI
|
||||
import database.MySQLInjector
|
||||
import java.util.function.Consumer
|
||||
|
||||
//TIP To <b>Run</b> code, press <shortcut actionId="Run"/> or
|
||||
// click the <icon src="AllIcons.Actions.Execute"/> icon in the gutter.
|
||||
lateinit var config : Config
|
||||
fun main() {
|
||||
val config = Config()
|
||||
config = Config()
|
||||
config.Load()
|
||||
val webUI = WebUI(config)
|
||||
val activeclient = ActiveMQClient(
|
||||
config.ActiveMQ_BrokerURL,
|
||||
config.ActiveMQ_Username,
|
||||
config.ActiveMQ_Password,
|
||||
config.ActiveMQ_QueueName
|
||||
)
|
||||
val mysql = MySQLInjector(config)
|
||||
val webUI = WebUI()
|
||||
val activeclient = ActiveMQClient()
|
||||
val mysql = MySQLInjector()
|
||||
|
||||
activeclient.MessageConsumer = Consumer{ message ->
|
||||
|
||||
|
||||
@@ -1,13 +1,13 @@
|
||||
package Web
|
||||
|
||||
import Other.Config
|
||||
import config
|
||||
import io.javalin.Javalin
|
||||
|
||||
@Suppress("unused")
|
||||
/**
|
||||
* Start WebUI Server
|
||||
*/
|
||||
class WebUI(config: Config) {
|
||||
class WebUI{
|
||||
private var app : Javalin = Javalin.create { config ->
|
||||
config.staticFiles.add("/html")
|
||||
}.start(config.WebPort)
|
||||
|
||||
@@ -1,8 +1,7 @@
|
||||
package database
|
||||
|
||||
import Other.Config
|
||||
|
||||
class MySQLInjector(config: Config) {
|
||||
class MySQLInjector {
|
||||
|
||||
fun Stop(){
|
||||
|
||||
|
||||
Reference in New Issue
Block a user