# Redmine Event Outbox

Small Redmine 3.4-compatible plugin that records selected Redmine changes into a
local database outbox table for external workers.

## Events Captured

- `issue.created`
- `issue.updated`
- `journal.created`
- `contact.created` when `redmine_contacts` is installed
- `contact.updated` when `redmine_contacts` is installed
- `helpdesk_ticket.created` when `redmine_contacts_helpdesk` is installed
- `helpdesk_ticket.updated` when `redmine_contacts_helpdesk` is installed
- `journal_message.created` when `redmine_contacts_helpdesk` is installed
- `journal_message.updated` when `redmine_contacts_helpdesk` is installed

The plugin does not publish to Redis, RabbitMQ, webhooks, or external search
services directly from Redmine request callbacks. It only writes local database
rows.

## Install

Copy this directory to the Redmine plugins directory:

```sh
cp -a redmine_event_outbox /path/to/redmine/plugins/
```

Run the plugin migration:

```sh
cd /path/to/redmine
RAILS_ENV=production bundle exec rake redmine:plugins:migrate NAME=redmine_event_outbox
```

Restart Redmine. For Passenger:

```sh
touch tmp/restart.txt
```

## Verify

List the rake task:

```sh
RAILS_ENV=production bundle exec rake -T redmine_event_outbox
```

Dump pending events:

```sh
RAILS_ENV=production bundle exec rake redmine_event_outbox:dump LIMIT=20
```

Create or update a low-risk test issue, then run the dump task again. You should
see JSON rows in `event_outbox_events`.

## Notes

- Payloads are JSON serialized into a `text` column for MySQL and Redmine 3.4
  compatibility.
- Outbox write failures are rescued and logged so normal Redmine saves are not
  intentionally failed by this plugin.
- Consumers should treat events as at-least-once and idempotent.
