Sha256: 5470e36f315ceaa089399e1f77e9c393933e4895d02a443c1d365db9c560280e

Contents?: true

Size: 771 Bytes

Versions: 166

Compression:

Stored size: 771 Bytes

Contents

class UserSubscriber < ActionSubscriber::Base

  # In this example, we are in an application called "alice"
  # We want to listen to events in bob when bob creates a user.
  # When bob creates a user, bob publishes to "bob.user.created",
  # on an exchange called events.
  #
  # This subscriber listens to bob's events and executes the created
  # method every time bob publishes to the created queue.

  publisher :bob
  exchange :events

  # Will create the queue:
  #   alice.bob.user.created
  # With the routing key:
  #   bob.user.created
  #
  def created
    send_email(payload)
  end

  private

  # This is a private method and will be invisible to ActionSubscriber
  #
  def send_email(user)
    # MyMailer.send_welcome_email(user.email, user.name)
  end
end

Version data entries

166 entries across 166 versions & 1 rubygems

Version Path
action_subscriber-5.3.3-java examples/basic_subscriber.rb
action_subscriber-5.3.3 examples/basic_subscriber.rb
action_subscriber-5.3.2-java examples/basic_subscriber.rb
action_subscriber-5.3.2 examples/basic_subscriber.rb
action_subscriber-5.3.1-java examples/basic_subscriber.rb
action_subscriber-5.3.1 examples/basic_subscriber.rb
action_subscriber-5.3.1.pre-java examples/basic_subscriber.rb
action_subscriber-5.3.1.pre examples/basic_subscriber.rb
action_subscriber-5.3.0-java examples/basic_subscriber.rb
action_subscriber-5.3.0 examples/basic_subscriber.rb
action_subscriber-5.2.4-java examples/basic_subscriber.rb
action_subscriber-5.2.4 examples/basic_subscriber.rb
action_subscriber-5.2.3-java examples/basic_subscriber.rb
action_subscriber-5.2.3 examples/basic_subscriber.rb
action_subscriber-5.2.2-java examples/basic_subscriber.rb
action_subscriber-5.2.2 examples/basic_subscriber.rb
action_subscriber-5.2.1-java examples/basic_subscriber.rb
action_subscriber-5.2.1 examples/basic_subscriber.rb
action_subscriber-5.2.0-java examples/basic_subscriber.rb
action_subscriber-5.2.0 examples/basic_subscriber.rb