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.

Last Post!

devinit

devinit

I have the same problem, how did you answer?

Where Next?

Popular in Questions Top

baxterw3b
Hi guys, i’m new in the Elixir world, and i have to say, that i love it! i’m having some problem to understand anonymous functions with ...
New
hariharasudhan94
lets say i have a sample like a = 20; b = 10; if (a &gt; b) do {:ok, "a"} end if (a &lt; b) do {:ok, b} end if (a == b) do {:ok, "equa...
New
fireproofsocks
Forgive me if this is obvious, but how does one delete a database record WITHOUT selecting it first? Ecto.Repo — Ecto v3.14.0 has exampl...
New
bsollish-terakeet
Credo is smart enough to check for (something like) this: assert length(the_list) == 0 with this response: Checking if an enum is empt...
New
shijith.k
I am trying to start a new phoenix project with elixir 1.9, but mix phx.new does not work. It says that ** (Mix) The task "phx.new" could...
New
romenigld
I am trying to run a deploy with docker and I successfully runned with this command: docker build -t romenigld/blog-prod . but when I t...
New
senggen
Erlang/OTP 25 [erts-13.2.2] [source] [64-bit] [smp:8:8] [ds:8:8:10] [async-threads:1] 15:22:35.803 [error] gen_event {lager_file_backend...
New

Other popular topics Top

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
grych
Hi folks, Few months ago I have announced the proof-of-concept of the library to manipulate the browsers DOM objects directly from Elixi...
639 54006 488
New
New
jononomo
For some reason my phoenix channels are working for me in my local dev environment, but as soon as I deploy via Docker, I get a 403 error...
New
openscript
Hello! Sorry for this astonishing simple question, but I’m really stuck. I try to set up the intellij-elixir plugin, but I don’t know ho...
New
ashish173
I am using Ecto timestamps with postgres, I can see the timestamps() use the :naive_dateime but for my use case I wanted to store the ti...
New

We're in Beta

About us Mission Statement