first commit

This commit is contained in:
2026-01-19 17:01:44 +07:00
parent 740b241b71
commit 61f22936c7
4 changed files with 13 additions and 19 deletions

View File

@@ -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}" }
}

View File

@@ -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 ->

View File

@@ -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)

View File

@@ -1,8 +1,7 @@
package database
import Other.Config
class MySQLInjector(config: Config) {
class MySQLInjector {
fun Stop(){