00001 #ifndef _client_Message_h
00002 #define _client_Message_h
00003
00004
00005
00006
00007
00008
00009
00010
00011
00012
00013
00014
00015
00016
00017
00018
00019
00020
00021
00022
00023
00024 #include <string>
00025 #include "qpid/client/Session.h"
00026 #include "qpid/framing/MessageTransferBody.h"
00027 #include "qpid/framing/TransferContent.h"
00028
00029 namespace qpid {
00030 namespace client {
00031
00038 class Message : public framing::TransferContent
00039 {
00040 public:
00041 Message(const std::string& data_=std::string(),
00042 const std::string& routingKey=std::string(),
00043 const std::string& exchange=std::string()
00044 ) : TransferContent(data_, routingKey, exchange) {}
00045
00046 std::string getDestination() const
00047 {
00048 return method.getDestination();
00049 }
00050
00051 bool isRedelivered() const
00052 {
00053 return hasDeliveryProperties() && getDeliveryProperties().getRedelivered();
00054 }
00055
00056 void setRedelivered(bool redelivered)
00057 {
00058 getDeliveryProperties().setRedelivered(redelivered);
00059 }
00060
00061 framing::FieldTable& getHeaders()
00062 {
00063 return getMessageProperties().getApplicationHeaders();
00064 }
00065
00066 void acknowledge(Session& session, bool cumulative = true, bool send = true) const
00067 {
00068 session.getExecution().completed(id, cumulative, send);
00069 }
00070
00071 void acknowledge(bool cumulative = true, bool send = true) const
00072 {
00073 const_cast<Session&>(session).getExecution().completed(id, cumulative, send);
00074 }
00075
00077 Message(const framing::FrameSet& frameset, Session s) :
00078 method(*frameset.as<framing::MessageTransferBody>()), id(frameset.getId()), session(s)
00079 {
00080 populate(frameset);
00081 }
00082
00083 const framing::MessageTransferBody& getMethod() const
00084 {
00085 return method;
00086 }
00087
00088 const framing::SequenceNumber& getId() const
00089 {
00090 return id;
00091 }
00092
00094 void setSession(Session s) { session=s; }
00095 private:
00096
00097 framing::MessageTransferBody method;
00098 framing::SequenceNumber id;
00099 Session session;
00100 };
00101
00102 }}
00103
00104 #endif