/** * Returns the session's distinguished message listener (optional). * * @return the message listener associated with this session * @throws JMSException if the JMS provider fails to get the message * listener due to an internal error. * @see javax.jms.Session#setMessageListener(javax.jms.MessageListener) * @see javax.jms.ServerSessionPool * @see javax.jms.ServerSession */ @Override public MessageListener getMessageListener() throws JMSException { checkClosed(); return this.messageListener; }
/** * Returns the acknowledgement mode of the session. The acknowledgement mode * is set at the time that the session is created. If the session is * transacted, the acknowledgement mode is ignored. * * @return If the session is not transacted, returns the current * acknowledgement mode for the session. If the session is * transacted, returns SESSION_TRANSACTED. * @throws JMSException * @see javax.jms.Connection#createSession(boolean,int) * @since 1.1 exception JMSException if there is some internal error. */ @Override public int getAcknowledgeMode() throws JMSException { checkClosed(); return this.acknowledgementMode; }
/** * Indicates whether the session is in transacted mode. * * @return true if the session is in transacted mode * @throws JMSException if there is some internal error. */ @Override public boolean getTransacted() throws JMSException { checkClosed(); return isTransacted(); }
/** * Checks that the session is not closed then configures the message */ protected void configureMessage(ActiveMQMessage message) throws IllegalStateException { checkClosed(); message.setConnection(connection); }
/** * Creates a <CODE>TemporaryTopic</CODE> object. Its lifetime will be that * of the <CODE>Connection</CODE> unless it is deleted earlier. * * @return a temporary topic identity * @throws JMSException if the session fails to create a temporary topic due * to some internal error. * @since 1.1 */ @Override public TemporaryTopic createTemporaryTopic() throws JMSException { checkClosed(); return (TemporaryTopic)connection.createTempDestination(true); }
/** * Creates a <CODE>TemporaryQueue</CODE> object. Its lifetime will be that * of the <CODE>Connection</CODE> unless it is deleted earlier. * * @return a temporary queue identity * @throws JMSException if the session fails to create a temporary queue due * to some internal error. * @since 1.1 */ @Override public TemporaryQueue createTemporaryQueue() throws JMSException { checkClosed(); return (TemporaryQueue)connection.createTempDestination(false); }
/** * Creates a <CODE>QueueReceiver</CODE> object to receive messages from * the specified queue. * * @param queue the <CODE>Queue</CODE> to access * @return a new QueueBrowser instance. * @throws JMSException if the session fails to create a receiver due to * some internal error. * @throws JMSException * @throws InvalidDestinationException if an invalid queue is specified. */ @Override public QueueReceiver createReceiver(Queue queue) throws JMSException { checkClosed(); return createReceiver(queue, null); }
/** * Creates a <CODE>QueueBrowser</CODE> object to peek at the messages on * the specified queue. * * @param queue the <CODE>queue</CODE> to access * @return the Queue Browser * @throws JMSException if the session fails to create a browser due to some * internal error. * @throws InvalidDestinationException if an invalid destination is * specified * @since 1.1 */ @Override public QueueBrowser createBrowser(Queue queue) throws JMSException { checkClosed(); return createBrowser(queue, null); }
/** * Unsubscribes a durable subscription that has been created by a client. * <P> * This method deletes the state being maintained on behalf of the * subscriber by its provider. * <P> * It is erroneous for a client to delete a durable subscription while there * is an active <CODE>MessageConsumer </CODE> or * <CODE>TopicSubscriber</CODE> for the subscription, or while a consumed * message is part of a pending transaction or has not been acknowledged in * the session. * * @param name the name used to identify this subscription * @throws JMSException if the session fails to unsubscribe to the durable * subscription due to some internal error. * @throws InvalidDestinationException if an invalid subscription name is * specified. * @since 1.1 */ @Override public void unsubscribe(String name) throws JMSException { checkClosed(); connection.unsubscribe(name); }
/** * Creates a nondurable subscriber to the specified topic. <p/> * <P> * A client uses a <CODE>TopicSubscriber</CODE> object to receive messages * that have been published to a topic. <p/> * <P> * Regular <CODE>TopicSubscriber</CODE> objects are not durable. They * receive only messages that are published while they are active. <p/> * <P> * In some cases, a connection may both publish and subscribe to a topic. * The subscriber <CODE>NoLocal</CODE> attribute allows a subscriber to * inhibit the delivery of messages published by its own connection. The * default value for this attribute is false. * * @param topic the <CODE>Topic</CODE> to subscribe to * @return TopicSubscriber * @throws JMSException if the session fails to create a subscriber due to * some internal error. * @throws InvalidDestinationException if an invalid topic is specified. */ @Override public TopicSubscriber createSubscriber(Topic topic) throws JMSException { checkClosed(); return createSubscriber(topic, null, false); }
@Override public void execute() throws Exception { checkClosed(); session.checkClosed(); session.acknowledge(); } });
@Override public void execute() throws Exception { checkClosed(); session.checkClosed(); acknowledge(md); } });
/** * Creates a queue identity given a <CODE>Queue</CODE> name. * <P> * This facility is provided for the rare cases where clients need to * dynamically manipulate queue identity. It allows the creation of a queue * identity with a provider-specific name. Clients that depend on this * ability are not portable. * <P> * Note that this method is not for creating the physical queue. The * physical creation of queues is an administrative task and is not to be * initiated by the JMS API. The one exception is the creation of temporary * queues, which is accomplished with the <CODE>createTemporaryQueue</CODE> * method. * * @param queueName the name of this <CODE>Queue</CODE> * @return a <CODE>Queue</CODE> with the given name * @throws JMSException if the session fails to create a queue due to some * internal error. * @since 1.1 */ @Override public Queue createQueue(String queueName) throws JMSException { checkClosed(); if (queueName.startsWith(ActiveMQDestination.TEMP_DESTINATION_NAME_PREFIX)) { return new ActiveMQTempQueue(queueName); } return new ActiveMQQueue(queueName); }
/** * Creates a topic identity given a <CODE>Topic</CODE> name. * <P> * This facility is provided for the rare cases where clients need to * dynamically manipulate topic identity. This allows the creation of a * topic identity with a provider-specific name. Clients that depend on this * ability are not portable. * <P> * Note that this method is not for creating the physical topic. The * physical creation of topics is an administrative task and is not to be * initiated by the JMS API. The one exception is the creation of temporary * topics, which is accomplished with the <CODE>createTemporaryTopic</CODE> * method. * * @param topicName the name of this <CODE>Topic</CODE> * @return a <CODE>Topic</CODE> with the given name * @throws JMSException if the session fails to create a topic due to some * internal error. * @since 1.1 */ @Override public Topic createTopic(String topicName) throws JMSException { checkClosed(); if (topicName.startsWith(ActiveMQDestination.TEMP_DESTINATION_NAME_PREFIX)) { return new ActiveMQTempTopic(topicName); } return new ActiveMQTopic(topicName); }
/** * Commits all messages done in this transaction and releases any locks * currently held. * * @throws JMSException if the JMS provider fails to commit the transaction * due to some internal error. * @throws TransactionRolledBackException if the transaction is rolled back * due to some internal error during commit. * @throws javax.jms.IllegalStateException if the method is not called by a * transacted session. */ @Override public void commit() throws JMSException { checkClosed(); if (!getTransacted()) { throw new javax.jms.IllegalStateException("Not a transacted session"); } if (LOG.isDebugEnabled()) { LOG.debug(getSessionId() + " Transaction Commit :" + transactionContext.getTransactionId()); } transactionContext.commit(); }
/** * Rolls back any messages done in this transaction and releases any locks * currently held. * * @throws JMSException if the JMS provider fails to roll back the * transaction due to some internal error. * @throws javax.jms.IllegalStateException if the method is not called by a * transacted session. */ @Override public void rollback() throws JMSException { checkClosed(); if (!getTransacted()) { throw new javax.jms.IllegalStateException("Not a transacted session"); } if (LOG.isDebugEnabled()) { LOG.debug(getSessionId() + " Transaction Rollback, txid:" + transactionContext.getTransactionId()); } transactionContext.rollback(); }
/** * Creates a <CODE>QueueBrowser</CODE> object to peek at the messages on * the specified queue using a message selector. * * @param queue the <CODE>queue</CODE> to access * @param messageSelector only messages with properties matching the message * selector expression are delivered. A value of null or an * empty string indicates that there is no message selector * for the message consumer. * @return the Queue Browser * @throws JMSException if the session fails to create a browser due to some * internal error. * @throws InvalidDestinationException if an invalid destination is * specified * @throws InvalidSelectorException if the message selector is invalid. * @since 1.1 */ @Override public QueueBrowser createBrowser(Queue queue, String messageSelector) throws JMSException { checkClosed(); return new ActiveMQQueueBrowser(this, getNextConsumerId(), ActiveMQMessageTransformation.transformDestination(queue), messageSelector, asyncDispatch); }
/** * Creates a <CODE>QueueSender</CODE> object to send messages to the * specified queue. * * @param queue the <CODE>Queue</CODE> to access, or null if this is an * unidentified producer * @return QueueSender * @throws JMSException if the session fails to create a sender due to some * internal error. * @throws InvalidDestinationException if an invalid queue is specified. */ @Override public QueueSender createSender(Queue queue) throws JMSException { checkClosed(); if (queue instanceof CustomDestination) { CustomDestination customDestination = (CustomDestination)queue; return customDestination.createSender(this); } int timeSendOut = connection.getSendTimeout(); return new ActiveMQQueueSender(this, ActiveMQMessageTransformation.transformDestination(queue),timeSendOut); }
/** * Creates a publisher for the specified topic. <p/> * <P> * A client uses a <CODE>TopicPublisher</CODE> object to publish messages * on a topic. Each time a client creates a <CODE>TopicPublisher</CODE> on * a topic, it defines a new sequence of messages that have no ordering * relationship with the messages it has previously sent. * * @param topic the <CODE>Topic</CODE> to publish to, or null if this is * an unidentified producer * @return TopicPublisher * @throws JMSException if the session fails to create a publisher due to * some internal error. * @throws InvalidDestinationException if an invalid topic is specified. */ @Override public TopicPublisher createPublisher(Topic topic) throws JMSException { checkClosed(); if (topic instanceof CustomDestination) { CustomDestination customDestination = (CustomDestination)topic; return customDestination.createPublisher(this); } int timeSendOut = connection.getSendTimeout(); return new ActiveMQTopicPublisher(this, ActiveMQMessageTransformation.transformDestination(topic),timeSendOut); }
/** * Creates a <CODE>QueueReceiver</CODE> object to receive messages from * the specified queue using a message selector. * * @param queue the <CODE>Queue</CODE> to access * @param messageSelector only messages with properties matching the message * selector expression are delivered. A value of null or an * empty string indicates that there is no message selector * for the message consumer. * @return QueueReceiver * @throws JMSException if the session fails to create a receiver due to * some internal error. * @throws InvalidDestinationException if an invalid queue is specified. * @throws InvalidSelectorException if the message selector is invalid. */ @Override public QueueReceiver createReceiver(Queue queue, String messageSelector) throws JMSException { checkClosed(); if (queue instanceof CustomDestination) { CustomDestination customDestination = (CustomDestination)queue; return customDestination.createReceiver(this, messageSelector); } ActiveMQPrefetchPolicy prefetchPolicy = this.connection.getPrefetchPolicy(); return new ActiveMQQueueReceiver(this, getNextConsumerId(), ActiveMQMessageTransformation.transformDestination(queue), messageSelector, prefetchPolicy.getQueuePrefetch(), prefetchPolicy.getMaximumPendingMessageLimit(), asyncDispatch); }