Service deactivation

25 views
Skip to first unread message

barbos...@gmail.com

unread,
Jul 27, 2020, 7:04:38 AM7/27/20
to mobicents-public
Hello all,

Maybe it will sound weird, but is it possible to deactivate service right from Sbb code?
Our goal is to deactivate service based on the specific condition.

Best regards,
Sergey Yashchenkov

Vladimir Tzanev

unread,
Jul 27, 2020, 8:29:27 AM7/27/20
to mobicents-public
Hi,

Try access ServiceManagement via jmx (javax.slee.management:name=ServiceManagement) and call deactivate(ServiceID[] arg0)

BR,
Vladimir

barbos...@gmail.com

unread,
Jul 28, 2020, 9:20:16 AM7/28/20
to mobicents-public
Hello Vladimir,

Thanks for your suggestion!
I realize it this way (maybe someone will search same question):

    private fun getMBeanServer(): MBeanServer? {
        var mbeanServer: MBeanServer? = null
        var servFound = false
        val servers = MBeanServerFactory.findMBeanServer(null)
        if (servers != null && (servers.size > 0)) {
            for (server in servers) {
                val defaultDomain = server.defaultDomain
                if (defaultDomain != null && defaultDomain == "jboss") {
                    mbeanServer = server
                    servFound = true
                }
            }
            if (!servFound) {
                mbeanServer = ManagementFactory.getPlatformMBeanServer()
            }
        }
        return mbeanServer
    }
    private fun deactivateService(mbeanServer: MBeanServer, event: ServiceStartedEvent) {
logger.error("Deactivating service {}", event.service.name)
val serviceManagementObjectName = ObjectName(ServiceManagementMBean.OBJECT_NAME)
val proxy = JMX.newMBeanProxy(mbeanServer, serviceManagementObjectName, ServiceManagementMBean::class.java)
proxy.deactivate(event.service)
    }

Call both methods from onServiceStartedEvent function.

Best regards,
Sergey Yashchenkov
понедельник, 27 июля 2020 г. в 15:29:27 UTC+3, Vladimir Tzanev:
Reply all
Reply to author
Forward
0 new messages