Create queue session.
@param connection
@return
@throws JMSException
195334
protected Session createSession(Connection connection) throws JMSException {
        if (connection instanceof QueueConnection) {
            return ((QueueConnection) connection).createQueueSession(false, Session.AUTO_ACKNOWLEDGE);
        }
        return connection.createSession(false, Session.AUTO_ACKNOWLEDGE);
    }
684827
@Override
    public TemporaryQueue createTemporaryQueue() throws JMSRuntimeException {

        if (TraceComponent.isAnyTracingEnabled() && tc.isEntryEnabled())
            SibTr.entry(this, tc, "createTemporaryQueue");

        TemporaryQueue tempQueue = null;
        try {
            tempQueue = jmsSession.createTemporaryQueue();
        } catch (JMSException jmse) {
            throw (JMSRuntimeException) JmsErrorUtils.getJMS2Exception(jmse, JMSRuntimeException.class);
        } finally {
            if (TraceComponent.isAnyTracingEnabled() && tc.isEntryEnabled())
                SibTr.exit(this, tc, "createTemporaryQueue", new Object[] { tempQueue });
        }

        return tempQueue;
    }
22489
@Override
    public Session createSession() throws JMSException {

        if (TraceComponent.isAnyTracingEnabled() && tc.isEntryEnabled())
            SibTr.entry(this, tc, "createSession");

        Session session = null;
        try {
            session = createSession(false, Session.AUTO_ACKNOWLEDGE);
        } finally {
            if (TraceComponent.isAnyTracingEnabled() && tc.isEntryEnabled())
                SibTr.exit(this, tc, "createSession");
        }

        return session;
    }
730094
protected void remoteInit() throws JMSException
    {
        CreateBrowserQuery query = new CreateBrowserQuery();
        query.setBrowserId(id);
        query.setSessionId(session.getId());
        query.setQueue(queue);
        query.setMessageSelector(messageSelector);
        transportEndpoint.blockingRequest(query);
    }
1225655
@Override
    public ConnectionConsumer createConnectionConsumer(Queue queue, String messageSelector, ServerSessionPool sessionPool, int maxMessages)
            throws JMSException {
        throw new JMSException(SQSMessagingClientConstants.UNSUPPORTED_METHOD);
    }
1298050
@Override
    public Queue createQueue(String queueName) throws JMSRuntimeException {

        if (TraceComponent.isAnyTracingEnabled() && tc.isEntryEnabled())
            SibTr.entry(this, tc, "createQueue", new Object[] { queueName });

        Queue queue = null;
        try {
            queue = jmsSession.createQueue(queueName);
        } catch (JMSException jmse) {
            throw (JMSRuntimeException) JmsErrorUtils.getJMS2Exception(jmse, JMSRuntimeException.class);
        } finally {
            if (TraceComponent.isAnyTracingEnabled() && tc.isEntryEnabled())
                SibTr.exit(this, tc, "createQueue", new Object[] { queue });
        }

        return queue;
    }
775673
protected void createConnection() throws JMSException {
        if (connection == null) {
            if (!endpointConfiguration.isPubSubDomain() && endpointConfiguration.getConnectionFactory() instanceof QueueConnectionFactory) {
                connection = ((QueueConnectionFactory) endpointConfiguration.getConnectionFactory()).createQueueConnection();
            } else if (endpointConfiguration.isPubSubDomain() && endpointConfiguration.getConnectionFactory() instanceof TopicConnectionFactory) {
                connection = ((TopicConnectionFactory) endpointConfiguration.getConnectionFactory()).createTopicConnection();
                connection.setClientID(getName());
            } else {
                log.warn("Not able to create a connection with connection factory '" + endpointConfiguration.getConnectionFactory() + "'" +
                        " when using setting 'publish-subscribe-domain' (=" + endpointConfiguration.isPubSubDomain() + ")");

                connection = endpointConfiguration.getConnectionFactory().createConnection();
            }

            connection.start();
        }
    }
