AmqpHashClient
class AmqpHashClient : public std::enable_shared_from_this<AmqpHashClient>
@brief Class that wraps around AmqpClient to provide a message interface with Hash header and body
Deserialisation of incoming messages is done via a karabo::net::Strand, i.e. a running karabo::net::EventLoop is needed.
Functions
| Name | Description |
|---|---|
| create | Create client with message interface based on two Hashes (header and body). |
| asyncSubscribe | Asynchronously subscribes client by just forwarding to AmqpClient::asyncSubscribe ==> See docs of that. |
| asyncUnsubscribe | Asynchronously unsubscribes client by just forwarding to AmqpClient::asyncUnsubscribe ==> See docs of that. |
| asyncUnsubscribeAll | Asynchronously unsubscribes client from all subscriptions by just forwarding to AmqpClient::asyncUnsubscribeAll ==> See docs of that. |
| asyncPublish | Asynchronously publish data from header and body Hashes are serialised such that AmqpClient::asyncPublish can be use internally. ==> See docs of that. |
| AmqpHashClient | Internal constructor, use static create instead: raw clients read handler has to be set after construction |
| onRead | Handler passed to raw client (i.e. runs in io context of connection). Post arguments for deserialzation on the respective strand that runs in Karabo event loop |
| deserialize | Deserializes 'data' input into Hash for header and body, adds exchange and key to the header and calls handler passed to constructor |
Function Details
AmqpHashClient
AmqpHashClient(AmqpConnection::Pointer connection, std::string instanceId, AMQP::Table queueArgs, HashReadHandler readHandler, ErrorReadHandler errorReadHandler)
Internal constructor, use static create instead: raw clients read handler has to be set after construction
asyncPublish
void asyncPublish(const std::string& exchange, const std::string& routingKey, const data::Hash::Pointer& header, const data::Hash::Pointer& body, AsyncHandler onPublishDone)
Asynchronously publish data from header and body
Hashes are serialised such that AmqpClient::asyncPublish can be use internally. ==> See docs of that.
asyncSubscribe
inline void asyncSubscribe(const std::string& exchange, const std::string& routingKey, AsyncHandler onSubscriptionDone)
Asynchronously subscribes client by just forwarding to AmqpClient::asyncSubscribe
==> See docs of that.
asyncUnsubscribe
inline void asyncUnsubscribe(const std::string& exchange, const std::string& routingKey, AsyncHandler onUnsubscriptionDone)
Asynchronously unsubscribes client by just forwarding to AmqpClient::asyncUnsubscribe
==> See docs of that.
asyncUnsubscribeAll
inline void asyncUnsubscribeAll(AsyncHandler onUnsubscriptionDone)
Asynchronously unsubscribes client from all subscriptions by just forwarding to AmqpClient::asyncUnsubscribeAll
==> See docs of that.
create
static Pointer create(AmqpConnection::Pointer connection, std::string instanceId, AMQP::Table queueArgs, HashReadHandler readHandler, ErrorReadHandler errorReadHandler)
Create client with message interface based on two Hashes (header and body).
connection
: the connection, all internal data access will run in its io context
instanceId
: the client id - will usually be the name of the queue that will be subscribed
queueArgs
: the arguments passed to queue creation
readHandler
: a valid read handler for all received messages
errorReadHandler
: a valid handler called when a received message could not be processed, e.g. due to
serialisation problems
deserialize
void deserialize(const std::shared_ptr<std::vector<char>>& data, const std::string& exchange, const std::string& routingKey)
Deserializes 'data' input into Hash for header and body, adds exchange and key to the header and calls handler passed to constructor
onRead
void onRead(const std::shared_ptr<std::vector<char>>& data, const std::string& exchange, const std::string& routingKey)
Handler passed to raw client (i.e. runs in io context of connection).
Post arguments for deserialzation on the respective strand that runs in Karabo event loop