newscred / webhook-broker

This is a fully HTTP based Pub/Sub Broker with a goal to simplify system architecture in SOA or Microservice architecture. It aims to solve the inter service communication problem.
Apache License 2.0
18 stars 25 forks source link

AR-292: Add endpoints for pull based consumer #141

Closed RedwanPlague closed 1 year ago

RedwanPlague commented 1 year ago

Ticket: AR-292

Description

GET url: /channel/{channel-id}/consumer/{consumer-id}/queued-jobs?limit=25

The endpoint requires the X-Broker-Channel-Token and X-Broker-Consumer-Token headers

The response structure is:

{
    Result: [
        {
            ID: string,
            Priority: integer
            Message: {
                MessageID: string
            Payload: string
            ContentType: string
            }
        },
        ...
    ]
}

Result holds all the jobs with status JobQueued for a specific consumer. The jobs are sorted in descending order of message priority. The value of limit will default to 25. The maximum value is 100. A higher value will get clipped to 100.


POST url: /channel/{channel-id}/consumer/{consumer-id}/job/{job-id}

The endpoint requires the X-Broker-Channel-Token and X-Broker-Consumer-Token headers and a body of the form:

{
    "NextState": "INFLIGHT"/"DELIVERED"/"DEAD"
}

Allowed transitions are: JobQueued -> JobInflight JobInflight -> JobDelivered JobInflight -> JobDead JobDead -> JobInflight (this transition increases job.RetryAttemptCount by 1)

If the current job status and requested next job status are the same, a 202 Accepted response will be given with no DB change.

All other transitions are invalid and will get a 400 Bad Request response.

ImperishableMe commented 1 year ago

Looks good to me, please manually functionally test the APIs before merging it! Thank you

I have tested the endpoints manually. Everything is working as expected.

imyousuf commented 1 year ago

Addresses part of #53