00001
00002
00003
00004
00005
00006
00007
00008
00009
00010
00011
00012
00013
00014
00015
00016
00017
00018
00019
00020
00021
00022
00023
00024
00025
00026
00027
00028 #ifndef qpid_framing_MessageTransferBody__
00029 #define qpid_framing_MessageTransferBody__
00030
00031 #include <string>
00032 #include <sstream>
00033
00034 #include "qpid/framing/amqp_types.h"
00035 #include "qpid/framing/AMQRequestBody.h"
00036 #include "qpid/framing/Buffer.h"
00037 #include "qpid/framing/FieldTable.h"
00038 #include "qpid/framing/FramingContent.h"
00039
00040 namespace qpid
00041 {
00042 namespace framing
00043 {
00044
00045
00046 class MessageTransferBody : public AMQRequestBody
00047 {
00048
00049
00050
00051 u_int16_t ticket;
00052 string destination;
00053 bool redelivered;
00054 bool immediate;
00055 u_int64_t ttl;
00056 u_int8_t priority;
00057 u_int64_t timestamp;
00058 u_int8_t deliveryMode;
00059 u_int64_t expiration;
00060 string exchange;
00061 string routingKey;
00062 string messageId;
00063 string correlationId;
00064 string replyTo;
00065 string contentType;
00066 string contentEncoding;
00067 string userId;
00068 string appId;
00069 string transactionId;
00070 string securityToken;
00071 FieldTable applicationHeaders;
00072 Content body;
00073 bool mandatory;
00074
00075
00076 public:
00077 static const ClassId CLASS_ID= 120;
00078 static const MethodId METHOD_ID = 10;
00079
00080 typedef boost::shared_ptr<MessageTransferBody> shared_ptr;
00081
00082
00083
00084 MessageTransferBody(ProtocolVersion version,
00085 u_int16_t ticket,
00086 const string& destination,
00087 bool redelivered,
00088 bool immediate,
00089 u_int64_t ttl,
00090 u_int8_t priority,
00091 u_int64_t timestamp,
00092 u_int8_t deliveryMode,
00093 u_int64_t expiration,
00094 const string& exchange,
00095 const string& routingKey,
00096 const string& messageId,
00097 const string& correlationId,
00098 const string& replyTo,
00099 const string& contentType,
00100 const string& contentEncoding,
00101 const string& userId,
00102 const string& appId,
00103 const string& transactionId,
00104 const string& securityToken,
00105 const FieldTable& applicationHeaders,
00106 const Content& body,
00107 bool mandatory
00108 ) : AMQRequestBody(version),
00109 ticket(ticket),
00110 destination(destination),
00111 redelivered(redelivered),
00112 immediate(immediate),
00113 ttl(ttl),
00114 priority(priority),
00115 timestamp(timestamp),
00116 deliveryMode(deliveryMode),
00117 expiration(expiration),
00118 exchange(exchange),
00119 routingKey(routingKey),
00120 messageId(messageId),
00121 correlationId(correlationId),
00122 replyTo(replyTo),
00123 contentType(contentType),
00124 contentEncoding(contentEncoding),
00125 userId(userId),
00126 appId(appId),
00127 transactionId(transactionId),
00128 securityToken(securityToken),
00129 applicationHeaders(applicationHeaders),
00130 body(body),
00131 mandatory(mandatory)
00132 { }
00133
00134
00135 MessageTransferBody(ProtocolVersion version): AMQRequestBody(version) {}
00136 virtual ~MessageTransferBody() {}
00137
00138
00139
00140 u_int16_t getTicket() { return ticket; }
00141 const string& getDestination() { return destination; }
00142 bool getRedelivered() { return redelivered; }
00143 bool getImmediate() { return immediate; }
00144 u_int64_t getTtl() { return ttl; }
00145 u_int8_t getPriority() { return priority; }
00146 u_int64_t getTimestamp() { return timestamp; }
00147 u_int8_t getDeliveryMode() { return deliveryMode; }
00148 u_int64_t getExpiration() { return expiration; }
00149 const string& getExchange() { return exchange; }
00150 const string& getRoutingKey() { return routingKey; }
00151 const string& getMessageId() { return messageId; }
00152 const string& getCorrelationId() { return correlationId; }
00153 const string& getReplyTo() { return replyTo; }
00154 const string& getContentType() { return contentType; }
00155 const string& getContentEncoding() { return contentEncoding; }
00156 const string& getUserId() { return userId; }
00157 const string& getAppId() { return appId; }
00158 const string& getTransactionId() { return transactionId; }
00159 const string& getSecurityToken() { return securityToken; }
00160 const FieldTable& getApplicationHeaders() { return applicationHeaders; }
00161 const Content& getBody() { return body; }
00162 bool getMandatory() { return mandatory; }
00163
00164
00165
00166 inline void print(std::ostream& out) const
00167 {
00168 printPrefix(out);
00169 out << "MessageTransfer: ";
00170 out << "ticket=" << ticket;
00171 out << "; destination=" << destination;
00172 out << "; redelivered=" << redelivered;
00173 out << "; immediate=" << immediate;
00174 out << "; ttl=" << ttl;
00175 out << "; priority=" << (int)priority;
00176 out << "; timestamp=" << timestamp;
00177 out << "; deliveryMode=" << (int)deliveryMode;
00178 out << "; expiration=" << expiration;
00179 out << "; exchange=" << exchange;
00180 out << "; routingKey=" << routingKey;
00181 out << "; messageId=" << messageId;
00182 out << "; correlationId=" << correlationId;
00183 out << "; replyTo=" << replyTo;
00184 out << "; contentType=" << contentType;
00185 out << "; contentEncoding=" << contentEncoding;
00186 out << "; userId=" << userId;
00187 out << "; appId=" << appId;
00188 out << "; transactionId=" << transactionId;
00189 out << "; securityToken=" << securityToken;
00190 out << "; applicationHeaders=" << applicationHeaders;
00191 out << "; body=" << body;
00192 out << "; mandatory=" << mandatory;
00193 }
00194
00195 inline ClassId amqpClassId() const { return CLASS_ID; }
00196 inline MethodId amqpMethodId() const { return METHOD_ID; }
00197
00198 u_int32_t size() const
00199 {
00200 u_int32_t sz = baseSize();
00201 sz += 2;
00202 sz += 1 + destination.length();
00203 sz += 1;
00204 sz += 8;
00205 sz += 1;
00206 sz += 8;
00207 sz += 1;
00208 sz += 8;
00209 sz += 1 + exchange.length();
00210 sz += 1 + routingKey.length();
00211 sz += 1 + messageId.length();
00212 sz += 1 + correlationId.length();
00213 sz += 1 + replyTo.length();
00214 sz += 1 + contentType.length();
00215 sz += 1 + contentEncoding.length();
00216 sz += 1 + userId.length();
00217 sz += 1 + appId.length();
00218 sz += 1 + transactionId.length();
00219 sz += 4 + securityToken.length();
00220 sz += applicationHeaders.size();
00221 sz += body.size();
00222 sz += 1;
00223 return sz;
00224 }
00225
00226 void encodeContent(Buffer& buffer) const
00227 {
00228 buffer.putShort(ticket);
00229 buffer.putShortString(destination);
00230 u_int8_t flags_4[1] = {0};
00231 flags_4[0] |= redelivered << 0;
00232 flags_4[0] |= immediate << 1;
00233 buffer.putOctet(flags_4[0]);
00234 buffer.putLongLong(ttl);
00235 buffer.putOctet(priority);
00236 buffer.putLongLong(timestamp);
00237 buffer.putOctet(deliveryMode);
00238 buffer.putLongLong(expiration);
00239 buffer.putShortString(exchange);
00240 buffer.putShortString(routingKey);
00241 buffer.putShortString(messageId);
00242 buffer.putShortString(correlationId);
00243 buffer.putShortString(replyTo);
00244 buffer.putShortString(contentType);
00245 buffer.putShortString(contentEncoding);
00246 buffer.putShortString(userId);
00247 buffer.putShortString(appId);
00248 buffer.putShortString(transactionId);
00249 buffer.putLongString(securityToken);
00250 buffer.putFieldTable(applicationHeaders);
00251 buffer.putContent(body);
00252 u_int8_t flags_22[1] = {0};
00253 flags_22[0] |= mandatory << 0;
00254 buffer.putOctet(flags_22[0]);
00255 }
00256
00257 inline void decodeContent(Buffer& buffer)
00258 {
00259 ticket = buffer.getShort();
00260 buffer.getShortString(destination);
00261 u_int8_t flags_4[1];
00262 flags_4[0] = buffer.getOctet();
00263 redelivered = (1 << 0) & flags_4[0];
00264 immediate = (1 << 1) & flags_4[0];
00265 ttl = buffer.getLongLong();
00266 priority = buffer.getOctet();
00267 timestamp = buffer.getLongLong();
00268 deliveryMode = buffer.getOctet();
00269 expiration = buffer.getLongLong();
00270 buffer.getShortString(exchange);
00271 buffer.getShortString(routingKey);
00272 buffer.getShortString(messageId);
00273 buffer.getShortString(correlationId);
00274 buffer.getShortString(replyTo);
00275 buffer.getShortString(contentType);
00276 buffer.getShortString(contentEncoding);
00277 buffer.getShortString(userId);
00278 buffer.getShortString(appId);
00279 buffer.getShortString(transactionId);
00280 buffer.getLongString(securityToken);
00281 buffer.getFieldTable(applicationHeaders);
00282 buffer.getContent(body);
00283 u_int8_t flags_22[1];
00284 flags_22[0] = buffer.getOctet();
00285 mandatory = (1 << 0) & flags_22[0];
00286 }
00287
00288 void invoke(AMQP_ServerOperations& target, const MethodContext& context)
00289 {
00290 target.getMessageHandler()->transfer(context,
00291 ticket,
00292 destination,
00293 redelivered,
00294 immediate,
00295 ttl,
00296 priority,
00297 timestamp,
00298 deliveryMode,
00299 expiration,
00300 exchange,
00301 routingKey,
00302 messageId,
00303 correlationId,
00304 replyTo,
00305 contentType,
00306 contentEncoding,
00307 userId,
00308 appId,
00309 transactionId,
00310 securityToken,
00311 applicationHeaders,
00312 body,
00313 mandatory
00314 );
00315 }
00316
00317
00318 };
00319
00320
00321 }
00322 }
00323
00324 #endif
00325