devie

devie

How to retry a Job In Elixir

Please i’ve got a Question, i’m replacing a Predictive dialer with Elixir. It has exceeded all expectations so far. However, i’m facing an issue. This piece of code works well assuming all third party dependencies work as expected,

def perform(phonebook_contacts,...) do
    alias FSModEvent.Connection, as: C
  for x <-Enum.chunk(phonebook_contacts,100,100,[]), y <- x  do 
    unless Telephony.user_balance(account_number) <= 0 do
  	Task.start_link(fn -> 
        # some background job to dailout phone number y
    end)
    # :timer.sleep(1000);
    end 
  ...

phonebook_contacts can be a list with as many as 200K Numbers
I’m using exq. If something external causes the job to fail, when it gets retried, it starts from the begining of the list, is there a way i can probably retry from the last contact where the Job failed at?

Assuming [12,34,56,78,90…]

Assuming the Job fails at 56, it restarts from 12 again, it there a way of continuing from 78,...? or a better way of handling this use case?

Most Liked

ryh

ryh

I don’t really know much about Exq, but looking at it… it doesn’t seem well-suited for what you’re trying to do. You’re redefining what Exq means by “retry”, which is “do this again with the same arguments as before as I’m expecting the same result”.

As for your idea of retry – you want to be able to start where the failure happened because starting from the beginning won’t give the same result - it has side effects! Even though you’re restarting what you think is the same job, with Exq semantics, that’s actually a new job because you want to use a different set of data.


I think there’s a better way to do this…

But first, what constitutes a failure? Is it when you receive a BGAPI error or a FreeSWITCH -ERR response or what?

Second, do you really want to start from the first job that failed? It makes more sense to me to collect every dial out that failed and then retry those specifically.

Eiji

Eiji

@devie: How about use retry library?

To save state you can use simple Agent and then skip entries based on stored information in it.

devie

devie

@Architect It’s part of a cloud based Call Center application - Inbound,outbound,voice analytics, IVR, … This code snippet just handles the dialing of the outbound calls.

cjbottaro

cjbottaro

Or use the retryable_ex package which doesn’t use a single drop of metaprogramming or macros.

Or just use Faktory (by the author of Sidekiq) and the Elixir Faktory Client, which has retries built in.

Where Next?

Popular in Questions Top

tduccuong
Hi, is there any work on GUI with Elixir, that is similar to Electron/Javascript? My idea is to bundle Phoenix and BEAM into a single se...
New
Harrisonl
We have an ECS cluster with 4 services, where each task joins a single cluster, via discovery ECS discovery service. Currently when I de...
New
quazar
How to set Jason to encode all fields in ecto schema, I don’t care about security and implementing only is taking long list of attributes...
New
qwerescape
Is there a way to get the call stack or stack trace at any point in the code? Not from exceptions, but an expression that returns how the...
New
mathew4509
I have a list say x = ["23gh", "56kh", "97mh"] I would like to pass each element to Val in each iteration. Say, in iteration 1 -------...
New
electic
Hi, I am new to Elixir. I am trying to use the DateTime component to insert a date into MySQL however the there seems to be no way to fo...
New
Patoshizzle
After calling mix ecto.create I get this error: 17:00:32.162 [error] GenServer #PID&lt;0.412.0&gt; terminating ** (Postgrex.Error) FATAL...
New
Fl4m3Ph03n1x
About me? ( if you have nothing better to do than reading about some random guy in the internet :stuck_out_tongue: ) Hello all, this is ...
New
Mooodi
Given a string, how can I get access to its character by index? Enum.at("my_string", 2) doesn't work. Or rather, not char, but a substr...
New
idi527
I’ve been re-reading swift book again and noticed that multiline strings there don’t have a trailing line break, unlike in elixir iex(2)...
New

Other popular topics Top

srinivasu
How to handle excepions in elixir? Suppose i have A, B, C ,D, E modules. and each module has get() function. A.get() method will call th...
New
William
I would like to know that is there any online source for learning Phoenix Framework for building E-Commerce Store? Any advantage on build...
New
itssasanka
Hi all, Trying to get some more clarity over utc_datetime and naive_datetime for Ecto: https://hexdocs.pm/ecto/Ecto.Schema.html#module-...
New
malloryerik
Hi, this is for people who, like me, have had some friction using .html.heex templates in VSCode. The solution seems to be, in a hyphena...
New
quazar
How to set Jason to encode all fields in ecto schema, I don’t care about security and implementing only is taking long list of attributes...
New
jononomo
I am trying to figure out how Mix knows whether the environment is test, dev, or prod -- where is this set? Thanks.
New
nsuchy
Hi. I’ve noticed that Windows Powershell has it’s own IEX command and you cannot access Elixir’s IEX due to the conflict. This isn’t a cr...
New
chrisalley
ExUnit now has describe blocks which is a welcome addition coming from RSpec. In the docs, it states that nested hierarchies of describe ...
New
belgoros
I’m not a pro in using Regex and can’t figure out why the following behaviour happens, especially if we take into account the difference ...
New
vrod
I am using the Starship cross-shell prompt – it seems pretty nice, but I get some errors: [WARN] - (starship::utils): Executing command ...
New

We're in Beta

About us Mission Statement