Shows how to set and examine message properties.
#include <iostream>
#include <map>
int main(int argc, char **argv) {
try {
std::string s = proton::get<std::string>(m.
properties().
get(
"string"));
int16_t i;
throw std::logic_error("wrong type!");
}
std::cout << "using put/get:"
<< " short=" << i
<< " string=" << s
<< std::endl;
std::cout << "using coerce:"
<< " short(as long)="
<< std::endl;
typedef std::map<std::string, proton::scalar> property_map;
property_map props;
for (property_map::iterator i = props.begin(); i != props.end(); ++i) {
std::cout << "props[" << i->first << "]=" << i->second << std::endl;
}
props["string"] = "bar";
props["short"] = 42;
<< std::endl;
try {
throw std::logic_error("expected exception");
std::cout << "expected conversion_error: \"" << e.what() << '"' << std::endl;
}
try {
throw std::logic_error("expected exception");
std::cout << "expected conversion_error: \"" << e.what() << '"' << std::endl;
}
return 0;
} catch (const std::exception& e) {
std::cerr << "unexpected exception: " << e.what() << std::endl;
return 1;
}
}
T get(const K &k) const
Get the map entry for key k.
void put(const K &k, const T &v)
Put a map entry for key k.
An AMQP message.
Definition: message.hpp:48
property_map & properties()
Get the application properties map.
A string that represents the AMQP symbol type.
Definition: symbol.hpp:35
T get(const scalar &s)
Get a contained value of type T.
Definition: scalar.hpp:60
type_id
An identifier for AMQP types.
Definition: type_id.hpp:37
@ SYMBOL
Variable-length encoded string.
Definition: type_id.hpp:58
An error converting between AMQP and C++ data.
Definition: error.hpp:56
Proton types used to represent AMQP types.