Skip to content

Commit bef8719

Browse files
committed
Updated README.md
1 parent f4a0cd2 commit bef8719

File tree

1 file changed

+10
-7
lines changed

1 file changed

+10
-7
lines changed

README.md

Lines changed: 10 additions & 7 deletions
Original file line numberDiff line numberDiff line change
@@ -14,7 +14,7 @@ The package can be installed via adding the `spotter` dependency to your list of
1414

1515
```elixir
1616
def deps do
17-
[{:spotter, "~> 0.4.0"}]
17+
[{:spotter, "~> 0.4.1"}]
1818
end
1919
```
2020

@@ -76,7 +76,10 @@ Any of those arguments (that were mentioned in the documentation) can be specifi
7676

7777
# Specify here the queue that you want to use
7878
# `opts` will contain options (as a Map) that were specified in child_spec for supervisor
79-
def configure(channel, _opts) do
79+
def configure(channel_name, _opts) do
80+
# For getting an access to the channel by its name use `get_channel(channel_name)` function
81+
channel = get_channel(channel_name)
82+
8083
:ok = AMQP.Exchange.direct(channel, @exchange, durable: true)
8184

8285
# An initial point where the worker do required stuff
@@ -99,20 +102,20 @@ Any of those arguments (that were mentioned in the documentation) can be specifi
99102

100103
# Invoked when a message successfully consumed
101104
def handle_info({:basic_deliver, payload, %{delivery_tag: tag, reply_to: reply_to, headers: headers}}, state) do
102-
channel = state[:channel]
103-
spawn fn -> consume(channel, tag, reply_to, headers, payload) end
105+
channel_name = state[:channel_name]
106+
spawn fn -> consume(channel_name, tag, reply_to, headers, payload) end
104107
{:noreply, state}
105108
end
106109

107110
# Processing a consumed message
108-
defp consume(channel, tag, reply_to, headers, payload) do
111+
defp consume(channel_name, tag, reply_to, headers, payload) do
109112
# Do some usefull stuff here ...
110113

111114
# And don't forget to ack a processed message. Or perhaps even use nack
112115
# when it will be neceessary.
113-
# We will wrap the call into `safe_run(channel, func)` call, so that it will retry
116+
# We will wrap the call into `safe_run(channel_name, func)` call, so that it will retry
114117
# the executed code when the used channel is failed
115-
safe_run(channel, fn(channel) -> AMQP.Basic.ack(channel, tag) end)
118+
safe_run(channel_name, fn(channel) -> AMQP.Basic.ack(channel, tag) end)
116119
end
117120
end
118121
```

0 commit comments

Comments
 (0)