Minor: code cleanup on ArtemisMessagingService.

- Use fixes in Kotlin 1.0 RC to clean up property access a bit (fewer set* calls)
- Note that we currently won't notice if Artemis throws an exception during startup, as it happens async. There is a fix to Artemis pending.
This commit is contained in:
Mike Hearn 2016-02-09 15:18:34 +01:00
parent d98a3871da
commit 2ccbd5db3e

View File

@ -111,11 +111,16 @@ class ArtemisMessagingService(val directory: Path, val myHostPort: HostAndPort)
secConfig.addUser("internal", password) secConfig.addUser("internal", password)
secConfig.addRole("internal", "internal") secConfig.addRole("internal", "internal")
secConfig.defaultUser = "internal" secConfig.defaultUser = "internal"
config.setSecurityRoles(mapOf( config.securityRoles = mapOf(
"#" to setOf(Role("internal", true, true, true, true, true, true, true)) "#" to setOf(Role("internal", true, true, true, true, true, true, true))
)) )
val secManager = ActiveMQJAASSecurityManager(InVMLoginModule::class.java.name, secConfig) val secManager = ActiveMQJAASSecurityManager(InVMLoginModule::class.java.name, secConfig)
mq.setSecurityManager(secManager) mq.setSecurityManager(secManager)
// Currently we cannot find out if something goes wrong during startup :( This is bug ARTEMIS-388 filed by me.
// The fix should be in the 1.3.0 release:
//
// https://issues.apache.org/jira/browse/ARTEMIS-388
mq.start() mq.start()
// Connect to our in-memory server. // Connect to our in-memory server.
@ -242,19 +247,19 @@ class ArtemisMessagingService(val directory: Path, val myHostPort: HostAndPort)
hostAndPort.hostText, hostAndPort.port)) hostAndPort.hostText, hostAndPort.port))
mq.activeMQServer.deployBridge(BridgeConfiguration().apply { mq.activeMQServer.deployBridge(BridgeConfiguration().apply {
setName(name) setName(name)
setQueueName(name) queueName = name
setForwardingAddress(name) forwardingAddress = name
setStaticConnectors(listOf(name)) staticConnectors = listOf(name)
setConfirmationWindowSize(100000) // a guess confirmationWindowSize = 100000 // a guess
}) })
} }
} }
private fun setConfigDirectories(config: Configuration, dir: Path) { private fun setConfigDirectories(config: Configuration, dir: Path) {
config.apply { config.apply {
setBindingsDirectory(dir.resolve("bindings").toString()) bindingsDirectory = dir.resolve("bindings").toString()
setJournalDirectory(dir.resolve("journal").toString()) journalDirectory = dir.resolve("journal").toString()
setLargeMessagesDirectory(dir.resolve("largemessages").toString()) largeMessagesDirectory = dir.resolve("largemessages").toString()
} }
} }
@ -262,11 +267,9 @@ class ArtemisMessagingService(val directory: Path, val myHostPort: HostAndPort)
val config = ConfigurationImpl() val config = ConfigurationImpl()
setConfigDirectories(config, directory) setConfigDirectories(config, directory)
// We will be talking to our server purely in memory. // We will be talking to our server purely in memory.
config.setAcceptorConfigurations( config.acceptorConfigurations = setOf(
setOf( tcpTransport(ConnectionDirection.INBOUND, "0.0.0.0", hp.port),
tcpTransport(ConnectionDirection.INBOUND, "0.0.0.0", hp.port), TransportConfiguration(InVMAcceptorFactory::class.java.name)
TransportConfiguration(InVMAcceptorFactory::class.java.name)
)
) )
return config return config
} }