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 Dec 20, 2024
1 parent 2d73771 commit 949ab80
Showing 1 changed file with 16 additions and 56 deletions.
72 changes: 16 additions & 56 deletions README.md
Original file line number Diff line number Diff line change
Expand Up @@ -21,10 +21,10 @@ gem 'outboxer'
bundle install
```

### 3. generate schema
### 3. generate schema, publisher script and job

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

### 4. migrate schema
Expand All @@ -33,81 +33,41 @@ bin/rails g outboxer:schema
bin/rake db:migrate
```

### 5. seed database

```bash
bin/rake outboxer:db:seed
```

### 6. queue message after event creation

#### new event

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

#### existing event
### 5. handle published message in sidekiq job

```ruby
class Event < ActiveRecord::Base
after_create do |event|
Outboxer::Message.queue(messageable: event)
module OutboxerIntegration
module Message
class PublishJob
include Sidekiq::Job

def perform_async(args)
# TODO: handle published message here
end
end
end
end
```

### 7. generate publisher

#### sidekiq

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

#### custom

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

### 8. publish message out of band

#### Sidekiq

```ruby
Outboxer::Publisher.publish do |message|
OutboxerIntegration::Message::PublishJob.perform_async(message)
end
```

#### Custom

```ruby
Outboxer::Publisher.publish do |message|
# publish message to custom broker here
end
```

### 9. run publisher
### 6. run publisher

```bash
bin/outboxer_publisher
```

### 10. open rails console
### 7. open rails console

```bash
bin/rails c
```

### 11. create event
### 8. create event

```ruby
Event.create!
```

### 12. Observe published message
### 9. Observe published message

Confirm the message has been published out of band

Expand Down

0 comments on commit 949ab80

Please sign in to comment.