# Forge Events

Library for [asynchronous data processing](https://developer.atlassian.com/platform/forge/runtime-reference/async-events-api/) in Forge.

## Requirements

See [Set up Forge](https://developer.atlassian.com/platform/forge/set-up-forge/) for details of the software required to develop Forge apps.

## Usage

### Pushing events to the queue

```typescript

async function pushEvent() {
  const { jobId } = await queue.push({
    body: {
      hello: 'world'
    }
  });

  const jobProgress = queue.getJob(jobId);
  const { success, inProgress, failed } = await jobProgress.getStats();
}
```

### Consuming events from the queue

```typescript
import { AsyncEvent } from '@forge/events';

export async function eventListener(event: AsyncEvent, context) {
  const jobProgress = queue.getJob(event.jobId);

  try {
    // process the event
  } catch (error) {
    await jobProgress.cancel();
  }
}
```

## Support

See [Get help](https://developer.atlassian.com/platform/forge/get-help/) for how to get help and provide feedback.