369520
@Override
	public ConnectionConsumer createDurableConnectionConsumer(Topic topic, String subscriptionName, String messageSelector, ServerSessionPool sessionPool, int maxMessages) throws JMSException
    {
    	throw new IllegalStateException("Method not available on this domain.");
    }
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;
    }
425536
@Override
	public QueueSender createSender(Queue queue) throws JMSException
    {
    	externalAccessLock.readLock().lock();
    	try
		{
	        checkNotClosed();
	        LocalQueueSender sender = new LocalQueueSender(this,queue,idProvider.createID());
	        registerProducer(sender);
	        return sender;
		}
    	finally
    	{
    		externalAccessLock.readLock().unlock();
    	}
    }
628597
@Override
	public final Session createSession(boolean transacted, int acknowledgeMode) throws JMSException
    {
    	return createSession(idProvider.createID(), transacted, acknowledgeMode);
    }
106318
@Override
    public Session createSession(boolean transacted, int acknowledgeMode) throws JMSException {
        if (TraceComponent.isAnyTracingEnabled() && tc.isEntryEnabled())
            SibTr.entry(this, tc, "createSession", new Object[] { transacted, acknowledgeMode });

        JmsSessionImpl jmsSession = null;

        // throw an exception if the connection is closed.
        checkClosed();

        // mark that the client id cannot be changed.
        fixClientID();

        // enforce consistency on transacted flag and acknowledge mode.
        if (transacted) {
            acknowledgeMode = Session.SESSION_TRANSACTED;
        }
        if (!transacted && isManaged) {
            if (acknowledgeMode == Session.CLIENT_ACKNOWLEDGE) {
                throw (JMSException) JmsErrorUtils.newThrowable(JMSException.class,
                                                                "INVALID_ACKNOWLEDGE_MODE_CWSIA0514",
                                                                new Object[] { acknowledgeMode },
                                                                tc
                                );
            }
            // if the ackmode is dups_ok then set it to dups_ok, for all the other combination 
            // set it to auto_ack
            if (acknowledgeMode == Session.DUPS_OK_ACKNOWLEDGE)
                acknowledgeMode = Session.DUPS_OK_ACKNOWLEDGE;
            else
                acknowledgeMode = Session.AUTO_ACKNOWLEDGE;
        }

        // create the jca session.
        boolean internallyTransacted = (transacted
                                        || acknowledgeMode == Session.CLIENT_ACKNOWLEDGE
                                        || acknowledgeMode == Session.DUPS_OK_ACKNOWLEDGE);
        JmsJcaSession jcaSession = createJcaSession(internallyTransacted);

        // Lock here so that another thread using the same connection doesn't reset the 
        // coreConnection to something else as as we are instantiating the Session 
        synchronized (this)
        {
            try
            {
                // We potentially have a new coreConnection becuase the creation of the JcaSession
                // detected that the coreConnection is now invalid and so a new managedConnection
                // and coreConnection was created. So reset the coreConnection for this JmsConnection
                // to the new one or we just set the old one again.
                coreConnection = jcaSession.getSICoreConnection();
            } catch (IllegalStateException e)
            {
                FFDCFilter.processException(e, "com.ibm.ws.sib.api.jms.impl.JmsConnectionImpl", "createSession#2", this);

                if (TraceComponent.isAnyTracingEnabled() && tc.isEntryEnabled())
                    SibTr.exit(this, tc, "createSession", jmsSession);

                throw (JMSException) JmsErrorUtils.newThrowable(
                                                                JMSException.class,
                                                                "JCA_CREATE_SESS_CWSIA0024",
                                                                null,
                                                                e,
                                                                "JmsConnectionImpl.createSession#2",
                                                                this,
                                                                tc);
            }
            // instantiate the jms session, and add it to this connection's session list.
            jmsSession = instantiateSession(transacted, acknowledgeMode, coreConnection, jcaSession);
        }
        synchronized (stateLock) {
            sessions.add(jmsSession);
            // d353701 - output a warning message if there are 'lots' of sessions active.
            if (sessions.size() % SESSION_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_SESSIONS_WARNING_CWSIA0027", new Object[] { "" + sessions.size(), errorLocation });
            }
        }

        if (TraceComponent.isAnyTracingEnabled() && tc.isEntryEnabled())
            SibTr.exit(this, tc, "createSession", jmsSession);
        return jmsSession;
    }
