EngErik
Delaying message broadcast
Hey guys,
I have an API where i create some publications and broadcast a message for each publication that i created.
The issue is: When i create a publication, that resource will be available for users after one minute, but at this point, message is already broadcasted and user will try to acess it and gets an error.
My doubt: Is that a way to delay this message broadcast, without blocking the request sended to create a publication?
Most Liked
chrismccord
The best approach would be to publish the broadcast when the resource is available, after that one minute. What triggers the resource becoming available? Wherever that codepath is, is where you can hook in the broadcast. If it’s third-party processing, see if they support a post-back URL to your app, which you can then use to broadcast. Make sense?
sribe
??? The process which calls Task.start does not block, and I don’t see how the blocking inside of the task could possibly matter, since it’s not visible to anything.
outlog
Task.start(fn ->
:timer.sleep(60*1000)
PhoenixApp.Web.Endpoint.broadcast("channel_name", "xx_update", %{payload: %{id: 1} })
end)
but this is very hackish - you really want to broadcast directly when the publication is ready.. (as @chrismccord said..)
Popular in Questions
Other popular topics
Categories:
Sub Categories:
Forums
Popular Tags
- #ecto
- #liveview
- #troubleshooting
- #learning-elixir
- #deployment
- #library
- #erlang
- #testing
- #genserver
- #mix
- #absinthe
- #remote-other
- #otp
- #plug
- #how-to-question
- #macros
- #postgres
- #channels
- #elixirconf
- #exunit
- #discussion
- #javascript
- #code-sync
- #podcasts
- #onsite
- #dialyzer
- #docker
- #authentication
- #umbrella
- #full-time-contract
- #podcasts-by-brainlid
- #ecto-query
- #elixir-ls
- #phoenix_html
- #iex
- #blog-post
- #graphql
- #genstage
- #ai
- #websockets
- #supervisor
- #advent-of-code
- #elixirconf-us
- #distillery
- #processes
- #forms
- #api
- #metaprogramming
- #security
- #performance








