Open
Description
Hi!
I have a production ticket office which uses Vert.x for realtime and I connecto to MySQL but after a while, every query gets this exception: "com.github.mauricio.async.db.exceptions.DatabaseException: This channel is not active and can't take messages"
I have 4 Verticles and all look like this:
package com.redpass.ticket.verticles
import io.vertx.core.eventbus.EventBus
import io.vertx.ext.asyncsql.MySQLClient
import io.vertx.core.AbstractVerticle
import io.vertx.core.json.JsonObject
import io.vertx.core.json.JsonArray
import com.redpass.ticket.queries.EntertainmentQueries
import com.redpass.ticket.mappers.EntertainmentMapper
import io.vertx.core.json.JsonObject
class EntertainmentVerticle extends AbstractVerticle {
@Override
void start() {
JsonObject config = config()
Map mysqlConfig = config.getJsonObject("mysql").getMap()
def client = MySQLClient.createNonShared vertx, new JsonObject(mysqlConfig)
def mapper = new EntertainmentMapper()
def connection = null
client.getConnection { response ->
if (response.succeeded())
connection = response.result()
else
println "Cannot connect to MySQL"
}
EventBus eventBus = vertx.eventBus()
eventBus.consumer("redpass.comunicate.entertainment") { message ->
println "consuming redpass.comunicate.entertainment"
def bodyMessage = message.body().getMap()
def queryParams = new JsonArray().add(bodyMessage.eventId)
connection.queryWithParams(EntertainmentQueries.FIND_BY_EVENT, queryParams, { response ->
try {
if (response.succeeded()) {
def result = response.result()
def rows = result.getRows()
def entertainments = mapper.fromDatabase(rows)
eventBus.send("redpass.comunicate.entertainment.response.${ bodyMessage.uuid }", mapper.fromEntity(entertainments))
} else {
throw response.cause()
}
} catch(Exception e) {
eventBus.send("redpass.comunicate.entertainment.response.${ bodyMessage.uuid }", new JsonObject([ hasError: true, cause: e.toString() ]))
}
})
}
}
}
I thought it was the fact that I was using createShared
on every verticle but I doesn't work even If I change it to createNonShared
.
What's the problem with my code and how can i solve it?
Metadata
Metadata
Assignees
Labels
No labels