1227593
@Override
    protected void closeConnection(Object connection) {
        try {
            if (qSession!=null) qSession.close();
            if (qConnection!=null) qConnection.close();
        } catch (Exception e) {
        }
        qSession = null;
        qConnection = null;
    }
1309889
@Override
    public JmsQueueConnectionFactory createQueueConnectionFactory() throws JMSException {
        if (TraceComponent.isAnyTracingEnabled() && tc.isEntryEnabled())
            SibTr.entry(this, tc, "createQueueConnectionFactory");
        JmsQueueConnectionFactory jmsqcf = null;

        // get a jca managed queue connection factory, which is used to construct
        // the jms queue connection factory.
        JmsJcaManagedQueueConnectionFactory jcamqcf = JmsJcaFactory.getInstance().createManagedQueueConnectionFactory();

        // invoke the construction of a jms queue connection factory - the jca
        // managed queue connection factory will call back into the jms api code
        // by getting a JmsRAFactoryFactory, and calling a create jms queue
        // connection factory method on it with jca connection factory and jca
        // managed queue connection factory objects as parameters (the jms qcf
        // will keep references to the jca cf and jca mqcf).
        try {
            jmsqcf = (JmsQueueConnectionFactory) jcamqcf.createConnectionFactory();
        } catch (ResourceException re) {
            // No FFDC code needed
            // d222942 review - no documentation for when a RE will be thrown, so
            // default exception ok. (A quick look at the RA suggests the exception isn't
            // ever thrown).
            // d238447 FFDC review. Comment above suggests an FFDC ok for this case.
            throw (JMSException) JmsErrorUtils.newThrowable(
                                                            JMSException.class,
                                                            "EXCEPTION_RECEIVED_CWSIA0007",
                                                            new Object[] { re, "JmsFactoryFactoryImpl.createQueueConnectionFactory (#1)" },
                                                            re,
                                                            "JmsFactoryFactoryImpl.createQueueConnectionFactory#1",
                                                            this,
                                                            tc
                            );
        }

        if (TraceComponent.isAnyTracingEnabled() && tc.isEntryEnabled())
            SibTr.exit(this, tc, "createQueueConnectionFactory", jmsqcf);
        return jmsqcf;
    }
1272770
@Override
    public ConnectionFactory createConnectionFactory(JmsJcaConnectionFactory jcaConnectionFactory) {
        if (TraceComponent.isAnyTracingEnabled() && tc.isEntryEnabled())
            SibTr.entry(this, tc, "createConnectionFactory", jcaConnectionFactory);
        ConnectionFactory cf = new JmsManagedConnectionFactoryImpl(jcaConnectionFactory);
        if (TraceComponent.isAnyTracingEnabled() && tc.isEntryEnabled())
            SibTr.exit(this, tc, "createConnectionFactory", cf);
        return cf;
    }
1139056
@Override
	public TemporaryQueue createTemporaryQueue() throws JMSException
    { 	
    	externalAccessLock.readLock().lock();
    	try
		{
	        checkNotClosed();
	        String queueName = "TEMP-QUEUE-"+UUIDProvider.getInstance().getShortUUID();
	        engine.createTemporaryQueue(queueName);
	        connection.registerTemporaryQueue(queueName);
	        
	        return new TemporaryQueueRef(connection,queueName);
		}
    	finally
    	{
    		externalAccessLock.readLock().unlock();
    	}
    }
652885
private PooledConnection createPooledConnection(JDBCConnection connection)
    throws SQLException {

        LifeTimeConnectionWrapper connectionWrapper =
            new LifeTimeConnectionWrapper(connection, this.connectionDefaults);
        JDBCPooledConnection pooledConnection =
            new JDBCPooledConnection(connectionWrapper);

        connectionWrapper.setPooledConnection(pooledConnection);

        return pooledConnection;
    }