📄 session.html
字号:
<DD><CODE><A HREF="../../javax/jms/JMSException.html" title="class in javax.jms">JMSException</A></CODE> - if the JMS provider fails to return the transaction mode due to some internal error.</DL></DD></DL><HR><A NAME="getAcknowledgeMode()"><!-- --></A><H3>getAcknowledgeMode</H3><PRE>public int <B>getAcknowledgeMode</B>() throws <A HREF="../../javax/jms/JMSException.html" title="class in javax.jms">JMSException</A></PRE><DL><DD>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.<P><DD><DL></DL></DD><DD><DL><DT><B>Returns:</B><DD>If the session is not transacted, returns the current acknowledgement mode for the session. If the session is transacted, returns SESSION_TRANSACTED.<DT><B>Throws:</B><DD><CODE><A HREF="../../javax/jms/JMSException.html" title="class in javax.jms">JMSException</A></CODE> - if the JMS provider fails to return the acknowledgment mode due to some internal error.<DT><B>Since:</B></DT> <DD>1.1</DD><DT><B>See Also:</B><DD><A HREF="../../javax/jms/Connection.html#createSession(boolean, int)"><CODE>Connection.createSession(boolean, int)</CODE></A></DL></DD></DL><HR><A NAME="commit()"><!-- --></A><H3>commit</H3><PRE>public void <B>commit</B>() throws <A HREF="../../javax/jms/JMSException.html" title="class in javax.jms">JMSException</A></PRE><DL><DD>Commits all messages done in this transaction and releases any locks currently held.<P><DD><DL></DL></DD><DD><DL><DT><B>Throws:</B><DD><CODE><A HREF="../../javax/jms/JMSException.html" title="class in javax.jms">JMSException</A></CODE> - if the JMS provider fails to commit the transaction due to some internal error.<DD><CODE><A HREF="../../javax/jms/TransactionRolledBackException.html" title="class in javax.jms">TransactionRolledBackException</A></CODE> - if the transaction is rolled back due to some internal error during commit.<DD><CODE><A HREF="../../javax/jms/IllegalStateException.html" title="class in javax.jms">IllegalStateException</A></CODE> - if the method is not called by a transacted session.</DL></DD></DL><HR><A NAME="rollback()"><!-- --></A><H3>rollback</H3><PRE>public void <B>rollback</B>() throws <A HREF="../../javax/jms/JMSException.html" title="class in javax.jms">JMSException</A></PRE><DL><DD>Rolls back any messages done in this transaction and releases any locks currently held.<P><DD><DL></DL></DD><DD><DL><DT><B>Throws:</B><DD><CODE><A HREF="../../javax/jms/JMSException.html" title="class in javax.jms">JMSException</A></CODE> - if the JMS provider fails to roll back the transaction due to some internal error.<DD><CODE><A HREF="../../javax/jms/IllegalStateException.html" title="class in javax.jms">IllegalStateException</A></CODE> - if the method is not called by a transacted session.</DL></DD></DL><HR><A NAME="close()"><!-- --></A><H3>close</H3><PRE>public void <B>close</B>() throws <A HREF="../../javax/jms/JMSException.html" title="class in javax.jms">JMSException</A></PRE><DL><DD>Closes the session. <P>Since a provider may allocate some resources on behalf of a session outside the JVM, clients should close the resources when they are not needed. Relying on garbage collection to eventually reclaim these resources may not be timely enough. <P>There is no need to close the producers and consumers of a closed session. <P> This call will block until a <CODE>receive</CODE> call or message listener in progress has completed. A blocked message consumer <CODE>receive</CODE> call returns <CODE>null</CODE> when this session is closed. <P>Closing a transacted session must roll back the transaction in progress. <P>This method is the only <CODE>Session</CODE> method that can be called concurrently. <P>Invoking any other <CODE>Session</CODE> method on a closed session must throw a <CODE>JMSException.IllegalStateException</CODE>. Closing a closed session must <I>not</I> throw an exception.<P><DD><DL></DL></DD><DD><DL><DT><B>Throws:</B><DD><CODE><A HREF="../../javax/jms/JMSException.html" title="class in javax.jms">JMSException</A></CODE> - if the JMS provider fails to close the session due to some internal error.</DL></DD></DL><HR><A NAME="recover()"><!-- --></A><H3>recover</H3><PRE>public void <B>recover</B>() throws <A HREF="../../javax/jms/JMSException.html" title="class in javax.jms">JMSException</A></PRE><DL><DD>Stops message delivery in this session, and restarts message delivery with the oldest unacknowledged message. <P>All consumers deliver messages in a serial order. Acknowledging a received message automatically acknowledges all messages that have been delivered to the client. <P>Restarting a session causes it to take the following actions: <UL> <LI>Stop message delivery <LI>Mark all messages that might have been delivered but not acknowledged as "redelivered" <LI>Restart the delivery sequence including all unacknowledged messages that had been previously delivered. Redelivered messages do not have to be delivered in exactly their original delivery order. </UL><P><DD><DL></DL></DD><DD><DL><DT><B>Throws:</B><DD><CODE><A HREF="../../javax/jms/JMSException.html" title="class in javax.jms">JMSException</A></CODE> - if the JMS provider fails to stop and restart message delivery due to some internal error.<DD><CODE><A HREF="../../javax/jms/IllegalStateException.html" title="class in javax.jms">IllegalStateException</A></CODE> - if the method is called by a transacted session.</DL></DD></DL><HR><A NAME="getMessageListener()"><!-- --></A><H3>getMessageListener</H3><PRE>public <A HREF="../../javax/jms/MessageListener.html" title="interface in javax.jms">MessageListener</A> <B>getMessageListener</B>() throws <A HREF="../../javax/jms/JMSException.html" title="class in javax.jms">JMSException</A></PRE><DL><DD>Returns the session's distinguished message listener (optional).<P><DD><DL></DL></DD><DD><DL><DT><B>Returns:</B><DD>the message listener associated with this session<DT><B>Throws:</B><DD><CODE><A HREF="../../javax/jms/JMSException.html" title="class in javax.jms">JMSException</A></CODE> - if the JMS provider fails to get the message listener due to an internal error.<DT><B>See Also:</B><DD><A HREF="../../javax/jms/Session.html#setMessageListener(javax.jms.MessageListener)"><CODE>setMessageListener(javax.jms.MessageListener)</CODE></A>, <A HREF="../../javax/jms/ServerSessionPool.html" title="interface in javax.jms"><CODE>ServerSessionPool</CODE></A>, <A HREF="../../javax/jms/ServerSession.html" title="interface in javax.jms"><CODE>ServerSession</CODE></A></DL></DD></DL><HR><A NAME="setMessageListener(javax.jms.MessageListener)"><!-- --></A><H3>setMessageListener</H3><PRE>public void <B>setMessageListener</B>(<A HREF="../../javax/jms/MessageListener.html" title="interface in javax.jms">MessageListener</A> listener) throws <A HREF="../../javax/jms/JMSException.html" title="class in javax.jms">JMSException</A></PRE><DL><DD>Sets the session's distinguished message listener (optional). <P>When the distinguished message listener is set, no other form of message receipt in the session can be used; however, all forms of sending messages are still supported. <P>This is an expert facility not used by regular JMS clients.<P><DD><DL></DL></DD><DD><DL><DT><B>Parameters:</B><DD><CODE>listener</CODE> - the message listener to associate with this session<DT><B>Throws:</B><DD><CODE><A HREF="../../javax/jms/JMSException.html" title="class in javax.jms">JMSException</A></CODE> - if the JMS provider fails to set the message listener due to an internal error.<DT><B>See Also:</B><DD><A HREF="../../javax/jms/Session.html#getMessageListener()"><CODE>getMessageListener()</CODE></A>, <A HREF="../../javax/jms/ServerSessionPool.html" title="interface in javax.jms"><CODE>ServerSessionPool</CODE></A>, <A HREF="../../javax/jms/ServerSession.html" title="interface in javax.jms"><CODE>ServerSession</CODE></A></DL></DD></DL><HR><A NAME="run()"><!-- --></A><H3>run</H3><PRE>public void <B>run</B>()</PRE><DL><DD>Optional operation, intended to be used only by Application Servers, not by ordinary JMS clients.<P><DD><DL><DT><B>Specified by:</B><DD><CODE><A HREF="http://java.sun.com/j2se/1.4/docs/api/java/lang/Runnable.html#run()" title="class or interface in java.lang">run</A></CODE> in interface <CODE><A HREF="http://java.sun.com/j2se/1.4/docs/api/java/lang/Runnable.html" title="class or interface in java.lang">Runnable</A></CODE></DL></DD><DD><DL><DT><B>See Also:</B><DD><A HREF="../../javax/jms/ServerSession.html" title="interface in javax.jms"><CODE>ServerSession</CODE></A></DL></DD></DL><HR><A NAME="createProducer(javax.jms.Destination)"><!-- --></A><H3>createProducer</H3><PRE>public <A HREF="../../javax/jms/MessageProducer.html" title="interface in javax.jms">MessageProducer</A> <B>createProducer</B>(<A HREF="../../javax/jms/Destination.html" title="interface in javax.jms">Destination</A> destination) throws <A HREF="../../javax/jms/JMSException.html" title="class in javax.jms">JMSException</A></PRE><DL><DD>Creates a <CODE>MessageProducer</CODE> to send messages to the specified destination. <P>A client uses a <CODE>MessageProducer</CODE> object to send messages to a destination. Since <CODE>Queue</CODE> and <CODE>Topic</CODE> both inherit from <CODE>Destination</CODE>, they can be used in the destination parameter to create a <CODE>MessageProducer</CODE> object.<P><DD><DL></DL></DD><DD><DL><DT><B>Parameters:</B><DD><CODE>destination</CODE> - the <CODE>Destination</CODE> to send to, or null if this is a producer which does not have a specified destination.<DT><B>Throws:</B><DD><CODE><A HREF="../../javax/jms/JMSException.html" title="class in javax.jms">JMSException</A></CODE> - if the session fails to create a MessageProducer due to some internal error.<DD><CODE><A HREF="../../javax/jms/InvalidDestinationException.html" title="class in javax.jms">InvalidDestinationException</A></CODE> - if an invalid destination is specified.<DT><B>Since:</B></DT> <DD>1.1</DD></DL></DD></DL><HR><A NAME="createConsumer(javax.jms.Destination)"><!-- --></A><H3>createConsumer</H3><PRE>public <A HREF="../../javax/jms/MessageConsumer.html" title="interface in javax.jms">MessageConsumer</A> <B>createConsumer</B>(<A HREF="../../javax/jms/Destination.html" title="interface in javax.jms">Destination</A> destination) throws <A HREF="../../javax/jms/JMSException.html" title="class in javax.jms">JMSException</A></PRE><DL><DD>Creates a <CODE>MessageConsumer</CODE> for the specified destination. Since <CODE>Queue</CODE> and <CODE>Topic</CODE> both inherit from <CODE>Destination</CODE>, they can be used in the destination parameter to create a <CODE>MessageConsumer</CODE>.<P>
⌨️ 快捷键说明
复制代码
Ctrl + C
搜索代码
Ctrl + F
全屏模式
F11
切换主题
Ctrl + Shift + D
显示快捷键
?
增大字号
Ctrl + =
减小字号
Ctrl + -