Skip to content

Commit

Permalink
doc: Minor documentation updates
Browse files Browse the repository at this point in the history
  • Loading branch information
VictorGaiva committed Mar 21, 2024
1 parent 635fd41 commit 0419a15
Show file tree
Hide file tree
Showing 2 changed files with 23 additions and 23 deletions.
42 changes: 20 additions & 22 deletions README.md
Original file line number Diff line number Diff line change
Expand Up @@ -37,9 +37,27 @@ def deps do
end
```

## Usage
### Producing

### Consuming from Stream
RabbitMQ Streams protocol needs a static `:reference_name` per producer. This is used to prevent message duplication. For this reason, each stream needs, for now, a static module to publish messages, which keeps track of its own `publishing_id`.

You can define a `Producer` module like this:

```elixir
defmodule MyApp.MyProducer do
use RabbitMQStream.Producer,
stream_name: "stream-01",
connection: MyApp.MyConnection
end
```

Then you can publish messages to the stream:

```elixir
MyApp.MyProducer.publish("Hello World")
```

## Consuming

First you define a connection

Expand Down Expand Up @@ -80,26 +98,6 @@ def handle_info({:deliver, %RabbitMQStream.Message.Types.DeliverData{} = deliver
end
```

### Publishing to Stream

RabbitMQ Streams protocol needs a static `:reference_name` per producer. This is used to prevent message duplication. For this reason, each stream needs, for now, a static module to publish messages, which keeps track of its own `publishing_id`.

You can define a `Producer` module like this:

```elixir
defmodule MyApp.MyProducer do
use RabbitMQStream.Producer,
stream_name: "stream-01",
connection: MyApp.MyConnection
end
```

Then you can publish messages to the stream:

```elixir
MyApp.MyProducer.publish("Hello World")
```

### Configuration

The configuration for the connection can be set in your `config.exs` file:
Expand Down
4 changes: 3 additions & 1 deletion guides/concepts/super-streams.md
Original file line number Diff line number Diff line change
Expand Up @@ -15,6 +15,7 @@ You can declare a consumer as being part of a Single Active Consumer group by pa
defmodule Subs1 do
use RabbitMQStream.Consumer,
stream_name: "super-stream-01",
connection: MyApp.MyConnection,
properties: [single_active_consumer: "group-1"]

@impl true
Expand All @@ -40,7 +41,7 @@ Based on the semantics of `single_active_consumer` property, this library implem
You can declare SuperStreams with:

```elixir
:ok = RabbitMQStream.Connection.create_super_stream(conn, "my_super_stream", "route-A": ["stream-01", "stream-02"], "route-B": ["stream-03"])
:ok = MyApp.MyConnection.create_super_stream("my_super_stream", "route-A": ["stream-01", "stream-02"], "route-B": ["stream-03"])
```

And you can consume from it with:
Expand All @@ -49,6 +50,7 @@ And you can consume from it with:
defmodule MyApp.MySuperConsumer do
use RabbitMQStream.SuperConsumer,
initial_offset: :next,
connection: MyApp.MyConnection,
super_stream: "my_super_stream"

@impl true
Expand Down

0 comments on commit 0419a15

Please sign in to comment.