1 2 3 4 5 6 7 8 9 10 11 12 13 14 15 16 17 18 19 20 21 22 23 24 25 26 27 28 29 30 31 32 33 34 35 36 37 38 39 40 41 42 43 44 45 46 47 48 49 50 51 52 53 54 55 56 57 58 59 60 61 62 63 64 65 66 67 68 69 70 71 72 73 74 75 76 77 78 79 80 81 82 83 84 85 86 87 88 89 90 91 92 93 94 95 96 97 98 99 100 101 102 103 104 105 106 107 108 109 110 111 112 113 114 115 116 117 118 119 120 121 122 123 124 125 126 127 128 129 130 131 132 133 134 135 136 137 138 139 140 141 142 143 144 145 146 147 148 149 150 151 152 153 154 155 156 157 158 159 160 161 162 163 164 165 166 167 168 169 170 171 172 173 174 175 176 177 178 179 180 181 182 183 184 185 186 187 188 189 190 191 192 193 194 195 196 197 198
|
<!--
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.
-->
<!DOCTYPE HTML PUBLIC "-//W3C//DTD HTML 4.01 Transitional//EN">
<html>
<head>
<meta http-equiv="Content-Type" content="text/html;charset=UTF-8">
<title>qpid::client::MessageListener Class Reference</title>
<link href="doxygen.css" rel="stylesheet" type="text/css">
<link href="tabs.css" rel="stylesheet" type="text/css">
</head>
<body bgcolor="#FFFFFF">
<table border="0" width="90%" align="center">
<tr>
<td align="left">
<a title="Apache Qpid Project Page" href="http://qpid.apache.org">Apache Qpid - AMQP Messaging for Java JMS, C++, Python, Ruby, and .NET</a>
</td>
<td align="right">
<a title="Apache Qpid Documentation" href="http://qpid.apache.org/documentation.html">Apache Qpid Documentation</a>
</td>
</tr>
</table>
<!-- Generated by Doxygen 1.7.5 -->
<div id="navrow1" class="tabs">
<ul class="tablist">
<li><a href="index.html"><span>Main Page</span></a></li>
<li><a href="modules.html"><span>Modules</span></a></li>
<li><a href="namespaces.html"><span>Namespaces</span></a></li>
<li class="current"><a href="annotated.html"><span>Classes</span></a></li>
<li><a href="files.html"><span>Files</span></a></li>
</ul>
</div>
<div id="navrow2" class="tabs2">
<ul class="tablist">
<li><a href="annotated.html"><span>Class List</span></a></li>
<li><a href="classes.html"><span>Class Index</span></a></li>
<li><a href="hierarchy.html"><span>Class Hierarchy</span></a></li>
<li><a href="functions.html"><span>Class Members</span></a></li>
</ul>
</div>
<div id="nav-path" class="navpath">
<ul>
<li class="navelem"><a class="el" href="a00574.html">qpid</a> </li>
<li class="navelem"><a class="el" href="a00576.html">client</a> </li>
<li class="navelem"><a class="el" href="a00209.html">MessageListener</a> </li>
</ul>
</div>
</div>
<div class="header">
<div class="summary">
<a href="#pub-methods">Public Member Functions</a> </div>
<div class="headertitle">
<div class="title">qpid::client::MessageListener Class Reference</div> </div>
</div>
<div class="contents">
<!-- doxytag: class="qpid::client::MessageListener" -->
<p>Implement a subclass of <a class="el" href="a00209.html" title="Implement a subclass of MessageListener and subscribe it using the SubscriptionManager to receive mes...">MessageListener</a> and subscribe it using the <a class="el" href="a00352.html" title="A class to help create and manage subscriptions.">SubscriptionManager</a> to receive messages.
<a href="a00209.html#details">More...</a></p>
<p><code>#include <<a class="el" href="a00471_source.html">qpid/client/MessageListener.h</a>></code></p>
<p><a href="a00692.html">List of all members.</a></p>
<table class="memberdecls">
<tr><td colspan="2"><h2><a name="pub-methods"></a>
Public Member Functions</h2></td></tr>
<tr><td class="memItemLeft" align="right" valign="top">virtual </td><td class="memItemRight" valign="bottom"><a class="el" href="a00209.html#a2ac4beffe6e0dfab7a7f4d369ce6bacc">~MessageListener</a> ()</td></tr>
<tr><td class="memItemLeft" align="right" valign="top">virtual void </td><td class="memItemRight" valign="bottom"><a class="el" href="a00209.html#a7bfa631fe7a244304eaeb1fa8a23dd25">received</a> (<a class="el" href="a00206.html">Message</a> &msg)=0</td></tr>
<tr><td class="mdescLeft"> </td><td class="mdescRight">Called for each message arriving from the broker. <a href="#a7bfa631fe7a244304eaeb1fa8a23dd25"></a><br/></td></tr>
</table>
<hr/><a name="details" id="details"></a><h2>Detailed Description</h2>
<div class="textblock"><p>Implement a subclass of <a class="el" href="a00209.html" title="Implement a subclass of MessageListener and subscribe it using the SubscriptionManager to receive mes...">MessageListener</a> and subscribe it using the <a class="el" href="a00352.html" title="A class to help create and manage subscriptions.">SubscriptionManager</a> to receive messages. </p>
<p>Another way to receive messages is by using a <a class="el" href="a00193.html" title="A local queue to collect messages retrieved from a remote broker queue.">LocalQueue</a>.</p>
<h2>Using a <a class="el" href="a00209.html" title="Implement a subclass of MessageListener and subscribe it using the SubscriptionManager to receive mes...">MessageListener</a></h2>
<ul>
<li>
<p class="startli"></p>
<p class="endli">The <a class="el" href="a00209.html#a7bfa631fe7a244304eaeb1fa8a23dd25" title="Called for each message arriving from the broker.">received()</a> function is called when a message arrives: </p>
<pre>virtual void received(<a class="el" href="a00206.html" title="A message sent to or received from the broker.">Message</a>& message)=0;</pre> </li>
<li>
<p class="startli"></p>
<p>Derive your own listener, implement the <a class="el" href="a00209.html#a7bfa631fe7a244304eaeb1fa8a23dd25" title="Called for each message arriving from the broker.">received()</a> function: </p>
<pre>
class Listener : public <a class="el" href="a00209.html" title="Implement a subclass of MessageListener and subscribe it using the SubscriptionManager to receive mes...">MessageListener</a> {
private:
<a class="el" href="a00352.html" title="A class to help create and manage subscriptions.">SubscriptionManager</a>& subscriptions;
public:
Listener(<a class="el" href="a00352.html" title="A class to help create and manage subscriptions.">SubscriptionManager</a>& subscriptions);
virtual void received(<a class="el" href="a00206.html" title="A message sent to or received from the broker.">Message</a>& message);
};</pre><pre> Listener::Listener(<a class="el" href="a00352.html" title="A class to help create and manage subscriptions.">SubscriptionManager</a>& subs) : subscriptions(subs)
{}</pre><pre> void Listener::received(<a class="el" href="a00206.html" title="A message sent to or received from the broker.">Message</a>& message) {
std::cout << "Message: " << message.getData() << std::endl;
if (message.getData() == "That's all, folks!") {
std::cout << "Shutting down listener for " << message.getDestination()
<< std::endl;
subscriptions.cancel(message.getDestination());
}
}
</pre> <pre>
<a class="el" href="a00352.html" title="A class to help create and manage subscriptions.">SubscriptionManager</a> subscriptions(session);</pre><pre> // Create a listener and subscribe it to the queue named "message_queue"
Listener listener(subscriptions);
subscriptions.subscribe(listener, "message_queue");</pre><pre> // Receive messages until the subscription is cancelled
// by Listener::received()
subscriptions.run();
</pre> </li>
</ul>
</div><hr/><h2>Constructor & Destructor Documentation</h2>
<a class="anchor" id="a2ac4beffe6e0dfab7a7f4d369ce6bacc"></a><!-- doxytag: member="qpid::client::MessageListener::~MessageListener" ref="a2ac4beffe6e0dfab7a7f4d369ce6bacc" args="()" -->
<div class="memitem">
<div class="memproto">
<table class="memname">
<tr>
<td class="memname">virtual qpid::client::MessageListener::~MessageListener </td>
<td>(</td>
<td class="paramname"></td><td>)</td>
<td><code> [virtual]</code></td>
</tr>
</table>
</div>
<div class="memdoc">
</div>
</div>
<hr/><h2>Member Function Documentation</h2>
<a class="anchor" id="a7bfa631fe7a244304eaeb1fa8a23dd25"></a><!-- doxytag: member="qpid::client::MessageListener::received" ref="a7bfa631fe7a244304eaeb1fa8a23dd25" args="(Message &msg)=0" -->
<div class="memitem">
<div class="memproto">
<table class="memname">
<tr>
<td class="memname">virtual void qpid::client::MessageListener::received </td>
<td>(</td>
<td class="paramtype"><a class="el" href="a00206.html">Message</a> & </td>
<td class="paramname"><em>msg</em></td><td>)</td>
<td><code> [pure virtual]</code></td>
</tr>
</table>
</div>
<div class="memdoc">
<p>Called for each message arriving from the broker. </p>
<p>Override in your own subclass to process messages. </p>
</div>
</div>
<hr/>The documentation for this class was generated from the following file:<ul>
<li>qpid/client/<a class="el" href="a00471_source.html">MessageListener.h</a></li>
</ul>
</div>
<!--
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.
-->
<hr size="1">
<address style="text-align: left;"><small>
Qpid C++ API Reference</small></address>
<address style="text-align: right;">
<small>
Generated on Thu May 10 2012 for Qpid C++ Client API by <a href="http://www.doxygen.org/index.html"><img src="doxygen.png" alt="doxygen" align="middle" border="0"></a> 1.7.5</small>
</address>
</body>
</html>
|