| <!DOCTYPE html> |
| <!-- |
| - |
| - Licensed to the Apache Software Foundation (ASF) under one |
| - or more contributor license agreements. See the NOTICE file |
| - distributed with this work for additional information |
| - regarding copyright ownership. The ASF licenses this file |
| - to you under the Apache License, Version 2.0 (the |
| - "License"); you may not use this file except in compliance |
| - with the License. You may obtain a copy of the License at |
| - |
| - http://www.apache.org/licenses/LICENSE-2.0 |
| - |
| - Unless required by applicable law or agreed to in writing, |
| - software distributed under the License is distributed on an |
| - "AS IS" BASIS, WITHOUT WARRANTIES OR CONDITIONS OF ANY |
| - KIND, either express or implied. See the License for the |
| - specific language governing permissions and limitations |
| - under the License. |
| - |
| --> |
| <html xmlns="http://www.w3.org/1999/xhtml" xml:lang="en"> |
| <head> |
| <title>5.5. MessageProducer - Apache Qpid™</title> |
| <meta http-equiv="X-UA-Compatible" content="IE=edge"/> |
| <meta name="viewport" content="width=device-width, initial-scale=1.0"/> |
| <link rel="stylesheet" href="/site.css" type="text/css" async="async"/> |
| <link rel="stylesheet" href="/deferred.css" type="text/css" defer="defer"/> |
| <script type="text/javascript">var _deferredFunctions = [];</script> |
| <script type="text/javascript" src="/deferred.js" defer="defer"></script> |
| <!--[if lte IE 8]> |
| <link rel="stylesheet" href="/ie.css" type="text/css"/> |
| <script type="text/javascript" src="/html5shiv.js"></script> |
| <![endif]--> |
| |
| <!-- Redirects for `go get` and godoc.org --> |
| <meta name="go-import" |
| content="qpid.apache.org git https://git-wip-us.apache.org/repos/asf/qpid-proton.git"/> |
| <meta name="go-source" |
| content="qpid.apache.org |
| https://github.com/apache/qpid-proton/blob/go1/README.md |
| https://github.com/apache/qpid-proton/tree/go1{/dir} |
| https://github.com/apache/qpid-proton/blob/go1{/dir}/{file}#L{line}"/> |
| </head> |
| <body> |
| <div id="-content"> |
| <div id="-top" class="panel"> |
| <a id="-menu-link"><img width="16" height="16" src="" alt="Menu"/></a> |
| |
| <a id="-search-link"><img width="22" height="16" src="" alt="Search"/></a> |
| |
| <ul id="-global-navigation"> |
| <li><a id="-logotype" href="/index.html">Apache Qpid<sup>™</sup></a></li> |
| <li><a href="/documentation.html">Documentation</a></li> |
| <li><a href="/download.html">Download</a></li> |
| <li><a href="/discussion.html">Discussion</a></li> |
| </ul> |
| </div> |
| |
| <div id="-menu" class="panel" style="display: none;"> |
| <div class="flex"> |
| <section> |
| <h3>Project</h3> |
| |
| <ul> |
| <li><a href="/overview.html">Overview</a></li> |
| <li><a href="/components/index.html">Components</a></li> |
| <li><a href="/releases/index.html">Releases</a></li> |
| </ul> |
| </section> |
| |
| <section> |
| <h3>Messaging APIs</h3> |
| |
| <ul> |
| <li><a href="/proton/index.html">Qpid Proton</a></li> |
| <li><a href="/components/jms/index.html">Qpid JMS</a></li> |
| <li><a href="/components/messaging-api/index.html">Qpid Messaging API</a></li> |
| </ul> |
| </section> |
| |
| <section> |
| <h3>Servers and tools</h3> |
| |
| <ul> |
| <li><a href="/components/broker-j/index.html">Broker-J</a></li> |
| <li><a href="/components/cpp-broker/index.html">C++ broker</a></li> |
| <li><a href="/components/dispatch-router/index.html">Dispatch router</a></li> |
| </ul> |
| </section> |
| |
| <section> |
| <h3>Resources</h3> |
| |
| <ul> |
| <li><a href="/dashboard.html">Dashboard</a></li> |
| <li><a href="https://cwiki.apache.org/confluence/display/qpid/Index">Wiki</a></li> |
| <li><a href="/resources.html">More resources</a></li> |
| </ul> |
| </section> |
| </div> |
| </div> |
| |
| <div id="-search" class="panel" style="display: none;"> |
| <form action="http://www.google.com/search" method="get"> |
| <input type="hidden" name="sitesearch" value="qpid.apache.org"/> |
| <input type="text" name="q" maxlength="255" autofocus="autofocus" tabindex="1"/> |
| <button type="submit">Search</button> |
| <a href="/search.html">More ways to search</a> |
| </form> |
| </div> |
| |
| <div id="-middle" class="panel"> |
| <ul id="-path-navigation"><li><a href="/index.html">Home</a></li><li><a href="/releases/index.html">Releases</a></li><li><a href="/releases/qpid-jms-amqp-0-x-6.3.1/index.html">Qpid JMS AMQP 0-x 6.3.1</a></li><li><a href="/releases/qpid-jms-amqp-0-x-6.3.1/jms-amqp-0-8-book/index.html">Apache Qpid JMS AMQP 0-8/0-9/0-9-1</a></li><li>5.5. MessageProducer</li></ul> |
| |
| <div id="-middle-content"> |
| <div class="docbook"><div class="navheader"><table summary="Navigation header" width="100%"><tr><th align="center" colspan="3">5.5. MessageProducer</th></tr><tr><td align="left" width="20%"><a accesskey="p" href="JMS-Client-0-8-Client-Understanding-Session.html">Prev</a> </td><th align="center" width="60%">Chapter 5. Understanding the Client</th><td align="right" width="20%"> <a accesskey="n" href="JMS-Client-0-8-Client-Understanding-MessageConsumer.html">Next</a></td></tr></table><hr /></div><div class="section"><div class="titlepage"><div><div><h2 class="title" style="clear: both"><a id="JMS-Client-0-8-Client-Understanding-MessageProducer"></a>5.5. MessageProducer</h2></div></div></div><p>A MessageProducer sends a message an <span class="emphasis"><em>Exchange</em></span>. It is the Exchange |
| (within the Broker) that routes the message to zero or more queue(s). Routing is performed |
| according to rules expressed as <span class="emphasis"><em>bindings</em></span> between the exchange and queues |
| and a <span class="emphasis"><em>routing key</em></span> included with each message.</p><p>To understand how this mechanism is used to deliver messages to queues and topics, see |
| <a class="link" href="../../java-broker/book/Java-Broker-Concepts-Exchanges.html" target="_top">Exchanges</a> |
| within the Apache Qpid Broker-J book.</p><p>It is important to understand that when synchronous publish is not exlicitly enabled, |
| <a class="link" href="http://docs.oracle.com/javaee/6/api/javax/jms/MessageProducer.html#send(javax.jms.Message)" target="_top">MessageProducer#send()</a> is <span class="emphasis"><em>asynchronous</em></span> in nature. When #send() |
| returns to the application, the application cannot be certain if the Broker has received the |
| message. The Client may not have yet started to send the message, the message could |
| residing in a TCP/IP buffer, or the messages could be in some intermediate buffer within the |
| Broker. If the application requires certainty the message has been received by the Broker, a |
| <a class="link" href="http://docs.oracle.com/javaee/6/api/javax/jms/Session.html#SESSION_TRANSACTED" target="_top">transactional |
| session</a> |
| <span class="emphasis"><em>must</em></span> be used, or synchronous publishing must be enabled using either the |
| <a class="link" href="JMS-Client-0-8-System-Properties.html#JMS-Client-0-8-System-Properties-SyncPublish">system property</a> or the |
| <a class="link" href="JMS-Client-0-8-Connection-URL.html#JMS-Client-0-8-Connection-URL-ConnectionOptions-SyncPublish">connection URL |
| option</a>.</p><p>Qpid JMS MessageProducers have a number of features above that required by JMS. These are |
| described in the sub-sections that follow.</p><div class="section"><div class="titlepage"><div><div><h3 class="title"><a id="JMS-Client-0-8-Client-Understanding-MessageProducer-MandatoryMessage"></a>5.5.1. Mandatory Messages</h3></div></div></div><p>With this feature, publishing a message with a routing key for which no binding exists |
| on the exchange will result in the message being returned to the publisher's |
| connection.</p><p>The Message is returned to the application in an asynchronous fashion via the |
| Connection's <a class="link" href="http://docs.oracle.com/javaee/6/api/javax/jms/ExceptionListener.html" target="_top">ExceptionListener</a>. When a message is returned, it will be invoked with a |
| JMSException whose linked exception is an <a class="link" href="JMS-Client-0-8-Appendix-Exceptions-AMQNoRouteException" target="_top">AMQNoRouteException</a>. |
| The returned message is available to the application by calling |
| AMQNoRouteException#getUndeliveredMessage(). The ExceptionListener will be invoked exactly |
| once for each returned message.</p><p>If synchronous publishing has been enabled, and a mandatory message is returned, the |
| <a class="link" href="http://docs.oracle.com/javaee/6/api/javax/jms/MessageProducer.html#send(javax.jms.Message)" target="_top">MessageProducer#send()</a> method will throw a JMSException. |
| </p><p>The mandatory message feature is turned <span class="emphasis"><em>on</em></span> by default for Queue |
| destinations and <span class="emphasis"><em>off</em></span> for Topic destinations. This can be overridden |
| using system properties <a class="link" href="JMS-Client-0-8-System-Properties.html#JMS-Client-0-8-System-Properties-DefaultMandatory"><code class="literal">qpid.default_mandatory</code></a> and <a class="link" href="JMS-Client-0-8-System-Properties.html#JMS-Client-0-8-System-Properties-DefaultMandatoryTopic"><code class="literal">qpid.default_mandatory_topic</code></a> for Queues and Topics |
| respectively.</p><div class="note" style="margin-left: 0.5in; margin-right: 0.5in;"><h3 class="title">Note</h3><p>If this the mandatory flag is not set, the Broker will treat <a class="link" href="../../java-broker/book/Java-Broker-Concepts-Exchanges.html#Java-Broker-Concepts-Exchanges-UnroutableMessage" target="_top">the messages as unroutable</a>.</p></div></div><div class="section"><div class="titlepage"><div><div><h3 class="title"><a id="JMS-Client-0-8-Client-Understanding-MessageProducer-CloseWhenNoRoute"></a>5.5.2. Close When No Route</h3></div></div></div><p>With this feature, if a mandatory message is published with a routing key for which no |
| binding exists on the exchange the Broker will close the connection. This client feature |
| requires support for the corresponding feature by the Broker.</p><p>To enable or disable from the client, use the Connection URL option <a class="link" href="JMS-Client-0-8-Connection-URL.html#JMS-Client-0-8-Connection-URL-ConnectionOptions-CloseWhenNoRoute"><code class="literal">closeWhenNoRoute</code></a>.</p><p>See <a class="link" href="../../java-broker/book/Java-Broker-Runtime-Close-Connection-When-No-Route.html" target="_top"> |
| Closing client connections on unroutable mandatory messages</a> within the Apache Qpid Broker-J |
| book for full details of the functioning of this feature.</p></div><div class="section"><div class="titlepage"><div><div><h3 class="title"><a id="JMS-Client-0-8-Client-Understanding-MessageProducer-ImmediateMessage"></a>5.5.3. Immediate Messages</h3></div></div></div><p>This feature is defined in <a class="link" href="http://www.amqp.org" target="_top">AMQP specifications</a>.</p><p>When this feature is enabled, when publishing a message the Broker ensures that a |
| Consumer is attached to queue. If there is no Consumer attached to the queue, the message is |
| returned to the publisher's connection. The Message is returned to the application in an |
| asynchronous fashion using the Connection's <a class="link" href="http://docs.oracle.com/javaee/6/api/javax/jms/ExceptionListener.html" target="_top">ExceptionListener</a>.</p><p>The ExceptionListener will be invoked with a JMSException whose linked exception is an |
| <a class="link" href="JMS-Client-0-8-Appendix-Exceptions-AMQNoConsumersException" target="_top">AMQNoConsumersException</a>. The returned message is available to the application by |
| calling AMQNoConsumersException#getUndeliveredMessage(). The ExceptionListener will be |
| invoked exactly once for each returned message.</p><p>If synchronous publishing has been enabled, and an immediate message is returned, the |
| <a class="link" href="http://docs.oracle.com/javaee/6/api/javax/jms/MessageProducer.html#send(javax.jms.Message)" target="_top">MessageProducer#send()</a> method will throw a JMSException. |
| </p><p>The immediate message feature is turned <span class="emphasis"><em>off</em></span> by default. It can be |
| enabled with system property <a class="link" href="JMS-Client-0-8-System-Properties.html#JMS-Client-0-8-System-Properties-DefaultImmediate"><code class="literal">qpid.default_immediate</code></a>.</p></div><div class="section"><div class="titlepage"><div><div><h3 class="title"><a id="JMS-Client-0-8-Client-Understanding-MessageProducer-FlowControl"></a>5.5.4. Flow Control</h3></div></div></div><p>With this feature, if a message is sent to a queue that is overflow, the producer's |
| session is blocked until the queue becomes underfull, or a timeout expires. This client |
| feature requires support for the corresponding feature by the Broker.</p><p>To control the timeout use System property <a class="link" href="JMS-Client-0-8-System-Properties.html#JMS-Client-0-8-System-Properties-FlowControlWaitFailure"><code class="literal">qpid.flow_control_wait_failure</code></a>. To control the frequency with |
| which warnings are logged whilst a Session is blocked, use System property <a class="link" href="JMS-Client-0-8-System-Properties.html#JMS-Client-0-8-System-Properties-FlowControlWaitNotifyPeriod"><code class="literal">qpid.flow_control_wait_notify_period</code></a></p><p>See <a class="link" href="../../java-broker/book/Java-Broker-Runtime-Disk-Space-Management.html#Qpid-Producer-Flow-Control" target="_top"> Producer Flow Control</a> within the Apache Qpid Broker-Java book for full details of the |
| functioning of this feature.</p></div></div><div class="navfooter"><hr /><table summary="Navigation footer" width="100%"><tr><td align="left" width="40%"><a accesskey="p" href="JMS-Client-0-8-Client-Understanding-Session.html">Prev</a> </td><td align="center" width="20%"><a accesskey="u" href="JMS-Client-0-8-Client-Understanding.html">Up</a></td><td align="right" width="40%"> <a accesskey="n" href="JMS-Client-0-8-Client-Understanding-MessageConsumer.html">Next</a></td></tr><tr><td align="left" valign="top" width="40%">5.4. Session </td><td align="center" width="20%"><a accesskey="h" href="JMS-Client-Book.html">Home</a></td><td align="right" valign="top" width="40%"> 5.6. MessageConsumer</td></tr></table></div></div> |
| |
| <hr/> |
| |
| <ul id="-apache-navigation"> |
| <li><a href="http://www.apache.org/">Apache</a></li> |
| <li><a href="http://www.apache.org/licenses/">License</a></li> |
| <li><a href="http://www.apache.org/foundation/sponsorship.html">Sponsorship</a></li> |
| <li><a href="http://www.apache.org/foundation/thanks.html">Thanks!</a></li> |
| <li><a href="/security.html">Security</a></li> |
| <li><a href="http://www.apache.org/"><img id="-apache-feather" width="48" height="14" src="" alt="Apache"/></a></li> |
| </ul> |
| |
| <p id="-legal"> |
| Apache Qpid, Messaging built on AMQP; Copyright © 2015 |
| The Apache Software Foundation; Licensed under |
| the <a href="http://www.apache.org/licenses/LICENSE-2.0">Apache |
| License, Version 2.0</a>; Apache Qpid, Qpid, Qpid Proton, |
| Proton, Apache, the Apache feather logo, and the Apache Qpid |
| project logo are trademarks of The Apache Software |
| Foundation; All other marks mentioned may be trademarks or |
| registered trademarks of their respective owners |
| </p> |
| </div> |
| </div> |
| </div> |
| </body> |
| </html> |