libbmq  a5f8a06ba1d16cb5a65643e1fa7f1a1d6aadef40
bmqt_messageguid.h File Reference

Provide a value-semantic global unique identifier for BlazingMQ messages. More...

#include <bsl_cstring.h>
#include <bsl_iosfwd.h>
#include <bslh_hash.h>
#include <bslmf_isbitwiseequalitycomparable.h>
#include <bslmf_istriviallycopyable.h>
#include <bslmf_nestedtraitdeclaration.h>
#include <bsls_annotation.h>
#include <bsls_types.h>

Go to the source code of this file.

Classes

class  BloombergLP::bmqt::MessageGUID
 
struct  BloombergLP::bmqt::MessageGUIDLess
 This struct provides a binary function for comparing 2 GUIDs. More...
 
class  BloombergLP::bmqt::MessageGUIDHashAlgo
 

Namespaces

 BloombergLP
 
 BloombergLP::bmqt
 

Functions

bsl::ostream & BloombergLP::bmqt::operator<< (bsl::ostream &stream, const MessageGUID &rhs)
 
bool BloombergLP::bmqt::operator== (const MessageGUID &lhs, const MessageGUID &rhs)
 
bool BloombergLP::bmqt::operator!= (const MessageGUID &lhs, const MessageGUID &rhs)
 
bool BloombergLP::bmqt::operator< (const MessageGUID &lhs, const MessageGUID &rhs)
 
template<class HASH_ALGORITHM >
void BloombergLP::bmqt::hashAppend (HASH_ALGORITHM &hashAlgo, const MessageGUID &guid)
 

Detailed Description

bmqt::MessageGUID provides a value-semantic global unique identifier for BlazingMQ messages. Each bmqa::Message delivered to BlazingMQ client from BlazingMQ broker contains a unique bmqt::MessageGUID. The binary functor bmqt::MessageGUIDLess can be used for comparing GUIDs, and an optimized custom hash function is provided with bmqt::MessageGUIDHashAlgo.

Externalization

For convenience, this class provides toHex method that can be used to externalize a bmqt::MessageGUID instance. Applications can persist the resultant buffer (on filesystem, in database) to keep track of last processed message ID across task instantiations. fromHex method can be used to convert a valid externalized buffer back to a message ID.

Efficient comparison and hash function

This component also provides efficient comparison and hash functions for convenience, and thus, applications can use this component as a key in associative containers.

Usage

This section illustrates intended use of this component.

Example 1: Externalizing

// Below, 'msg' is a valid instance of 'bmqa::Message' obtained from an
// instance of 'bmqa::Session':
bmqt::MessageGUID g1 = msg.messageId();
char buffer[bmqt::MessageGUID::e_SIZE_HEX];
g1.toHex(buffer);
BSLS_ASSERT(true == bmqt::MessageGUID::isValidHexRepresentation(buffer));
bmqt::MessageGUID g2;
g2.fromHex(buffer);
BSLS_ASSERT(g1 == g2);