FairMQ/examples/MQ/8-multipart
Alexey Rybalchenko bbadf09aad FairMQ: Extend Multipart and messaging API
- Extend the multipart API to allow sending vectors of messages or helper
   thin wrapper FairMQParts. See example in examples/MQ/8-multipart.
 - NewMessage() can be used in devices instead of
   fTransportFactory->CreateMessage().
   Possible arguments remain unchanged (no args, size or data+size).
 - Send()/Receive() methods can be used in devices instead of
   fChannels.at("chan").at(i).Send()/Receive():
   Send(msg, "chan", i = 0), Receive(msg, "chan", i = 0).
 - Use the new methods in MQ examples and tests.
 - No breaking changes, but FAIRMQ_INTERFACE_VERSION is incremented to 3
   to allow to check for new methods.
2018-05-02 16:12:57 +02:00
..
CMakeLists.txt Add FlatBuffers & MessagePack examples 2018-05-02 16:12:57 +02:00
ex8-multipart.json Rename /example to /examples and move MQ examples in it 2018-05-02 16:12:57 +02:00
FairMQExample8Sampler.cxx FairMQ: Extend Multipart and messaging API 2018-05-02 16:12:57 +02:00
FairMQExample8Sampler.h Rename /example to /examples and move MQ examples in it 2018-05-02 16:12:57 +02:00
FairMQExample8Sink.cxx FairMQ: Extend Multipart and messaging API 2018-05-02 16:12:57 +02:00
FairMQExample8Sink.h Rename /example to /examples and move MQ examples in it 2018-05-02 16:12:57 +02:00
README.md Rename /example to /examples and move MQ examples in it 2018-05-02 16:12:57 +02:00
runExample8Sampler.cxx Remove compile time transport interface switch 2018-05-02 16:12:57 +02:00
runExample8Sink.cxx Remove compile time transport interface switch 2018-05-02 16:12:57 +02:00

Example 8: Sending Multipart messages

A topology of two devices - Sampler and Sink, communicating with PUSH-PULL pattern.

The Sampler sends a multipart message to the Sink, consisting of two message parts - header and body.

Each message part is a regular FairMQMessage. To combine them into a multi-part message, simply send all but the last part with SendPart() and the last part with Send() as shown in the example.

The ZeroMQ transport guarantees delivery of both parts together. Meaning that when the Receive call of the Sink receives the first part, following parts have arrived too.

The header contains a simple data structure with one integer. The integer in this structure is used as a stop flag for the sink. As long as its value is 0, the Sink will keep processing the data. Once its value is 1, the Sink will exit its Run() method.