Giter Club home page Giter Club logo

Comments (6)

edgurgel avatar edgurgel commented on July 16, 2024 1

terminate is not necessarily called on a shutdown: http://elixir-lang.org/docs/v1.1/elixir/GenServer.html#c:terminate/2

What I'm doing is: on init() link to the connection and the channel. This is not the best solution as it will not allow you to reuse a connection for multiple consumers but at least it's safe to clean up hanging processes. I think this should be fixed upstream (rabbitmq-client)...

from amqp.

pma avatar pma commented on July 16, 2024

@bradleyd You are correct. The channel or connection won't automatically close when a subscriber process dies. Assuming your subscriber is a GenServer, you can use the terminate callback to cleanup and close the channel. Whether you also close the connection or not will depend if you reusing the same connection for other channels (you can open up to 65535 channels in a single TCP connection).

from amqp.

bradleyd avatar bradleyd commented on July 16, 2024

@pma thanks for the response. We are seeing AWS LB close connections after N time of inactivity. The connection is closed unexpectedly--hence creating multiple connections everytime supervisor restarts our consumer.

from amqp.

bradleyd avatar bradleyd commented on July 16, 2024

@edgurgel in our case that would be fine as we only have one consumer

from amqp.

bradleyd avatar bradleyd commented on July 16, 2024

@pma maybe an example in README.md would be nice?

btw, thanks for all the help and responses

from amqp.

chvanikoff avatar chvanikoff commented on July 16, 2024

@bradleyd with AWS LB you have to enable heartbeat option to prevent connections dropping:

{:ok, conn} = AMQP.Connection.open([
  host: config[:host],
  username: config[:username],
  password: config[:password],
  connection_timeout: 2000,
  heartbeat: 30 # <- here it is, in seconds
])

from amqp.

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.