Alan
This isn't functional, but it starts to fill in the handler stubs - look
it over to make sure it's in the correct direction
Andrew
==== Patch <InitialStubFilling> level 2
Source: 8427bd24-ae5a-4eba-a324-d2fc9c9c6c77:/local/qpid.0-9.ams:800
Target: 13f79535-47bb-0310-9956-ffa450edef68:/incubator/qpid/branches/qpid.0-9:496926
(http://svn.apache.org/repos/asf/incubator/qpid/branches/qpid.0-9)
Log:
[EMAIL PROTECTED]: andrew | 2007-01-12 00:35:16 +0000
Branch for my work on Qpid.0-9
[EMAIL PROTECTED]: andrew | 2007-01-12 00:59:28 +0000
Added in empty implementation of handler class for protocol Message class
[EMAIL PROTECTED]: andrew | 2007-01-17 01:25:16 +0000
* Added Test for new MessageHandlerImpl (but no actual tests yet)
* Filled in lots of the blanks in the MessageHandlerImpl with code
stolen from the BasicHandlerImpl
[EMAIL PROTECTED]: andrew | 2007-01-17 17:34:13 +0000
Updated to latest upstream changes
=== cpp/tests/MessageHandlerTest.cpp
==================================================================
--- cpp/tests/MessageHandlerTest.cpp (revision 496926)
+++ cpp/tests/MessageHandlerTest.cpp (patch InitialStubFilling level 2)
@@ -0,0 +1,57 @@
+/*
+ *
+ * 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.
+ *
+ */
+//#include <iostream>
+//#include <AMQP_HighestVersion.h>
+#include <amqp_framing.h>
+#include <qpid_test_plugin.h>
+
+#include <BrokerAdapter.h>
+
+using namespace qpid::framing;
+using namespace qpid::broker;
+
+class MessageHandlerTest : public CppUnit::TestCase
+{
+ CPPUNIT_TEST_SUITE(MessageHandlerTest);
+ CPPUNIT_TEST(testOpenMethod);
+ CPPUNIT_TEST_SUITE_END();
+private:
+
+public:
+
+ MessageHandlerTest()
+ {
+ }
+
+ void testOpenMethod()
+ {
+ //AMQFrame frame(highestProtocolVersion, 0, method);
+ //TestBodyHandler handler(method);
+ //handler.handleBody(frame.getBody());
+ }
+
+};
+
+
+// Make this test suite a plugin.
+CPPUNIT_PLUGIN_IMPLEMENT();
+CPPUNIT_TEST_SUITE_REGISTRATION(MessageHandlerTest);
+
=== cpp/tests/Makefile.am
==================================================================
--- cpp/tests/Makefile.am (revision 496926)
+++ cpp/tests/Makefile.am (patch InitialStubFilling level 2)
@@ -30,6 +30,7 @@
InMemoryContentTest \
LazyLoadedContentTest \
MessageBuilderTest \
+ MessageHandlerTest \
MessageTest \
QueueRegistryTest \
QueueTest \
=== cpp/lib/broker/BrokerAdapter.cpp
==================================================================
--- cpp/lib/broker/BrokerAdapter.cpp (revision 496926)
+++ cpp/lib/broker/BrokerAdapter.cpp (patch InitialStubFilling level 2)
@@ -393,7 +393,9 @@
assert(0); // FIXME aconway 2007-01-04: 0-9 feature
}
+//
// Message class method handlers
+//
void
BrokerAdapter::MessageHandlerImpl::append( u_int16_t /*channel*/,
const string& /*reference*/,
@@ -404,10 +406,14 @@
void
-BrokerAdapter::MessageHandlerImpl::cancel( u_int16_t /*channel*/,
- const string& /*destination*/ )
+BrokerAdapter::MessageHandlerImpl::cancel( u_int16_t channel,
+ const string& destination )
{
assert(0); // FIXME astitcher 2007-01-11: 0-9 feature
+
+ connection.getChannel(channel).cancel(destination);
+
+ connection.client->getMessageHandler()->ok(channel);
}
void
@@ -426,16 +432,35 @@
}
void
-BrokerAdapter::MessageHandlerImpl::consume( u_int16_t /*channel*/,
- u_int16_t /*ticket*/,
- const string& /*queue*/,
- const string& /*destination*/,
- bool /*noLocal*/,
- bool /*noAck*/,
- bool /*exclusive*/,
- const qpid::framing::FieldTable& /*filter*/ )
+BrokerAdapter::MessageHandlerImpl::consume( u_int16_t channelId,
+ u_int16_t /*ticket*/,
+ const string& queueName,
+ const string& destination,
+ bool noLocal,
+ bool noAck,
+ bool exclusive,
+ const qpid::framing::FieldTable& filter )
{
assert(0); // FIXME astitcher 2007-01-11: 0-9 feature
+
+ Queue::shared_ptr queue = connection.getQueue(queueName, channelId);
+ Channel& channel = connection.getChannel(channelId);
+ if(!destination.empty() && channel.exists(destination)){
+ throw ConnectionException(530, "Consumer tags must be unique");
+ }
+
+ try{
+ string newTag = destination;
+ channel.consume(newTag, queue, !noAck, exclusive, noLocal ? &connection : 0, &filter);
+
+ connection.client->getMessageHandler()->ok(channelId);
+
+ //allow messages to be dispatched if required as there is now a consumer:
+ queue->dispatch();
+ }catch(ExclusiveAccessException& e){
+ if(exclusive) throw ChannelException(403, "Exclusive access cannot be granted");
+ else throw ChannelException(403, "Access would violate previously granted exclusivity");
+ }
}
void
@@ -445,13 +470,22 @@
}
void
-BrokerAdapter::MessageHandlerImpl::get( u_int16_t /*channel*/,
+BrokerAdapter::MessageHandlerImpl::get( u_int16_t channelId,
u_int16_t /*ticket*/,
- const string& /*queue*/,
+ const string& queueName,
const string& /*destination*/,
- bool /*noAck*/ )
+ bool noAck )
{
assert(0); // FIXME astitcher 2007-01-11: 0-9 feature
+
+ Queue::shared_ptr queue = connection.getQueue(queueName, channelId);
+
+ // FIXME: get is probably Basic specific
+ if(!connection.getChannel(channelId).get(queue, !noAck)){
+
+ connection.client->getMessageHandler()->empty(channelId);
+ }
+
}
void
@@ -475,19 +509,28 @@
}
void
-BrokerAdapter::MessageHandlerImpl::qos( u_int16_t /*channel*/,
- u_int32_t /*prefetchSize*/,
- u_int16_t /*prefetchCount*/,
- bool /*global*/ )
+BrokerAdapter::MessageHandlerImpl::qos( u_int16_t channel,
+ u_int32_t prefetchSize,
+ u_int16_t prefetchCount,
+ bool /*global*/ )
{
assert(0); // FIXME astitcher 2007-01-11: 0-9 feature
+
+ //TODO: handle global
+ connection.getChannel(channel).setPrefetchSize(prefetchSize);
+ connection.getChannel(channel).setPrefetchCount(prefetchCount);
+
+ connection.client->getMessageHandler()->ok(channel);
}
void
-BrokerAdapter::MessageHandlerImpl::recover( u_int16_t /*channel*/,
- bool /*requeue*/ )
+BrokerAdapter::MessageHandlerImpl::recover( u_int16_t channel,
+ bool requeue )
{
assert(0); // FIXME astitcher 2007-01-11: 0-9 feature
+
+ connection.getChannel(channel).recover(requeue);
+
}
void
@@ -507,31 +550,40 @@
}
void
-BrokerAdapter::MessageHandlerImpl::transfer( u_int16_t /*channel*/,
- u_int16_t /*ticket*/,
- const string& /*destination*/,
- bool /*redelivered*/,
- bool /*immediate*/,
- u_int64_t /*ttl*/,
- u_int8_t /*priority*/,
- u_int64_t /*timestamp*/,
- u_int8_t /*deliveryMode*/,
- u_int64_t /*expiration*/,
- const string& /*exchange*/,
- const string& /*routingKey*/,
- const string& /*messageId*/,
- const string& /*correlationId*/,
- const string& /*replyTo*/,
- const string& /*contentType*/,
- const string& /*contentEncoding*/,
- const string& /*userId*/,
- const string& /*appId*/,
- const string& /*transactionId*/,
- const string& /*securityToken*/,
- const qpid::framing::FieldTable& /*applicationHeaders*/,
- qpid::framing::Content /*body*/ )
+BrokerAdapter::MessageHandlerImpl::transfer( u_int16_t channel,
+ u_int16_t /*ticket*/,
+ const string& /*destination*/,
+ bool /*redelivered*/,
+ bool immediate,
+ u_int64_t /*ttl*/,
+ u_int8_t /*priority*/,
+ u_int64_t /*timestamp*/,
+ u_int8_t /*deliveryMode*/,
+ u_int64_t /*expiration*/,
+ const string& exchangeName,
+ const string& routingKey,
+ const string& /*messageId*/,
+ const string& /*correlationId*/,
+ const string& /*replyTo*/,
+ const string& /*contentType*/,
+ const string& /*contentEncoding*/,
+ const string& /*userId*/,
+ const string& /*appId*/,
+ const string& /*transactionId*/,
+ const string& /*securityToken*/,
+ const qpid::framing::FieldTable& /*applicationHeaders*/,
+ qpid::framing::Content /*body*/ )
{
- assert(0); // FIXME astitcher 2007-01-11: 0-9 feature
+ assert(0); // FIXME astitcher 2007-01-11: 0-9 feature
+
+ Exchange::shared_ptr exchange = exchangeName.empty() ?
+ connection.broker.getExchanges().getDefault() : connection.broker.getExchanges().get(exchangeName);
+ if(exchange){
+ Message* msg = new Message(&connection, exchangeName, routingKey, false /*mandatory?*/, immediate);
+ connection.getChannel(channel).handlePublish(msg, exchange);
+ }else{
+ throw ChannelException(404, "Exchange not found '" + exchangeName + "'");
+ }
}
}} // namespace qpid::broker
==== BEGIN SVK PATCH BLOCK ====
Version: svk 1.08 (linux)
eJydWNlv48YZVwM4CwtoGzRtggYtOrtVDNmxDlISSdGN44OUrLWt9VraXEAgDMmRxJoiuTzsVaJN
TPpYrXe7TdAUPYACTVEgbwGKAn1o/4wCRdHn/hF56EO/IWVb3theJ7ZhaWa++X3HfNdMxWnOLTCD
+fn8IMXkB403V0VxA3tq91WmOEhxA6LpnuWkSgODbBMjVRgYVidVHJi4R2DVtXxHpV887HSIR7/o
6hbx5ucZgBNiODmCOIaNUBXsWaabKkfwLc8hJMUMhIXyYKFA/1oppjxwCaxEsC2HbOuubpnAXsjn
gQCoGdht2cRsOZblwQJfFhZYujM/UA3LJS0KDTMLJUrNpkCdiFzTHaKCPH3Yo9p2hBTvjviWRrtP
yYCAShXBFM6BKVOYnEdcz40YxWAROXcOOR+RG7oyRnwhZ5Zy5ihUMSUMsKa12rpBUgX2lGdunbgu
7pAVbGoGcZowl431KrRS7CDDxKKUjs0VAbDMOADeInQ2i3uRis+QqUCNysWr2LaNfssj9zyNGB6m
crZggSlRT6onEonHr4TewYf70rf+IU38upL8RP7+kby0V9n8vZR7KGelic+kl8KVd4NK8PLKR4fV
8uoPqpOHUv6BvBRUJ/fkMHEkOdXA/VReqgYv1sLv71fDhaEc1PbWQn9PmpAmnsivHKwE3ccre699
JlVkVX7hkTQRrFxfC67dDCdW9q6H6/uZfTmY+5s08Ym09/N9KSThag8WpOBGNZz9rRRUDqXwxiM5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