Giter Site home page Giter Site logo

Comments (5)

noozo avatar noozo commented on May 3, 2024

Would awesome. Had to kill some brain cells trying to dig out how to simply do this (which in reality in not directly related to Broadway :)):

def broadcast(queue_name, event_type, message_struct) do
    struct = %{event_type: event_type, body: message_struct}

    IO.puts("Broadcasting '#{event_type}' to queue '#{queue_name}'.")

    # TODO: Eventually store the broadcasted message in the database as
    # an history/log entry (or send to datadog)

    ExAws.SQS.send_message(
      queue_name,
      Poison.encode!(struct)
    )
    |> ExAws.request(%{
      secret_access_key: System.get_env("AWS_SECRET_ACCESS_KEY"),
      access_key_id: System.get_env("AWS_ACCESS_KEY_ID"),
      region: System.get_env("AWS_REGION"),
      host: "sqs.eu-west-1.amazonaws.com",
      scheme: "https"
    })
  end

Would be great to be able to post a message to a queue reusing the credentials i already define for Broadway. If there is, please let me know how :)

And while i'm here, is there a way to fake the producer for testing purposes? Would love to test my worker without having to have AWS queues setup or having to install RabbitMQ :(

from broadway.

josevalim avatar josevalim commented on May 3, 2024

You can share credentials by simply moving the code to a function and calling that function from both! For a faker, you can use Mox or similar.

from broadway.

msaraiva avatar msaraiva commented on May 3, 2024

You'll also be able to use a DummyProducer in your tests after #91 is merged.

from broadway.

noozo avatar noozo commented on May 3, 2024

Cool, thank you guys!

from broadway.

noozo avatar noozo commented on May 3, 2024

I was trying to create a fake producer as well, but couldn't figure out the @behaviour thing. Total noob in Elixir here. Thanks again! :)

from broadway.

Related Issues (20)

Recommend Projects

  • React photo React

    A declarative, efficient, and flexible JavaScript library for building user interfaces.

  • Vue.js photo Vue.js

    🖖 Vue.js is a progressive, incrementally-adoptable JavaScript framework for building UI on the web.

  • Typescript photo Typescript

    TypeScript is a superset of JavaScript that compiles to clean JavaScript output.

  • TensorFlow photo TensorFlow

    An Open Source Machine Learning Framework for Everyone

  • Django photo Django

    The Web framework for perfectionists with deadlines.

  • D3 photo D3

    Bring data to life with SVG, Canvas and HTML. 📊📈🎉

Recommend Topics

  • javascript

    JavaScript (JS) is a lightweight interpreted programming language with first-class functions.

  • web

    Some thing interesting about web. New door for the world.

  • server

    A server is a program made to process requests and deliver data to clients.

  • Machine learning

    Machine learning is a way of modeling and interpreting data that allows a piece of software to respond intelligently.

  • Game

    Some thing interesting about game, make everyone happy.

Recommend Org

  • Facebook photo Facebook

    We are working to build community through open source technology. NB: members must have two-factor auth.

  • Microsoft photo Microsoft

    Open source projects and samples from Microsoft.

  • Google photo Google

    Google ❤️ Open Source for everyone.

  • D3 photo D3

    Data-Driven Documents codes.