Skip to content

Commit

Permalink
Update README.md
Browse files Browse the repository at this point in the history
  • Loading branch information
bedrock-adam authored Nov 16, 2024
1 parent 7e9896c commit 773de59
Showing 1 changed file with 38 additions and 9 deletions.
47 changes: 38 additions & 9 deletions README.md
Original file line number Diff line number Diff line change
Expand Up @@ -7,7 +7,7 @@

Outboxer is an ActiveRecord implementation of the transactional outbox pattern for PostgreSQL and MySQL databases.

## Installation
## Setup

### 1. add gem to gemfile

Expand All @@ -21,27 +21,25 @@ gem 'outboxer'
bundle install
```

## Set up

### 1. generate schema
### 3. generate schema

```bash
bin/rails g outboxer:schema
```

### 2. migrate schema
### 4. migrate schema

```bash
bin/rake db:migrate
```

### 3. generate publisher
### 5. generate publisher

```bash
bin/rails g outboxer:publisher
```

### 4. after model creation, queue message
### 6. queue message after model creation

```ruby
class Event < ActiveRecord::Base
Expand All @@ -53,7 +51,9 @@ class Event < ActiveRecord::Base
end
```

### 5. publish message out of band
### 7. publish message out of band

#### Sidekiq

```ruby
Outboxer::Publisher.publish do |message|
Expand All @@ -64,12 +64,41 @@ Outboxer::Publisher.publish do |message|
end
```

### 6. run publisher
#### Bunny

```ruby
Outboxer::Publisher.publish do |message|
case message[:messageable_type]
when 'Event'
queue.publish({ 'id' => message[:messageable_id] }.to_json, persistent: true)
end
end
```

### 8. run publisher

```bash
bin/outboxer_publisher
```

## Testing

To confirm outboxer is set up correctly:

1. Open your Rails console:

```bash
bin/rails c
```

2. Run the following command to create a test event:

```ruby
Event.create!
```

3. Observe that the message was published via sidekiq, bunny etc

## Management

Outboxer provides a sidekiq like UI to help manage your messages.
Expand Down

0 comments on commit 773de59

Please sign in to comment.