messaging-activemq/src/main/java/org/wildfly/extension/messaging/activemq/deployment/JMSDestinationDefinitionInjectionSource.java
private void startQueue(final String queueName,
                            final ServiceTarget serviceTarget,
                            final ServiceName serverServiceName,
                            final ServiceBuilder<?> serviceBuilder,
                            final DeploymentUnit deploymentUnit,
                            final Injector<ManagedReferenceFactory> injector,
                            final boolean external) {

        final String selector = properties.containsKey(SELECTOR.getName()) ? properties.get(SELECTOR.getName()) : null;
        final boolean durable = properties.containsKey(DURABLE.getName()) ? Boolean.valueOf(properties.get(DURABLE.getName())) : DURABLE.getDefaultValue().asBoolean();
        final String managementAddress =  properties.containsKey(MANAGEMENT_ADDRESS.getName()) ? properties.get(MANAGEMENT_ADDRESS.getName()) : MANAGEMENT_ADDRESS.getDefaultValue().asString();
        final String user =  properties.containsKey("management-user") ? properties.get("management-user") : null;
        final String password =  properties.containsKey("management-password") ? properties.get("\"management-password") : null;

        ModelNode destination = new ModelNode();
        destination.get(NAME).set(queueName);
        destination.get(DURABLE.getName()).set(durable);
        if (selector != null) {
            destination.get(SELECTOR.getName()).set(selector);
        }
        destination.get(ENTRIES).add(jndiName);
        Service<Queue> queueService;
        if(external) {
            ServiceName pcfName= JMSServices.getPooledConnectionFactoryBaseServiceName(serverServiceName).append(resourceAdapter);
            final ServiceName jmsQueueServiceName = JMSServices.getJmsQueueBaseServiceName(serverServiceName).append(queueName);
            queueService = ExternalJMSQueueService.installRuntimeQueueService(
                    DestinationConfiguration.Builder.getInstance()
                            .setResourceAdapter(resourceAdapter)
                            .setName(queueName)
                            .setManagementQueueAddress(managementAddress)
                            .setDestinationServiceName(jmsQueueServiceName)
                            .setDurable(durable)
                            .setSelector(selector)
                            .setManagementUsername(user)
                            .setManagementPassword(password)
                            .build(),
                    serviceTarget,
                    pcfName);
        } else {
           queueService = JMSQueueService.installService(queueName, serviceTarget, serverServiceName, selector, durable);
        }


        inject(serviceBuilder, injector, queueService);

        //create the management registration
        String serverName = null;
        final DeploymentResourceSupport deploymentResourceSupport = deploymentUnit.getAttachment(Attachments.DEPLOYMENT_RESOURCE_SUPPORT);
        PathAddress registration;
        if (external) {
            final PathElement dest = PathElement.pathElement(EXTERNAL_JMS_QUEUE, queueName);
            deploymentResourceSupport.getDeploymentSubsystemModel(MessagingExtension.SUBSYSTEM_NAME);
            registration = PathAddress.pathAddress(dest);
        } else {
            serverName = getActiveMQServerName(properties);
            final PathElement dest = PathElement.pathElement(JMS_QUEUE, queueName);
            final PathElement serverElement = PathElement.pathElement(SERVER, serverName);
            deploymentResourceSupport.getDeploymentSubModel(MessagingExtension.SUBSYSTEM_NAME, serverElement);
            registration = PathAddress.pathAddress(serverElement, dest);
        }
        MessagingXmlInstallDeploymentUnitProcessor.createDeploymentSubModel(registration, deploymentUnit);
        JMSQueueConfigurationRuntimeHandler.INSTANCE.registerResource(serverName, queueName, destination);
    }
private void startQueue(final String queueName,
                            final ServiceTarget serviceTarget,
                            final ServiceName serverServiceName,
                            final ServiceBuilder<?> serviceBuilder,
                            final DeploymentUnit deploymentUnit,
                            final Injector<ManagedReferenceFactory> injector,
                            final boolean external) {

        final String selector = properties.containsKey(SELECTOR.getName()) ? properties.get(SELECTOR.getName()) : null;
        final boolean durable = properties.containsKey(DURABLE.getName()) ? Boolean.valueOf(properties.get(DURABLE.getName())) : DURABLE.getDefaultValue().asBoolean();
        final String managementAddress =  properties.containsKey(MANAGEMENT_ADDRESS.getName()) ? properties.get(MANAGEMENT_ADDRESS.getName()) : MANAGEMENT_ADDRESS.getDefaultValue().asString();
        final String user =  properties.containsKey("management-user") ? properties.get("management-user") : null;
        final String password =  properties.containsKey("management-password") ? properties.get("\"management-password") : null;

        ModelNode destination = new ModelNode();
        destination.get(NAME).set(queueName);
        destination.get(DURABLE.getName()).set(durable);
        if (selector != null) {
            destination.get(SELECTOR.getName()).set(selector);
        }
        destination.get(ENTRIES).add(jndiName);
        Service<Queue> queueService;
        if(external) {
            ServiceName pcfName= JMSServices.getPooledConnectionFactoryBaseServiceName(serverServiceName).append(resourceAdapter);
            final ServiceName jmsQueueServiceName = JMSServices.getJmsQueueBaseServiceName(serverServiceName).append(queueName);
            queueService = ExternalJMSQueueService.installRuntimeQueueService(
                    DestinationConfiguration.Builder.getInstance()
                            .setResourceAdapter(resourceAdapter)
                            .setName(queueName)
                            .setManagementQueueAddress(managementAddress)
                            .setDestinationServiceName(jmsQueueServiceName)
                            .setDurable(durable)
                            .setSelector(selector)
                            .setManagementUsername(user)
                            .setManagementPassword(password)
                            .build(),
                    serviceTarget,
                    pcfName);
        } else {
           queueService = JMSQueueService.installService(queueName, serviceTarget, serverServiceName, selector, durable);
        }


        inject(serviceBuilder, injector, queueService);

        //create the management registration
        String serverName = null;
        final DeploymentResourceSupport deploymentResourceSupport = deploymentUnit.getAttachment(Attachments.DEPLOYMENT_RESOURCE_SUPPORT);
        PathAddress registration;
        if (external) {
            final PathElement dest = PathElement.pathElement(EXTERNAL_JMS_QUEUE, queueName);
            deploymentResourceSupport.getDeploymentSubsystemModel(MessagingExtension.SUBSYSTEM_NAME);
            registration = PathAddress.pathAddress(dest);
        } else {
            serverName = getActiveMQServerName(properties);
            final PathElement dest = PathElement.pathElement(JMS_QUEUE, queueName);
            final PathElement serverElement = PathElement.pathElement(SERVER, serverName);
            deploymentResourceSupport.getDeploymentSubModel(MessagingExtension.SUBSYSTEM_NAME, serverElement);
            registration = PathAddress.pathAddress(serverElement, dest);
        }
        MessagingXmlInstallDeploymentUnitProcessor.createDeploymentSubModel(registration, deploymentUnit);
        JMSQueueConfigurationRuntimeHandler.INSTANCE.registerResource(serverName, queueName, destination);
    }
To workaround ActiveMQ's BindingRegistry limitation in {@link WildFlyBindingRegistry}
that does not allow to build a BindingInfo with the ResolutionContext info, the JMS queue is created *without* any
JNDI bindings and handle the JNDI bindings directly by getting the service's JMS queue.