org.axonframework.messaging.MetaData
and
org.axonframework.commandhandling.GenericCommandMessage
both now define MetaData as Map<String, String>
What’s the rational behind this decision in Axon 5, won’t any serialisable type work? I want to store auth roles in metadata as List<String>
I am currently doing that in Axon 5 with this approach and wanted to be able to return Map<String, Any> from my claimsExtractor.currentMetaData() to avoid repeating the same deserialisation or String.split code within all my command handler methods.
I know it’s not exactly the end of the world just curious, will this be in the final GA release of Axon 5? Is this to facilitate some incoming metadata based routing feature or something
package uk.specit.security
import org.axonframework.commandhandling.GenericCommandMessage
import org.axonframework.commandhandling.gateway.CommandResult
import org.axonframework.messaging.MessageType
import org.axonframework.commandhandling.gateway.CommandGateway as OriginalCommandGateway
import org.springframework.stereotype.Component
@Component
class AuthenticatedCommandGateway(
private val originalCommandGateway: OriginalCommandGateway,
private val claimsExtractor: AuthClaimsExtractor
) {
/**
* Sends the given command, enriching it with authentication metadata derived from the
* current Spring Security context (Microsoft Entra OIDC). This avoids relying on
* deprecated/removed gateway interceptors in Axon 5 milestones by explicitly attaching
* minimal trusted claims as command metadata.
*/
fun send(command: Any): CommandResult = originalCommandGateway.send(
GenericCommandMessage(
MessageType(
command::class.qualifiedName.toString()
),
command,
claimsExtractor.currentMetaData()
),
null
)
}