Configuring Exchange Options
The C++ Broker M4 or later supports the following additional Exchange options in addition to the standard AMQP define options
- Exchange Level Message sequencing
Exchange Level Message sequencing
This feature can be used to place a sequence number into each message's headers, based on the order they pass through an exchange. The sequencing starts at 0 and then wraps in an AMQP int64 type.
The field name used is "qpid.msg_sequence"
To use this feature an exchange needs to be declared specifying this option in the declare
.... FieldTable args; args.setInt("qpid.msg_sequence",1); ... // now declare the exchange session.exchangeDeclare(arg::exchange="direct", arg::arguments=args);
Then each message passing through that exchange will be numbers in the application headers.
unit64_t seqNo; //after message transfer seqNo = message.getHeaders().getAsInt64("qpid.msg_sequence");