<commit_before>[ ![Codeship Status for
teamsnap/emque-consuming](https://www.codeship.io/projects/83d08620-2023-0132-2bcd-1a9cd91404f6/status)](https://www.codeship.io/projects/35892)

# Emque::Consuming

Emque Consuming is a Ruby application framework that includes everything needed
to create and run application capable of consuming messages from a message
broker in a Pub/sub architecture. Messages can be produced with the
[emque-producing](https://github.com/teamsnap/emque-producing) library.

## Adapters

We currently only support RabbitMQ. If you would like to add your own adapter,
take a look at [the adapters directory](https://github.com/teamsnap/emque-consuming/tree/socket-control/lib/emque/consuming/adapters).

## Installation

Add this line to your application's Gemfile:

```ruby
gem "emque-consuming", :git => "https://github.com/teamsnap/emque-consuming"
# make sure you have bunny for rabbitmq unless you're using a custom adapter
gem "bunny", "~> 1.7"

```

And then execute:

    $ bundle

Or install it yourself as:

    $ gem install emque-consuming

## Setup

### Easy

Using the `new` generator is the easiest way to get up and running quickly.

```
emque <options> new name
```

This command will create a directory "name" with barebones directories and files
you'll need to get started. You can also use the following command line options
to customize your application's configuration. Options will be added to the
config/application.rb file generated.

```
emque <options> (start|stop|new|console|help) <name (new only)>
    # ...
    -S, --socket PATH                PATH to the application's unix socket
    -b, --bind IP:PORT               IP & port for the http status application to listen on.
    # ...
    -e, --error-limit N              Set the max errors before application suicide
    -s, --status                     Run the http status application
    -x, --error-expiration SECONDS   Expire errors after SECONDS
        --app-name NAME              Run the application as NAME
    # ...
```

### Custom

Configure Emque::Consuming in your config/application.rb file. Here is an example:

```ruby
# config/application.rb
require "emque/consuming"

module Example
  class Application
    include Emque::Consuming::Application

    initialize_core!

    config.set_adapter(:rabbit_mq)
  end
end
```

You'll also want to set up a routes.rb file:

```ruby
# config/routes.rb<commit_msg>Add config details to example<commit_after>[ ![Codeship Status for
teamsnap/emque-consuming](https://www.codeship.io/projects/83d08620-2023-0132-2bcd-1a9cd91404f6/status)](https://www.codeship.io/projects/35892)

# Emque::Consuming

Emque Consuming is a Ruby application framework that includes everything needed
to create and run application capable of consuming messages from a message
broker in a Pub/sub architecture. Messages can be produced with the
[emque-producing](https://github.com/teamsnap/emque-producing) library.

## Adapters

We currently only support RabbitMQ. If you would like to add your own adapter,
take a look at [the adapters directory](https://github.com/teamsnap/emque-consuming/tree/socket-control/lib/emque/consuming/adapters).

## Installation

Add this line to your application's Gemfile:

```ruby
gem "emque-consuming", :git => "https://github.com/teamsnap/emque-consuming"
# make sure you have bunny for rabbitmq unless you're using a custom adapter
gem "bunny", "~> 1.7"

```

And then execute:

    $ bundle

Or install it yourself as:

    $ gem install emque-consuming

## Setup

### Easy

Using the `new` generator is the easiest way to get up and running quickly.

```
emque <options> new name
```

This command will create a directory "name" with barebones directories and files
you'll need to get started. You can also use the following command line options
to customize your application's configuration. Options will be added to the
config/application.rb file generated.

```
emque <options> (start|stop|new|console|help) <name (new only)>
    # ...
    -S, --socket PATH                PATH to the application's unix socket
    -b, --bind IP:PORT               IP & port for the http status application to listen on.
    # ...
    -e, --error-limit N              Set the max errors before application suicide
    -s, --status                     Run the http status application
    -x, --error-expiration SECONDS   Expire errors after SECONDS
        --app-name NAME              Run the application as NAME
    # ...
```

### Custom

Configure Emque::Consuming in your config/application.rb file. Here is an example:

```ruby
# config/application.rb
require "emque/consuming"

module Example
  class Application
    include Emque::Consuming::Application

    initialize_core!

    config.set_adapter(:rabbit_mq, :url => ENV["RABBITMQ_URL"], :prefetch => 10)

    # customize the error thresholds
    # config.error_limit = 10
    # config.error_expiration = 300

    # enable the status application
    # config.status = :on

    # errors will be logged, but if more is needed, that can be added
    # config.error_handlers << Proc.new {|ex, context|
    #  send an email, send to HoneyBadger, etc
    # }

    # do something when shutdown occurs
    # config.shutdown_handlers << Proc.new { |context|
    #   notify slack, pagerduty or send an email
    # }
  end
end
```

You'll also want to set up a routes.rb file:

```ruby
# config/routes.rb
{'fraction_non_alphanumeric': 0.09784013291489754, 'fraction_numerical': 0.012737677681373454, 'mean_word_length': 3.3240223463687153, 'pattern_counts': {'":': 0, '<': 13, '<?xml version=': 0, '>': 15, 'https://': 10, 'lorem ipsum': 0, 'www.': 4, 'xml': 0}, 'pii_count': 0, 'substrings_counts': 0, 'word_list_counts': {'cursed_substrings.json': 0, 'profanity_word_list.json': 0, 'sexual_word_list.json': 0, 'zh_pornsignals.json': 0}}
{'dir': 'git-commits-cleaned', 'id': '5023093', 'n_tokens_mistral': 1699, 'n_tokens_neox': 1537, 'n_words': 580}