Skip to content
Merged
Show file tree
Hide file tree
Changes from all commits
Commits
File filter

Filter by extension

Filter by extension


Conversations
Failed to load comments.
Loading
Jump to
Jump to file
Failed to load files.
Loading
Diff view
Diff view
2 changes: 2 additions & 0 deletions .github/workflows/main.yml
Original file line number Diff line number Diff line change
Expand Up @@ -29,6 +29,8 @@ jobs:
ports:
- 5672:5672
- 15672:15672
volumes:
- ./conf/:/etc/rabbitmq/

steps:
- uses: actions/checkout@v3
Expand Down
1 change: 1 addition & 0 deletions conf/enabled_plugins
Original file line number Diff line number Diff line change
@@ -0,0 +1 @@
[rabbitmq_stream_management,rabbitmq_consistent_hash_exchange].
2 changes: 2 additions & 0 deletions docker-compose.yml
Original file line number Diff line number Diff line change
Expand Up @@ -10,3 +10,5 @@ services:
environment:
RABBITMQ_DEFAULT_USER: "rabbit"
RABBITMQ_DEFAULT_PASS: "rabbit"
volumes:
- ./conf/:/etc/rabbitmq/
4 changes: 2 additions & 2 deletions src/exchange.ts
Original file line number Diff line number Diff line change
Expand Up @@ -4,15 +4,15 @@ export type ExchangeOptions = {
arguments: Record<string, string>
auto_delete: boolean
durable: boolean
type: ExchangeType
type: ExchangeType | string
}

export interface ExchangeInfo {
name: string
arguments: Record<string, string>
autoDelete: boolean
durable: boolean
type: ExchangeType
type: ExchangeType | string
}

export interface Exchange {
Expand Down
1 change: 1 addition & 0 deletions src/management.ts
Original file line number Diff line number Diff line change
Expand Up @@ -200,6 +200,7 @@ export class AmqpManagement implements Management {
type: options.type ?? "direct",
durable: options.durable ?? true,
auto_delete: options.auto_delete ?? false,
arguments: options.arguments ?? {},
})
.build()

Expand Down
15 changes: 15 additions & 0 deletions test/e2e/management.test.ts
Original file line number Diff line number Diff line change
Expand Up @@ -114,6 +114,21 @@ describe("Management", () => {
})
})

test("create an exchange with custom type", async () => {
const customType = "x-consistent-hash" // requires plugin rabbitmq_consistent_hash_exchange enabled
const exchange = await management.declareExchange(exchangeName, {
type: customType,
auto_delete: true,
durable: false,
})

await eventually(async () => {
const exchangeInfo = await getExchangeInfo(exchange.getInfo.name)
expect(exchangeInfo.ok).to.eql(true)
expect(exchangeInfo.body.type).to.eql(customType)
})
})

test("delete an exchange through the management", async () => {
await createExchange(exchangeName)
await eventually(async () => {
Expand Down