/*
(non-Javadoc)

@see javax.jms.JMSContext#createBrowser(javax.jms.Queue)
554552
@Override
    public QueueBrowser createBrowser(Queue queue) throws JMSRuntimeException, InvalidDestinationRuntimeException {
        if (TraceComponent.isAnyTracingEnabled() && tc.isEntryEnabled())
            SibTr.entry(this, tc, "createBrowser", queue);

        QueueBrowser queueBrowser = null;
        try {
            queueBrowser = jmsSession.createBrowser(queue);
        } catch (InvalidDestinationException ide) {
            throw (InvalidDestinationRuntimeException) JmsErrorUtils.getJMS2Exception(ide, InvalidDestinationRuntimeException.class);
        } catch (JMSException jmse) {
            throw (JMSRuntimeException) JmsErrorUtils.getJMS2Exception(jmse, JMSRuntimeException.class);
        } finally {
            if (TraceComponent.isAnyTracingEnabled() && tc.isEntryEnabled())
                SibTr.exit(this, tc, "createBrowser");
        }

        return queueBrowser;
    }
628431
@Override
	public synchronized QueueSession createQueueSession(boolean transacted, int acknowledgeMode) throws JMSException
    {
        checkNotClosed();
        LocalQueueSession session =  new LocalQueueSession(idProvider.createID(),this,engine,transacted,acknowledgeMode);
        registerSession(session);
        return session;
    }
520132
private TopicSubscriber createDurableSubscriber(Topic topic, String name, String messageSelector, boolean noLocal, boolean isSharedDurable, boolean isNonSharedDurable) throws JMSException {
        if (TraceComponent.isAnyTracingEnabled() && tc.isEntryEnabled())
            SibTr.entry(this, tc, "createDurableSubscriber", new Object[] { topic, name, messageSelector, noLocal, isSharedDurable, isNonSharedDurable });

        checkNotClosed();
        if (topic == null) {
            throw (InvalidDestinationException) JmsErrorUtils.newThrowable(InvalidDestinationException.class,
                                                                           "INVALID_VALUE_CWSIA0048",
                                                                           new Object[] { "Topic", "null" },
                                                                           tc
                            );
        }

        if ((name == null) || ("".equals(name))) {
            throw (InvalidDestinationException) JmsErrorUtils.newThrowable(InvalidDestinationException.class,
                                                                           "INVALID_VALUE_CWSIA0048",
                                                                           new Object[] { "name", name },
                                                                           tc
                            );
        }

        // Check that this is not a foreign implementation.
        // Note that in some situations this method call can return a _different_
        // destination than the one passed in as the parameter (e.g. Spring).
        JmsDestinationImpl nativeDest = JmsDestinationImpl.checkNativeInstance(topic);

        // Check that this destination is not blocked
        JmsDestinationImpl.checkBlockedStatus(nativeDest);

        //client ID check should be there for only for non-shared. For shared client ID should be optional
        String clientID = connection.getClientID();
        if (isNonSharedDurable) {
            if ((clientID == null) || ("".equals(clientID))) {
                throw (IllegalStateException) JmsErrorUtils.newThrowable(IllegalStateException.class,
                                                                         "INVALID_VALUE_CWSIA0048",
                                                                         new Object[] { "clientID", clientID },
                                                                         tc
                                );
            }
        }

        // Look up the subscription home that was set on the ConnectionFactory
        // at the point when the Connection was created.
        String durSubHome = (String) passThruProps.get(JmsraConstants.DURABLE_SUB_HOME);
        if (TraceComponent.isAnyTracingEnabled() && tc.isDebugEnabled())
            SibTr.debug(this, tc, "DurableSubHome : " + durSubHome);

        // We demand that if durable subscriptions are being used then the user
        // must have specified a durable subscription home on the ConnectionFactory
        // before they create the connection.
        if ((durSubHome == null) || ("".equals(durSubHome))) {
            if (TraceComponent.isAnyTracingEnabled() && tc.isDebugEnabled())
                SibTr.debug(this, tc, "User Error - No durableSubscriptionHome was specified.");
            throw (javax.jms.IllegalStateException) JmsErrorUtils.newThrowable(javax.jms.IllegalStateException.class,
                                                                               "DURABLE_SUB_HOME_NOT_SPECIFIED_CWSIA0056",
                                                                               null,
                                                                               tc
                            );
        }

        // Now determine whether or not we are running in a cloned environment.
        String sharedSubs = (String) passThruProps.get(JmsInternalConstants.SHARE_DSUBS);
        if (TraceComponent.isAnyTracingEnabled() && tc.isDebugEnabled())
            SibTr.debug(this, tc, "shareDurableSubs: " + sharedSubs);
        boolean supportsMultiple = false;
        if ((sharedSubs == null)
            || ("".equals(sharedSubs))
            || (ApiJmsConstants.SHARED_DSUBS_IN_CLUSTER.equals(sharedSubs))) {
            // The application asked us to work it out for ourselves (default)
            boolean isCloned = JmsConnectionImpl.isClonedServer();
            if (TraceComponent.isAnyTracingEnabled() && tc.isDebugEnabled())
                SibTr.debug(this, tc, "isClonedServer: " + isCloned);
            // Pass the cloned state in as the instruction to support
            // multiple consumers on this durable subscription.
            supportsMultiple = isCloned;
        }
        else if (ApiJmsConstants.SHARED_DSUBS_ALWAYS.equals(sharedSubs)) {
            // The application stated explicitly it wants to share.
            supportsMultiple = true;
        }
        else {
            // The safe behaviour is to not support multiple consumers.
            supportsMultiple = false;
        }

        //if the call is made from createSharedDurableConsumer, set supportsMultiple to true
        //otherwise leaving the property as it is
        if (isSharedDurable)
            supportsMultiple = true;

        //if the call is made from CreateSharedConsumer i.e non-shared durable then
        //set supportsMultiple to false, otherwise leaving the property as it is
        if (isNonSharedDurable)
            supportsMultiple = false;

        // Create the consumer properties object filling in as much information
        // as we have available at the moment.
        ConsumerProperties newProps = new ConsumerProperties(nativeDest,
                        null, // DestType                filled in later
                        messageSelector, // Selector
                        null, // Reliability             filled in later
                        false, // ReadAhead               filled in later
                        true, // RecovExpress            filled in later
                        noLocal, // NoLocal
                        name, // SubName
                        clientID, // ClientID
                        supportsMultiple,// SupportMultiple
                        durSubHome // DurableSubscriptionHome
        );

        TopicSubscriber durableSubscriber = new JmsDurableSubscriberImpl(coreConnection, this, newProps);
        // newly created consumer is synchronous
        syncConsumers.add(durableSubscriber);

        if (TraceComponent.isAnyTracingEnabled() && tc.isEntryEnabled())
            SibTr.exit(this, tc, "createDurableSubscriber", durableSubscriber);
        return durableSubscriber;
    }
544279
private MessageConsumer createConsumer(Destination destination, String name, String messageSelector, boolean noLocal,
                                           boolean isSharedNonDurable) throws JMSException {
        if (TraceComponent.isAnyTracingEnabled() && tc.isEntryEnabled())
            SibTr.entry(this, tc, "createConsumer", new Object[] { destination, messageSelector, noLocal, isSharedNonDurable });
        JmsMsgConsumer consumer = null;

        checkNotClosed();
        if (destination == null) {
            throw (InvalidDestinationException) JmsErrorUtils.newThrowable(InvalidDestinationException.class,
                                                                           "INVALID_VALUE_CWSIA0048",
                                                                           new Object[] { "Destination", "null" },
                                                                           tc
                            );
        }

        if (isSharedNonDurable) {
            if ((name == null) || ("".equals(name))) {
                throw (JMSException) JmsErrorUtils.newThrowable(JMSException.class,
                                                                "INVALID_VALUE_CWSIA0048",
                                                                new Object[] { "sharedSubscriptionName", name },
                                                                tc
                                );
            }
        }

        // Check that this is not a foreign implementation.
        // Note that in some situations this method call can return a _different_
        // destination than the one passed in as the parameter (e.g. Spring).
        JmsDestinationImpl nativeDest = JmsDestinationImpl.checkNativeInstance(destination);

        // Check that this destination is not blocked from creating consumers
        JmsDestinationImpl.checkBlockedStatus(nativeDest);

        // create the consumer properties object filling in as much information
        // as we have available at the moment.
        ConsumerProperties newProps = new ConsumerProperties(nativeDest,
                        null, // DestType                filled in later
                        messageSelector, // Selector
                        null, // Reliability             filled in later
                        false, // ReadAhead               filled in later
                        true, // RecovExpress            filled in later
                        noLocal, // NoLocal
                        name, // SubName  .. with JMS 2.0, the value is set for all cases
                        connection.getClientID(), // ClientID .. with JMS 2.0, the value is set for all cases
                        isSharedNonDurable, // SupportMultiple .. with JMS 2.0, the value is set for all cases         
                        null // DurableSubscriptionHome n/a for non-durable consumers
        );

        // Hold the state lock while the msg consumer constructor is called to prevent
        // it from reading invalid start/stopped state while start is in progress. This
        // will basically cause and createConsumer calls on this session to wait until
        // session.start is complete.
        synchronized (stateLock) {
            consumer = instantiateConsumer(newProps);
            // newly created consumers must be synchronous
            syncConsumers.add(consumer);

            // d353701 - output a warning message if there are 'lots' of producers active.
            int totalConsumers = syncConsumers.size() + asyncConsumers.size();
            if (totalConsumers % PROD_CONS_WARNING_THRESHOLD == 0) {
                // We wish to tell the user which line of their application created the session,
                // so we must obtain a line of stack trace from their application.
                String errorLocation = JmsErrorUtils.getFirstApplicationStackString();
                SibTr.warning(tc, "MANY_CONSUMERS_WARNING_CWSIA0059", new Object[] { "" + totalConsumers, errorLocation });
            }

        }

        if (TraceComponent.isAnyTracingEnabled() && tc.isEntryEnabled())
            SibTr.exit(this, tc, "createConsumer", consumer);
        return consumer;
    }
763123
public QueueConsumer createQueueTextMessageListener(final String topic, final ConsumerCallback<String> messageCallback)
    {
        Preconditions.checkState(connectionFactory != null, "connection factory was never injected!");
        return new QueueConsumer(connectionFactory, jmsConfig, topic, new TextMessageConsumerCallback(messageCallback));
    }
1260664
@Override
    public QueueConnectionFactory createQueueConnectionFactory(JmsJcaConnectionFactory jcaConnectionFactory) {
        if (TraceComponent.isAnyTracingEnabled() && tc.isEntryEnabled())
            SibTr.entry(this, tc, "createQueueConnectionFactory", jcaConnectionFactory);
        QueueConnectionFactory qcf = new JmsManagedQueueConnectionFactoryImpl(jcaConnectionFactory);
        if (TraceComponent.isAnyTracingEnabled() && tc.isEntryEnabled())
            SibTr.exit(this, tc, "createQueueConnectionFactory", qcf);
        return qcf;
    }
1281167
protected final void registerBrowser( AbstractQueueBrowser browser )
    {
    	if (browsersMap.put(browser.getId(),browser) != null)
    		throw new IllegalArgumentException("Browser "+browser.getId()+" already exists");
    }
191609
public static CompletableFuture<MessageReceiver> create(
            final MessagingFactory factory,
            final String name,
            final String recvPath,
            final int prefetchCount,
            final ReceiverSettingsProvider settingsProvider) {
        MessageReceiver msgReceiver = new MessageReceiver(
                factory,
                name,
                recvPath,
                prefetchCount,
                settingsProvider);
        return msgReceiver.createLink();
    }
921296
public <T> QueuePublisher<T> createQueuePublisher(final String name, final PublisherCallback<T> messageCallback)
    {
        Preconditions.checkState(connectionFactory != null, "connection factory was never injected!");
        return new QueuePublisher<T>(connectionFactory, amqpConfig, name, messageCallback);
    }
1096248
@Override
    public MessageConsumer createSharedConsumer(Topic topic, String sharedSubscriptionName) throws JMSException, InvalidDestinationException, InvalidSelectorException {
        if (TraceComponent.isAnyTracingEnabled() && tc.isEntryEnabled())
            SibTr.entry(this, tc, "createSharedConsumer", new Object[] { topic, sharedSubscriptionName });
        MessageConsumer messageConsumer = null;
        try {
            messageConsumer = createConsumer(
                                             topic,
                                             sharedSubscriptionName,
                                             null, //messageSelector
                                             false, //nLocal
                                             true //is JMS2.0 shared non durable subscriber
            );
        } finally {
            if (TraceComponent.isAnyTracingEnabled() && tc.isEntryEnabled())
                SibTr.exit(this, tc, "createSharedConsumer", messageConsumer);
        }
        return messageConsumer;
    }
445473
public Mailbox createMailbox(MailboxesQueue queue) {
        if (mailboxCreator != null) {
            return mailboxCreator.createMailbox(queue);
        } else {
            return new Mailbox(queue);
        }
    }
671425
protected JcrService createJcrService( Map<String, JcrRepository> jcrRepositories,
                                           CallContext context ) {
        return new JcrService(jcrRepositories);
    }
1057808
@Override
    public java.util.concurrent.Future<ChangeMessageVisibilityBatchResult> changeMessageVisibilityBatchAsync(String queueUrl,
            java.util.List<ChangeMessageVisibilityBatchRequestEntry> entries) {

        return changeMessageVisibilityBatchAsync(new ChangeMessageVisibilityBatchRequest().withQueueUrl(queueUrl).withEntries(entries));
    }
42121
public <P extends ProcessBuilder> QueueBuilder<P> newQueueBuilder(Class<P> process_builder_class)
    {
        return QueueFactory.newQueueBuilder(this, process_builder_class);
    }
320570
public QueueModel create() throws IOException {
        String url = "queues/" + name;
        IronReader reader = client.put(url, "{}");
        QueueContainer container = gson.fromJson(reader.reader, QueueContainer.class);
        reader.close();
        return container.getQueue();
    }
1355881
public QueueConsumer createQueueListener(final String name, final ConsumerCallback messageCallback)
    {
        Preconditions.checkState(connectionFactory != null, "connection factory was never injected!");
        return new QueueConsumer(connectionFactory, amqpConfig, name, messageCallback);
    }
197645
@Override
	public synchronized QueueSession createQueueSession(boolean transacted, int acknowledgeMode) throws JMSException
    {
        checkNotClosed();
        
        RemoteQueueSession session = new RemoteQueueSession(idProvider.createID(),
        		                                            this,
        		                                            transportHub.createEndpoint(),
        		                                            transacted,
        		                                            acknowledgeMode);
        registerSession(session);
        session.remoteInit();
        return session;
    }