Technical Details of Traction Service that allows message publishingΒΆ
The two classes central to sending volume tracking messages to the message broker are app/messages/emq/publisher.rb and app/messages/emq/publishing_job.rb.
The former defines functions to instantiate an Emq::PublishingJob object, and the latter defines business logic on how message publishing should occur.
The former is a trivial implementation on instantiating a Ruby object based on a configuration (enabled in bunny.yml); therefore it is not discussed here.
However, the latter has some points that are worthy of some explaination. Emq::PublishingJob class' publish method is documented in traction-service documentation.
Tip
Each noteworthy code fragment/line is explained in tooltips that could be viewed by clicking on the right arrow symbol () right hand side of the code line.
bunny_configrefers to theconfig/bunny.ymlfile.Emq::Encoderencodes messages into a binary format usingavroschemas stored in RedPanda Schema Registry.Emq::Senderuses theversionandsubjectto populate the headers of the AMQP message.message_objectrefers to a dynamically generated (and populated) Ruby object that uses the object schema defined in config/pipelines/pacbio.yml.- The schema defined in RedPanda Schema Registry is fetched using the REST API provided by RedPanda, and the message is encoded into a binary format.
- Each object is published into the broker in a loop, separately.
- Subject refers to the schema name in RedPanda Schema Registry.
- Message publishing event is logged for monitoring purposes.
The message is published to the configured RabbitMQ broker.
The broker's configuration are declared under the YAML key bunny_config.amqp in config/bunny.yml.
Warning
Note that if traction-service is not able to find the schema from the schema registry, or not able to find either the subject or version declared in bunny.yml, no message will be pushed to the queue.
Therefore, correct configuration is essential for a successful end-to-end volume tracking process.