Skip to content

How streamview reads without taking messages

A tool that shows messages must not change what your services get. streamview only reads. This page explains how that works for each broker, and where the limits are.

Some brokers keep a log. A reader of a log does not remove a message, and many readers can read the same message.

Other brokers keep a queue. When one reader gets a message from a queue, the other readers do not get it. A tool that reads from such a queue takes messages from the service that owns the queue.

A logReaders do not remove messages.123456Reader A is hereReader B is hereEach reader has its own position.All readers get all messages.A queueA read removes the message.123456Reader A gets itReader B does not get itOne reader gets each message.Then the message is gone from the queue.

Thus the answer is different for each broker.

A Kafka topic is a log. Kafka does not delete a message when a consumer reads it. Kafka keeps one position, the offset, for each consumer group.

One Kafka topicA log. Each message has an offset.0123456789streamview's own groupYour consumer groupstreamview reads from the first stored message.The offset of your group does not change.

streamview reads as a new consumer group. Each start uses a new group name, unless you give --group. The offsets of your consumer groups do not change, and your services get all their messages.

There are two effects that you can see on the broker:

  • The broker shows one more consumer group for each start of streamview.
  • The broker sends the data one more time. With many stored messages, this is a load on the broker.

To decrease the load, use --topics to read fewer topics, or --latest to read only new messages.

NATS sends each message to all subscriptions that match its subject. streamview makes a usual subscription, by default to >, which is all subjects.

Your servicepublishes a messageNATS subjectsuch as orders.placedA subscribergets the messageA queue groupone member gets itstreamviewgets a copyA usual subscription has no history.streamview sees new messages only.

A usual subscription gets a copy. It does not take the message from other subscribers. This is also true for a queue group. NATS sends the message to one member of the group, and also to streamview.

A usual subscription has no history. streamview sees only the messages that come after it starts.

A JetStream stream stores messages. How streamview reads a stream depends on the retention of the stream.

Limits retentionkeeps a message until a limitAn ordered consumertemporary, and it removes nothingHistory and newfrom the first messageWork-queue streamdeletes a message after a readNo consumer on the streama read takes the messageNew messages onlyno historyInterest streamkeeps what consumers needNo consumer on the streama consumer changes what it keepsNew messages onlyno history

Streams with limits retention. The stream keeps a message until a limit removes it, for example an age limit. Readers do not remove messages. streamview reads these streams with an ordered consumer, from the first message. An ordered consumer is temporary. streamview deletes its consumers when it stops. If streamview cannot delete them, the server removes them after some minutes.

Work-queue streams. The stream deletes a message when a consumer gets it. If streamview reads such a stream, it takes messages from the service that owns the queue. Thus streamview does not read work-queue streams.

Interest streams. The stream keeps a message while consumers need it. A new consumer changes what the stream keeps. Thus streamview does not read interest streams.

For the last two kinds, streamview uses the usual subscription. You see their messages when a service publishes them, but you do not see their history.

In RabbitMQ, a program publishes a message to an exchange. The exchange puts a copy in each queue that is connected to it. When a consumer takes a message from a queue, the message is gone from that queue.

directly to a queue: not visible without --traceYour servicepublishesExchangecopies to each queueA queueof your serviceYour serviceconsumesA temporary queuemade by streamviewstreamviewonly readsThere is no history.New messages only.The queue is gonewhen streamview stops.

Thus streamview must not read a queue of your services. It makes a queue of its own, and connects it to your exchanges. Each exchange then puts a copy of each message in the queue of streamview. Your queues get their copies as before.

The queue of streamview is temporary. RabbitMQ deletes it when streamview stops, and no messages stay on the server. The queue also has a maximum length. If streamview is too slow, RabbitMQ deletes the oldest copies in this queue, and the memory of the server does not fill.

This method has two limits:

  • There is no history. RabbitMQ does not keep messages for a queue that did not exist. streamview sees only the messages that come after it starts.
  • A message that goes directly to a queue is not visible. Such a message goes through the default exchange, and no program can connect a queue to that exchange.

For the second limit, RabbitMQ has a tracer. When the tracer is on, the server gives a copy of each published message. streamview reads these copies when you start it with --trace. The tracer makes the server slower, thus it is off by default.

A direct exchange gives a queue only the routing keys that the queue asks for, by their exact name. The adapter asks the management API which routing keys your queues use. It then asks for the same keys.

In SQS, a reader that gets a message hides it from the other readers, and then deletes it. There is no method to read such a queue and not change it.

no read is possible without a changeHTTP: POST /eventsYour servicesends a messageSQS queuehides, then deletesYour consumergets the messageYour systemsends a copystreamviewshows the copy

streamview has no adapter for SQS, SNS, or EventBridge. If your system sends a copy of each message to a different destination, you can send that copy to streamview with HTTP. See Show events from a file, a program, or HTTP.

streamview does not publish messages to Kafka, to NATS, or to RabbitMQ.

streamviewonly readsIts own SQLite filethe events that it keeps~/.cache/streamview/the Kafka, NATS, and RabbitMQ adaptersOne temporary queueon RabbitMQ, with its connectionsMessages on your brokersstreamview does not publish

On RabbitMQ, it makes one temporary queue and the connections of that queue to your exchanges. It writes only to its own SQLite file, and to its adapter directory in ~/.cache/streamview/.