| <!DOCTYPE HTML PUBLIC "-//W3C//DTD HTML 4.01 Transitional//EN" "http://www.w3.org/TR/html4/loose.dtd"> |
| <!-- NewPage --> |
| <html lang="en"> |
| <head> |
| <title>JMSConsumer</title> |
| <link rel="stylesheet" type="text/css" href="../../stylesheet.css" title="Style"> |
| <script type="text/javascript" src="../../script.js"></script> |
| |
| <link rel="shortcut icon" href="/img/jakarta-favicon.ico"> |
| </head> |
| <body> |
| <script type="text/javascript"><!-- |
| try { |
| if (location.href.indexOf('is-external=true') == -1) { |
| parent.document.title="JMSConsumer"; |
| } |
| } |
| catch(err) { |
| } |
| //--> |
| var methods = {"i0":6,"i1":6,"i2":6,"i3":6,"i4":6,"i5":6,"i6":6,"i7":6,"i8":6,"i9":6}; |
| var tabs = {65535:["t0","All Methods"],2:["t2","Instance Methods"],4:["t3","Abstract Methods"]}; |
| var altColor = "altColor"; |
| var rowColor = "rowColor"; |
| var tableTab = "tableTab"; |
| var activeTableTab = "activeTableTab"; |
| </script> |
| <noscript> |
| <div>JavaScript is disabled on your browser.</div> |
| </noscript> |
| <!-- ========= START OF TOP NAVBAR ======= --> |
| <div class="topNav"><a name="navbar.top"> |
| <!-- --> |
| </a> |
| <div class="skipNav"><a href="#skip.navbar.top" title="Skip navigation links">Skip navigation links</a></div> |
| <a name="navbar.top.firstrow"> |
| <!-- --> |
| </a> |
| <ul class="navList" title="Navigation"> |
| <li><a href="../../overview-summary.html">Overview</a></li> |
| <li><a href="package-summary.html">Package</a></li> |
| <li class="navBarCell1Rev">Class</li> |
| <li><a href="package-tree.html">Tree</a></li> |
| <li><a href="../../deprecated-list.html">Deprecated</a></li> |
| <li><a href="../../index-all.html">Index</a></li> |
| <li><a href="../../help-doc.html">Help</a></li> |
| </ul> |
| </div> |
| <div class="subNav"> |
| <ul class="navList"> |
| <li><a href="../../jakarta/jms/JMSConnectionFactoryDefinitions.html" title="annotation in jakarta.jms"><span class="typeNameLink">Prev Class</span></a></li> |
| <li><a href="../../jakarta/jms/JMSContext.html" title="interface in jakarta.jms"><span class="typeNameLink">Next Class</span></a></li> |
| </ul> |
| <ul class="navList"> |
| <li><a href="../../index.html?jakarta/jms/JMSConsumer.html" target="_top">Frames</a></li> |
| <li><a href="JMSConsumer.html" target="_top">No Frames</a></li> |
| </ul> |
| <ul class="navList" id="allclasses_navbar_top"> |
| <li><a href="../../allclasses-noframe.html">All Classes</a></li> |
| </ul> |
| <div> |
| <script type="text/javascript"><!-- |
| allClassesLink = document.getElementById("allclasses_navbar_top"); |
| if(window==top) { |
| allClassesLink.style.display = "block"; |
| } |
| else { |
| allClassesLink.style.display = "none"; |
| } |
| //--> |
| </script> |
| </div> |
| <div> |
| <ul class="subNavList"> |
| <li>Summary: </li> |
| <li>Nested | </li> |
| <li>Field | </li> |
| <li>Constr | </li> |
| <li><a href="#method.summary">Method</a></li> |
| </ul> |
| <ul class="subNavList"> |
| <li>Detail: </li> |
| <li>Field | </li> |
| <li>Constr | </li> |
| <li><a href="#method.detail">Method</a></li> |
| </ul> |
| </div> |
| <a name="skip.navbar.top"> |
| <!-- --> |
| </a></div> |
| <!-- ========= END OF TOP NAVBAR ========= --> |
| <!-- ======== START OF CLASS DATA ======== --> |
| <div class="header"> |
| <div class="subTitle">jakarta.jms</div> |
| <h2 title="Interface JMSConsumer" class="title">Interface JMSConsumer</h2> |
| </div> |
| <div class="contentContainer"> |
| <div class="description"> |
| <ul class="blockList"> |
| <li class="blockList"> |
| <dl> |
| <dt>All Superinterfaces:</dt> |
| <dd>java.lang.AutoCloseable</dd> |
| </dl> |
| <hr> |
| <br> |
| <pre>public interface <span class="typeNameLabel">JMSConsumer</span> |
| extends java.lang.AutoCloseable</pre> |
| <div class="block">A client using the simplified Jakarta Messaging API introduced for Jakarta Messaging 2.0 uses a <code>JMSConsumer</code> object to receive messages |
| from a queue or topic. A <code>JMSConsumer</code> object may be created either created by passing a <code>Queue</code> or |
| <code>Topic</code> object to one of the <code>createConsumer</code> methods on a <code>JMSContext</code>. or by passing a |
| <code>Topic</code> object to one of the <code>createSharedConsumer</code> or <code>createDurableConsumer</code> methods on a |
| <code>JMSContext</code>. |
| |
| <p> |
| A <code>JMSConsumer</code> can be created with a message selector. A message selector allows the client to restrict the |
| messages delivered to the <code>JMSConsumer</code> to those that match the selector. |
| |
| <p> |
| A client may either synchronously receive a <code>JMSConsumer</code>'s messages or have the <code>JMSConsumer</code> |
| asynchronously deliver them as they arrive. |
| |
| <p> |
| For synchronous receipt, a client can request the next message from a <code>JMSConsumer</code> using one of its |
| <code>receive</code> methods. There are several variations of <code>receive</code> that allow a client to poll or wait for the |
| next message. |
| |
| <p> |
| For asynchronous delivery, a client can register a <code>MessageListener</code> object with a <code>JMSConsumer</code>. As |
| messages arrive at the <code>JMSConsumer</code>, it delivers them by calling the <code>MessageListener</code> 's |
| <code>onMessage</code> method. |
| |
| <p> |
| It is a client programming error for a <code>MessageListener</code> to throw an exception.</div> |
| <dl> |
| <dt><span class="simpleTagLabel">Since:</span></dt> |
| <dd>JMS 2.0</dd> |
| <dt><span class="seeLabel">See Also:</span></dt> |
| <dd><a href="../../jakarta/jms/JMSContext.html" title="interface in jakarta.jms"><code>JMSContext</code></a></dd> |
| </dl> |
| </li> |
| </ul> |
| </div> |
| <div class="summary"> |
| <ul class="blockList"> |
| <li class="blockList"> |
| <!-- ========== METHOD SUMMARY =========== --> |
| <ul class="blockList"> |
| <li class="blockList"><a name="method.summary"> |
| <!-- --> |
| </a> |
| <h3>Method Summary</h3> |
| <table class="memberSummary" border="0" cellpadding="3" cellspacing="0" summary="Method Summary table, listing methods, and an explanation"> |
| <caption><span id="t0" class="activeTableTab"><span>All Methods</span><span class="tabEnd"> </span></span><span id="t2" class="tableTab"><span><a href="javascript:show(2);">Instance Methods</a></span><span class="tabEnd"> </span></span><span id="t3" class="tableTab"><span><a href="javascript:show(4);">Abstract Methods</a></span><span class="tabEnd"> </span></span></caption> |
| <tr> |
| <th class="colFirst" scope="col">Modifier and Type</th> |
| <th class="colLast" scope="col">Method and Description</th> |
| </tr> |
| <tr id="i0" class="altColor"> |
| <td class="colFirst"><code>void</code></td> |
| <td class="colLast"><code><span class="memberNameLink"><a href="../../jakarta/jms/JMSConsumer.html#close--">close</a></span>()</code> |
| <div class="block">Closes the <code>JMSConsumer</code>.</div> |
| </td> |
| </tr> |
| <tr id="i1" class="rowColor"> |
| <td class="colFirst"><code><a href="../../jakarta/jms/MessageListener.html" title="interface in jakarta.jms">MessageListener</a></code></td> |
| <td class="colLast"><code><span class="memberNameLink"><a href="../../jakarta/jms/JMSConsumer.html#getMessageListener--">getMessageListener</a></span>()</code> |
| <div class="block">Gets the <code>JMSConsumer</code>'s <code>MessageListener</code>.</div> |
| </td> |
| </tr> |
| <tr id="i2" class="altColor"> |
| <td class="colFirst"><code>java.lang.String</code></td> |
| <td class="colLast"><code><span class="memberNameLink"><a href="../../jakarta/jms/JMSConsumer.html#getMessageSelector--">getMessageSelector</a></span>()</code> |
| <div class="block">Gets this <code>JMSConsumer</code>'s message selector expression.</div> |
| </td> |
| </tr> |
| <tr id="i3" class="rowColor"> |
| <td class="colFirst"><code><a href="../../jakarta/jms/Message.html" title="interface in jakarta.jms">Message</a></code></td> |
| <td class="colLast"><code><span class="memberNameLink"><a href="../../jakarta/jms/JMSConsumer.html#receive--">receive</a></span>()</code> |
| <div class="block">Receives the next message produced for this <code>JMSConsumer</code>.</div> |
| </td> |
| </tr> |
| <tr id="i4" class="altColor"> |
| <td class="colFirst"><code><a href="../../jakarta/jms/Message.html" title="interface in jakarta.jms">Message</a></code></td> |
| <td class="colLast"><code><span class="memberNameLink"><a href="../../jakarta/jms/JMSConsumer.html#receive-long-">receive</a></span>(long timeout)</code> |
| <div class="block">Receives the next message that arrives within the specified timeout interval.</div> |
| </td> |
| </tr> |
| <tr id="i5" class="rowColor"> |
| <td class="colFirst"><code><T> T</code></td> |
| <td class="colLast"><code><span class="memberNameLink"><a href="../../jakarta/jms/JMSConsumer.html#receiveBody-java.lang.Class-">receiveBody</a></span>(java.lang.Class<T> c)</code> |
| <div class="block">Receives the next message produced for this <code>JMSConsumer</code> and returns its body as an object of the specified |
| type.</div> |
| </td> |
| </tr> |
| <tr id="i6" class="altColor"> |
| <td class="colFirst"><code><T> T</code></td> |
| <td class="colLast"><code><span class="memberNameLink"><a href="../../jakarta/jms/JMSConsumer.html#receiveBody-java.lang.Class-long-">receiveBody</a></span>(java.lang.Class<T> c, |
| long timeout)</code> |
| <div class="block">Receives the next message produced for this <code>JMSConsumer</code> that arrives within the specified timeout period and |
| returns its body as an object of the specified type.</div> |
| </td> |
| </tr> |
| <tr id="i7" class="rowColor"> |
| <td class="colFirst"><code><T> T</code></td> |
| <td class="colLast"><code><span class="memberNameLink"><a href="../../jakarta/jms/JMSConsumer.html#receiveBodyNoWait-java.lang.Class-">receiveBodyNoWait</a></span>(java.lang.Class<T> c)</code> |
| <div class="block">Receives the next message produced for this <code>JMSConsumer</code> if one is immediately available and returns its body |
| as an object of the specified type.</div> |
| </td> |
| </tr> |
| <tr id="i8" class="altColor"> |
| <td class="colFirst"><code><a href="../../jakarta/jms/Message.html" title="interface in jakarta.jms">Message</a></code></td> |
| <td class="colLast"><code><span class="memberNameLink"><a href="../../jakarta/jms/JMSConsumer.html#receiveNoWait--">receiveNoWait</a></span>()</code> |
| <div class="block">Receives the next message if one is immediately available.</div> |
| </td> |
| </tr> |
| <tr id="i9" class="rowColor"> |
| <td class="colFirst"><code>void</code></td> |
| <td class="colLast"><code><span class="memberNameLink"><a href="../../jakarta/jms/JMSConsumer.html#setMessageListener-jakarta.jms.MessageListener-">setMessageListener</a></span>(<a href="../../jakarta/jms/MessageListener.html" title="interface in jakarta.jms">MessageListener</a> listener)</code> |
| <div class="block">Sets the <code>JMSConsumer</code>'s <code>MessageListener</code>.</div> |
| </td> |
| </tr> |
| </table> |
| </li> |
| </ul> |
| </li> |
| </ul> |
| </div> |
| <div class="details"> |
| <ul class="blockList"> |
| <li class="blockList"> |
| <!-- ============ METHOD DETAIL ========== --> |
| <ul class="blockList"> |
| <li class="blockList"><a name="method.detail"> |
| <!-- --> |
| </a> |
| <h3>Method Detail</h3> |
| <a name="getMessageSelector--"> |
| <!-- --> |
| </a> |
| <ul class="blockList"> |
| <li class="blockList"> |
| <h4>getMessageSelector</h4> |
| <pre>java.lang.String getMessageSelector()</pre> |
| <div class="block">Gets this <code>JMSConsumer</code>'s message selector expression.</div> |
| <dl> |
| <dt><span class="returnLabel">Returns:</span></dt> |
| <dd>this <code>JMSConsumer</code>'s message selector, or null if no message selector exists for the |
| <code>JMSConsumer</code> (that is, if the message selector was not set or was set to null or the empty string)</dd> |
| <dt><span class="throwsLabel">Throws:</span></dt> |
| <dd><code><a href="../../jakarta/jms/JMSRuntimeException.html" title="class in jakarta.jms">JMSRuntimeException</a></code> - if the Jakarta Messaging provider fails to get the message selector due to some internal error.</dd> |
| </dl> |
| </li> |
| </ul> |
| <a name="getMessageListener--"> |
| <!-- --> |
| </a> |
| <ul class="blockList"> |
| <li class="blockList"> |
| <h4>getMessageListener</h4> |
| <pre><a href="../../jakarta/jms/MessageListener.html" title="interface in jakarta.jms">MessageListener</a> getMessageListener() |
| throws <a href="../../jakarta/jms/JMSRuntimeException.html" title="class in jakarta.jms">JMSRuntimeException</a></pre> |
| <div class="block">Gets the <code>JMSConsumer</code>'s <code>MessageListener</code>. |
| <p> |
| This method must not be used in a Jakarta EE web or EJB application. Doing so may cause a <code>JMSRuntimeException</code> to |
| be thrown though this is not guaranteed.</div> |
| <dl> |
| <dt><span class="returnLabel">Returns:</span></dt> |
| <dd>the <code>JMSConsumer</code>'s <code>MessageListener</code>, or null if one was not set</dd> |
| <dt><span class="throwsLabel">Throws:</span></dt> |
| <dd><code><a href="../../jakarta/jms/JMSRuntimeException.html" title="class in jakarta.jms">JMSRuntimeException</a></code> - if the Jakarta Messaging provider fails to get the <code>MessageListener</code> for one of the following |
| reasons: |
| <ul> |
| <li>an internal error has occurred or |
| <li>this method has been called in a Jakarta EE web or EJB application (though it is not guaranteed that an exception is |
| thrown in this case) |
| </ul></dd> |
| <dt><span class="seeLabel">See Also:</span></dt> |
| <dd><a href="../../jakarta/jms/JMSConsumer.html#setMessageListener-jakarta.jms.MessageListener-"><code>setMessageListener(jakarta.jms.MessageListener)</code></a></dd> |
| </dl> |
| </li> |
| </ul> |
| <a name="setMessageListener-jakarta.jms.MessageListener-"> |
| <!-- --> |
| </a> |
| <ul class="blockList"> |
| <li class="blockList"> |
| <h4>setMessageListener</h4> |
| <pre>void setMessageListener(<a href="../../jakarta/jms/MessageListener.html" title="interface in jakarta.jms">MessageListener</a> listener) |
| throws <a href="../../jakarta/jms/JMSRuntimeException.html" title="class in jakarta.jms">JMSRuntimeException</a></pre> |
| <div class="block">Sets the <code>JMSConsumer</code>'s <code>MessageListener</code>. |
| <p> |
| Setting the <code>MessageListener</code> to null is the equivalent of unsetting the <code>MessageListener</code> for the |
| <code>JMSConsumer</code>. |
| <p> |
| The effect of calling this method while messages are being consumed by an existing listener or the |
| <code>JMSConsumer</code> is being used to consume messages synchronously is undefined. |
| <p> |
| This method must not be used in a Jakarta EE web or EJB application. Doing so may cause a <code>JMSRuntimeException</code> to |
| be thrown though this is not guaranteed.</div> |
| <dl> |
| <dt><span class="paramLabel">Parameters:</span></dt> |
| <dd><code>listener</code> - the listener to which the messages are to be delivered</dd> |
| <dt><span class="throwsLabel">Throws:</span></dt> |
| <dd><code><a href="../../jakarta/jms/JMSRuntimeException.html" title="class in jakarta.jms">JMSRuntimeException</a></code> - if the Jakarta Messaging provider fails to set the <code>JMSConsumer</code>'s <code>MessageListener</code> for |
| one of the following reasons: |
| <ul> |
| <li>an internal error has occurred or |
| <li>this method has been called in a Jakarta EE web or EJB application (though it is not guaranteed that an exception is |
| thrown in this case) |
| </ul></dd> |
| <dt><span class="seeLabel">See Also:</span></dt> |
| <dd><a href="../../jakarta/jms/JMSConsumer.html#getMessageListener--"><code>getMessageListener()</code></a></dd> |
| </dl> |
| </li> |
| </ul> |
| <a name="receive--"> |
| <!-- --> |
| </a> |
| <ul class="blockList"> |
| <li class="blockList"> |
| <h4>receive</h4> |
| <pre><a href="../../jakarta/jms/Message.html" title="interface in jakarta.jms">Message</a> receive()</pre> |
| <div class="block">Receives the next message produced for this <code>JMSConsumer</code>. |
| |
| <p> |
| This call blocks indefinitely until a message is produced or until this <code>JMSConsumer</code> is closed. |
| |
| <p> |
| If this <code>receive</code> is done within a transaction, the JMSConsumer retains the message until the transaction |
| commits.</div> |
| <dl> |
| <dt><span class="returnLabel">Returns:</span></dt> |
| <dd>the next message produced for this <code>JMSConsumer</code>, or null if this <code>JMSConsumer</code> is concurrently |
| closed</dd> |
| <dt><span class="throwsLabel">Throws:</span></dt> |
| <dd><code><a href="../../jakarta/jms/JMSRuntimeException.html" title="class in jakarta.jms">JMSRuntimeException</a></code> - if the Jakarta Messaging provider fails to receive the next message due to some internal error.</dd> |
| </dl> |
| </li> |
| </ul> |
| <a name="receive-long-"> |
| <!-- --> |
| </a> |
| <ul class="blockList"> |
| <li class="blockList"> |
| <h4>receive</h4> |
| <pre><a href="../../jakarta/jms/Message.html" title="interface in jakarta.jms">Message</a> receive(long timeout)</pre> |
| <div class="block">Receives the next message that arrives within the specified timeout interval. |
| |
| <p> |
| This call blocks until a message arrives, the timeout expires, or this <code>JMSConsumer</code> is closed. A |
| <code>timeout</code> of zero never expires, and the call blocks indefinitely.</div> |
| <dl> |
| <dt><span class="paramLabel">Parameters:</span></dt> |
| <dd><code>timeout</code> - the timeout value (in milliseconds)</dd> |
| <dt><span class="returnLabel">Returns:</span></dt> |
| <dd>the next message produced for this <code>JMSConsumer</code>, or null if the timeout expires or this |
| <code>JMSConsumer</code> is concurrently closed</dd> |
| <dt><span class="throwsLabel">Throws:</span></dt> |
| <dd><code><a href="../../jakarta/jms/JMSRuntimeException.html" title="class in jakarta.jms">JMSRuntimeException</a></code> - if the Jakarta Messaging provider fails to receive the next message due to some internal error.</dd> |
| </dl> |
| </li> |
| </ul> |
| <a name="receiveNoWait--"> |
| <!-- --> |
| </a> |
| <ul class="blockList"> |
| <li class="blockList"> |
| <h4>receiveNoWait</h4> |
| <pre><a href="../../jakarta/jms/Message.html" title="interface in jakarta.jms">Message</a> receiveNoWait()</pre> |
| <div class="block">Receives the next message if one is immediately available.</div> |
| <dl> |
| <dt><span class="returnLabel">Returns:</span></dt> |
| <dd>the next message produced for this <code>JMSConsumer</code>, or null if one is not available</dd> |
| <dt><span class="throwsLabel">Throws:</span></dt> |
| <dd><code><a href="../../jakarta/jms/JMSRuntimeException.html" title="class in jakarta.jms">JMSRuntimeException</a></code> - if the Jakarta Messaging provider fails to receive the next message due to some internal error.</dd> |
| </dl> |
| </li> |
| </ul> |
| <a name="close--"> |
| <!-- --> |
| </a> |
| <ul class="blockList"> |
| <li class="blockList"> |
| <h4>close</h4> |
| <pre>void close()</pre> |
| <div class="block">Closes the <code>JMSConsumer</code>. |
| <p> |
| Since a provider may allocate some resources on behalf of a <code>JMSConsumer</code> outside the Java virtual machine, |
| clients should close them when they are not needed. Relying on garbage collection to eventually reclaim these |
| resources may not be timely enough. |
| <p> |
| This call will block until a <code>receive</code> call in progress on this consumer has completed. A blocked |
| <code>receive</code> call returns null when this consumer is closed. |
| <p> |
| If this method is called whilst a message listener is in progress in another thread then it will block until the |
| message listener has completed. |
| <p> |
| This method may be called from a message listener's <code>onMessage</code> method on its own consumer. After this method |
| returns the <code>onMessage</code> method will be allowed to complete normally. |
| <p> |
| This method is the only <code>JMSConsumer</code> method that can be called concurrently.</div> |
| <dl> |
| <dt><span class="overrideSpecifyLabel">Specified by:</span></dt> |
| <dd><code>close</code> in interface <code>java.lang.AutoCloseable</code></dd> |
| <dt><span class="throwsLabel">Throws:</span></dt> |
| <dd><code><a href="../../jakarta/jms/JMSRuntimeException.html" title="class in jakarta.jms">JMSRuntimeException</a></code> - if the Jakarta Messaging provider fails to close the consumer due to some internal error.</dd> |
| </dl> |
| </li> |
| </ul> |
| <a name="receiveBody-java.lang.Class-"> |
| <!-- --> |
| </a> |
| <ul class="blockList"> |
| <li class="blockList"> |
| <h4>receiveBody</h4> |
| <pre><T> T receiveBody(java.lang.Class<T> c)</pre> |
| <div class="block">Receives the next message produced for this <code>JMSConsumer</code> and returns its body as an object of the specified |
| type. This method may be used to receive any type of message except for <code>StreamMessage</code> and <code>Message</code>, so |
| long as the message has a body which is capable of being assigned to the specified type. This means that the |
| specified class or interface must either be the same as, or a superclass or superinterface of, the class of the |
| message body. If the message is not one of the supported types, or its body cannot be assigned to the specified type, |
| or it has no body, then a <code>MessageFormatRuntimeException</code> is thrown. |
| |
| <p> |
| This method does not give access to the message headers or properties (such as the <code>JMSRedelivered</code> message |
| header field or the <code>JMSXDeliveryCount</code> message property) and should only be used if the application has no |
| need to access them. |
| |
| <p> |
| This call blocks indefinitely until a message is produced or until this <code>JMSConsumer</code> is closed. |
| |
| <p> |
| If this method is called within a transaction, the <code>JMSConsumer</code> retains the message until the transaction |
| commits. |
| |
| <p> |
| The result of this method throwing a <code>MessageFormatRuntimeException</code> depends on the session mode: |
| |
| <ul> |
| <li><code>AUTO_ACKNOWLEDGE</code> or <code>DUPS_OK_ACKNOWLEDGE</code>: The Jakarta Messaging provider will behave as if the unsuccessful call |
| to <code>receiveBody</code> had not occurred. The message will be delivered again before any subsequent messages. |
| |
| This is not considered to be redelivery and does not cause the <code>JMSRedelivered</code> message header field to be set |
| or the <code>JMSXDeliveryCount</code> message property to be incremented.</li> |
| <li><code>CLIENT_ACKNOWLEDGE</code>: The Jakarta Messaging provider will behave as if the call to <code>receiveBody</code> had been |
| successful and will not deliver the message again. |
| |
| As with any message that is delivered with a session mode of <code>CLIENT_ACKNOWLEDGE</code>, the message will not be |
| acknowledged until <code>acknowledge</code> is called on the <code>JMSContext</code>. If an application wishes to have the |
| failed message redelivered, it must call <code>recover</code> on the <code>JMSContext</code>. The redelivered message's |
| <code>JMSRedelivered</code> message header field will be set and its <code>JMSXDeliveryCount</code> message property will be |
| incremented.</li> |
| |
| <li>Transacted session: The Jakarta Messaging provider will behave as if the call to <code>receiveBody</code> had been successful and |
| will not deliver the message again. |
| |
| As with any message that is delivered in a transacted session, the transaction will remain uncommitted until the |
| transaction is committed or rolled back by the application. If an application wishes to have the failed message |
| redelivered, it must roll back the transaction. The redelivered message's <code>JMSRedelivered</code> message header field |
| will be set and its <code>JMSXDeliveryCount</code> message property will be incremented.</li> |
| </ul></div> |
| <dl> |
| <dt><span class="paramLabel">Type Parameters:</span></dt> |
| <dd><code>T</code> - The type of the message body</dd> |
| <dt><span class="paramLabel">Parameters:</span></dt> |
| <dd><code>c</code> - The type to which the body of the next message should be assigned.<br> |
| If the next message is expected to be a <code>TextMessage</code> then this should be set to <code>String.class</code> or |
| another class to which a <code>String</code> is assignable.<br> |
| If the next message is expected to be a <code>ObjectMessage</code> then this should be set to |
| <code>java.io.Serializable.class</code> or another class to which the body is assignable. <br> |
| If the next message is expected to be a <code>MapMessage</code> then this should be set to <code>java.util.Map.class</code> (or |
| <code>java.lang.Object.class</code>).<br> |
| If the next message is expected to be a <code>BytesMessage</code> then this should be set to <code>byte[].class</code> (or |
| <code>java.lang.Object.class</code>).<br></dd> |
| <dt><span class="returnLabel">Returns:</span></dt> |
| <dd>the body of the next message produced for this <code>JMSConsumer</code>, or null if this <code>JMSConsumer</code> is |
| concurrently closed</dd> |
| <dt><span class="throwsLabel">Throws:</span></dt> |
| <dd><code><a href="../../jakarta/jms/MessageFormatRuntimeException.html" title="class in jakarta.jms">MessageFormatRuntimeException</a></code> - <ul> |
| <li>if the message is not one of the supported types listed above |
| <li>if the message body cannot be assigned to the specified type |
| <li>if the message has no body |
| <li>if the message is an <code>ObjectMessage</code> and object deserialization fails. |
| </ul></dd> |
| <dd><code><a href="../../jakarta/jms/JMSRuntimeException.html" title="class in jakarta.jms">JMSRuntimeException</a></code> - if the Jakarta Messaging provider fails to receive the next message due to some internal error</dd> |
| </dl> |
| </li> |
| </ul> |
| <a name="receiveBody-java.lang.Class-long-"> |
| <!-- --> |
| </a> |
| <ul class="blockList"> |
| <li class="blockList"> |
| <h4>receiveBody</h4> |
| <pre><T> T receiveBody(java.lang.Class<T> c, |
| long timeout)</pre> |
| <div class="block">Receives the next message produced for this <code>JMSConsumer</code> that arrives within the specified timeout period and |
| returns its body as an object of the specified type. This method may be used to receive any type of message except |
| for <code>StreamMessage</code> and <code>Message</code>, so long as the message has a body which is capable of being assigned |
| to the specified type. This means that the specified class or interface must either be the same as, or a superclass |
| or superinterface of, the class of the message body. If the message is not one of the supported types, or its body |
| cannot be assigned to the specified type, or it has no body, then a <code>MessageFormatRuntimeException</code> is thrown. |
| |
| <p> |
| This method does not give access to the message headers or properties (such as the <code>JMSRedelivered</code> message |
| header field or the <code>JMSXDeliveryCount</code> message property) and should only be used if the application has no |
| need to access them. |
| |
| <p> |
| This call blocks until a message arrives, the timeout expires, or this <code>JMSConsumer</code> is closed. A timeout of |
| zero never expires, and the call blocks indefinitely. |
| |
| <p> |
| If this method is called within a transaction, the <code>JMSConsumer</code> retains the message until the transaction |
| commits. |
| |
| <p> |
| The result of this method throwing a <code>MessageFormatRuntimeException</code> depends on the session mode: |
| <ul> |
| <li><code>AUTO_ACKNOWLEDGE</code> or <code>DUPS_OK_ACKNOWLEDGE</code>: The Jakarta Messaging provider will behave as if the unsuccessful call |
| to <code>receiveBody</code> had not occurred. The message will be delivered again before any subsequent messages. |
| |
| This is not considered to be redelivery and does not cause the <code>JMSRedelivered</code> message header field to be set |
| or the <code>JMSXDeliveryCount</code> message property to be incremented.</li> |
| <li><code>CLIENT_ACKNOWLEDGE</code>: The Jakarta Messaging provider will behave as if the call to <code>receiveBody</code> had been |
| successful and will not deliver the message again. |
| |
| As with any message that is delivered with a session mode of <code>CLIENT_ACKNOWLEDGE</code>, the message will not be |
| acknowledged until <code>acknowledge</code> is called on the <code>JMSContext</code>. If an application wishes to have the |
| failed message redelivered, it must call <code>recover</code> on the <code>JMSContext</code>. The redelivered message's |
| <code>JMSRedelivered</code> message header field will be set and its <code>JMSXDeliveryCount</code> message property will be |
| incremented.</li> |
| |
| <li>Transacted session: The Jakarta Messaging provider will behave as if the call to <code>receiveBody</code> had been successful and |
| will not deliver the message again. |
| |
| As with any message that is delivered in a transacted session, the transaction will remain uncommitted until the |
| transaction is committed or rolled back by the application. If an application wishes to have the failed message |
| redelivered, it must roll back the transaction. The redelivered message's <code>JMSRedelivered</code> message header field |
| will be set and its <code>JMSXDeliveryCount</code> message property will be incremented.</li> |
| </ul></div> |
| <dl> |
| <dt><span class="paramLabel">Type Parameters:</span></dt> |
| <dd><code>T</code> - The message body type</dd> |
| <dt><span class="paramLabel">Parameters:</span></dt> |
| <dd><code>c</code> - The type to which the body of the next message should be assigned.<br> |
| If the next message is expected to be a <code>TextMessage</code> then this should be set to <code>String.class</code> or |
| another class to which a <code>String</code> is assignable.<br> |
| If the next message is expected to be a <code>ObjectMessage</code> then this should be set to |
| <code>java.io.Serializable.class</code> or another class to which the body is assignable. <br> |
| If the next message is expected to be a <code>MapMessage</code> then this should be set to <code>java.util.Map.class</code> (or |
| <code>java.lang.Object.class</code>).<br> |
| If the next message is expected to be a <code>BytesMessage</code> then this should be set to <code>byte[].class</code> (or |
| <code>java.lang.Object.class</code>).</dd> |
| <dd><code>timeout</code> - The maximum amount of time this method blocks. Zero means blocking indefinitely.</dd> |
| <dt><span class="returnLabel">Returns:</span></dt> |
| <dd>the body of the next message produced for this <code>JMSConsumer</code>, or null if the timeout expires or this |
| <code>JMSConsumer</code> is concurrently closed</dd> |
| <dt><span class="throwsLabel">Throws:</span></dt> |
| <dd><code><a href="../../jakarta/jms/MessageFormatRuntimeException.html" title="class in jakarta.jms">MessageFormatRuntimeException</a></code> - <ul> |
| <li>if the message is not one of the supported types listed above |
| <li>if the message body cannot be assigned to the specified type |
| <li>if the message has no body |
| <li>if the message is an <code>ObjectMessage</code> and object deserialization fails. |
| </ul></dd> |
| <dd><code><a href="../../jakarta/jms/JMSRuntimeException.html" title="class in jakarta.jms">JMSRuntimeException</a></code> - if the Jakarta Messaging provider fails to receive the next message due to some internal error</dd> |
| </dl> |
| </li> |
| </ul> |
| <a name="receiveBodyNoWait-java.lang.Class-"> |
| <!-- --> |
| </a> |
| <ul class="blockListLast"> |
| <li class="blockList"> |
| <h4>receiveBodyNoWait</h4> |
| <pre><T> T receiveBodyNoWait(java.lang.Class<T> c)</pre> |
| <div class="block">Receives the next message produced for this <code>JMSConsumer</code> if one is immediately available and returns its body |
| as an object of the specified type. This method may be used to receive any type of message except for |
| <code>StreamMessage</code> and <code>Message</code>, so long as the message has a body which is capable of being assigned to |
| the specified type. This means that the specified class or interface must either be the same as, or a superclass or |
| superinterface of, the class of the message body. If the message is not one of the supported types, or its body |
| cannot be assigned to the specified type, or it has no body, then a <code>MessageFormatRuntimeException</code> is thrown. |
| <p> |
| This method does not give access to the message headers or properties (such as the <code>JMSRedelivered</code> message |
| header field or the <code>JMSXDeliveryCount</code> message property) and should only be used if the application has no |
| need to access them. |
| |
| <p> |
| If a message is not immediately available null is returned. |
| |
| <p> |
| If this method is called within a transaction, the <code>JMSConsumer</code> retains the message until the transaction |
| commits. |
| |
| <p> |
| The result of this method throwing a <code>MessageFormatRuntimeException</code> depends on the session mode: |
| <ul> |
| <li><code>AUTO_ACKNOWLEDGE</code> or <code>DUPS_OK_ACKNOWLEDGE</code>: The Jakarta Messaging provider will behave as if the unsuccessful call |
| to <code>receiveBodyNoWait</code> had not occurred. The message will be delivered again before any subsequent messages. |
| |
| This is not considered to be redelivery and does not cause the <code>JMSRedelivered</code> message header field to be set |
| or the <code>JMSXDeliveryCount</code> message property to be incremented.</li> |
| <li><code>CLIENT_ACKNOWLEDGE</code>: The Jakarta Messaging provider will behave as if the call to <code>receiveBodyNoWait</code> had been |
| successful and will not deliver the message again. |
| |
| As with any message that is delivered with a session mode of <code>CLIENT_ACKNOWLEDGE</code>, the message will not be |
| acknowledged until <code>acknowledge</code> is called on the <code>JMSContext</code>. If an application wishes to have the |
| failed message redelivered, it must call <code>recover</code> on the <code>JMSContext</code>. The redelivered message's |
| <code>JMSRedelivered</code> message header field will be set and its <code>JMSXDeliveryCount</code> message property will be |
| incremented.</li> |
| |
| <li>Transacted session: The Jakarta Messaging provider will behave as if the call to <code>receiveBodyNoWait</code> had been successful |
| and will not deliver the message again. |
| |
| As with any message that is delivered in a transacted session, the transaction will remain uncommitted until the |
| transaction is committed or rolled back by the application. If an application wishes to have the failed message |
| redelivered, it must roll back the transaction. The redelivered message's <code>JMSRedelivered</code> message header field |
| will be set and its <code>JMSXDeliveryCount</code> message property will be incremented.</li> |
| </ul></div> |
| <dl> |
| <dt><span class="paramLabel">Type Parameters:</span></dt> |
| <dd><code>T</code> - The type of the message body</dd> |
| <dt><span class="paramLabel">Parameters:</span></dt> |
| <dd><code>c</code> - The type to which the body of the next message should be assigned.<br> |
| If the next message is expected to be a <code>TextMessage</code> then this should be set to <code>String.class</code> or |
| another class to which a <code>String</code> is assignable.<br> |
| If the next message is expected to be a <code>ObjectMessage</code> then this should be set to |
| <code>java.io.Serializable.class</code> or another class to which the body is assignable. <br> |
| If the next message is expected to be a <code>MapMessage</code> then this should be set to <code>java.util.Map.class</code> (or |
| <code>java.lang.Object.class</code>).<br> |
| If the next message is expected to be a <code>BytesMessage</code> then this should be set to <code>byte[].class</code> (or |
| <code>java.lang.Object.class</code>).<br></dd> |
| <dt><span class="returnLabel">Returns:</span></dt> |
| <dd>the body of the next message produced for this <code>JMSConsumer</code>, or null if one is not immediately |
| available or this <code>JMSConsumer</code> is concurrently closed</dd> |
| <dt><span class="throwsLabel">Throws:</span></dt> |
| <dd><code><a href="../../jakarta/jms/MessageFormatRuntimeException.html" title="class in jakarta.jms">MessageFormatRuntimeException</a></code> - <ul> |
| <li>if the message is not one of the supported types listed above |
| <li>if the message body cannot be assigned to the specified type |
| <li>if the message has no body |
| <li>if the message is an <code>ObjectMessage</code> and object deserialization fails. |
| </ul></dd> |
| <dd><code><a href="../../jakarta/jms/JMSRuntimeException.html" title="class in jakarta.jms">JMSRuntimeException</a></code> - if the Jakarta Messaging provider fails to receive the next message due to some internal error</dd> |
| </dl> |
| </li> |
| </ul> |
| </li> |
| </ul> |
| </li> |
| </ul> |
| </div> |
| </div> |
| <!-- ========= END OF CLASS DATA ========= --> |
| <!-- ======= START OF BOTTOM NAVBAR ====== --> |
| <div class="bottomNav"><a name="navbar.bottom"> |
| <!-- --> |
| </a> |
| <div class="skipNav"><a href="#skip.navbar.bottom" title="Skip navigation links">Skip navigation links</a></div> |
| <a name="navbar.bottom.firstrow"> |
| <!-- --> |
| </a> |
| <ul class="navList" title="Navigation"> |
| <li><a href="../../overview-summary.html">Overview</a></li> |
| <li><a href="package-summary.html">Package</a></li> |
| <li class="navBarCell1Rev">Class</li> |
| <li><a href="package-tree.html">Tree</a></li> |
| <li><a href="../../deprecated-list.html">Deprecated</a></li> |
| <li><a href="../../index-all.html">Index</a></li> |
| <li><a href="../../help-doc.html">Help</a></li> |
| </ul> |
| </div> |
| <div class="subNav"> |
| <ul class="navList"> |
| <li><a href="../../jakarta/jms/JMSConnectionFactoryDefinitions.html" title="annotation in jakarta.jms"><span class="typeNameLink">Prev Class</span></a></li> |
| <li><a href="../../jakarta/jms/JMSContext.html" title="interface in jakarta.jms"><span class="typeNameLink">Next Class</span></a></li> |
| </ul> |
| <ul class="navList"> |
| <li><a href="../../index.html?jakarta/jms/JMSConsumer.html" target="_top">Frames</a></li> |
| <li><a href="JMSConsumer.html" target="_top">No Frames</a></li> |
| </ul> |
| <ul class="navList" id="allclasses_navbar_bottom"> |
| <li><a href="../../allclasses-noframe.html">All Classes</a></li> |
| </ul> |
| <div> |
| <script type="text/javascript"><!-- |
| allClassesLink = document.getElementById("allclasses_navbar_bottom"); |
| if(window==top) { |
| allClassesLink.style.display = "block"; |
| } |
| else { |
| allClassesLink.style.display = "none"; |
| } |
| //--> |
| </script> |
| </div> |
| <div> |
| <ul class="subNavList"> |
| <li>Summary: </li> |
| <li>Nested | </li> |
| <li>Field | </li> |
| <li>Constr | </li> |
| <li><a href="#method.summary">Method</a></li> |
| </ul> |
| <ul class="subNavList"> |
| <li>Detail: </li> |
| <li>Field | </li> |
| <li>Constr | </li> |
| <li><a href="#method.detail">Method</a></li> |
| </ul> |
| </div> |
| <a name="skip.navbar.bottom"> |
| <!-- --> |
| </a></div> |
| <!-- ======== END OF BOTTOM NAVBAR ======= --> |
| </body> |
| </html> |