Skip to content

Commit

Permalink
Account for optional headers
Browse files Browse the repository at this point in the history
  • Loading branch information
nikitaeverywhere committed Mar 13, 2024
1 parent 011581e commit d98e132
Show file tree
Hide file tree
Showing 3 changed files with 14 additions and 14 deletions.
16 changes: 8 additions & 8 deletions package-lock.json

Some generated files are not rendered by default. Learn more about how customized files appear on GitHub.

6 changes: 3 additions & 3 deletions package.json
Original file line number Diff line number Diff line change
@@ -1,6 +1,6 @@
{
"name": "node-message-bus",
"version": "3.3.3",
"version": "3.3.4",
"description": "Minimalistic and complete AMQP message bus implementation",
"main": "lib/index.js",
"files": [
Expand Down Expand Up @@ -53,8 +53,8 @@
"typescript": "^5.0.4"
},
"dependencies": {
"@types/amqplib": "^0.10.1",
"amqp-connection-manager": "^4.1.13",
"@types/amqplib": "^0.10.5",
"amqp-connection-manager": "^4.1.14",
"amqplib": "^0.10.3"
}
}
6 changes: 3 additions & 3 deletions src/consumer.ts
Original file line number Diff line number Diff line change
Expand Up @@ -39,7 +39,7 @@ const backoffRetryMessage = async <DataType = any>({
error?: Error;
}) => {
const currentBackoffSeconds =
parseInt(message.properties.headers[HEADER_NAME_EXP_BACKOFF_SEC]) || 0;
parseInt(message.properties.headers?.[HEADER_NAME_EXP_BACKOFF_SEC]) || 0;
const nextBackoffSeconds = Math.min(
MAX_EXP_BACKOFF,
currentBackoffSeconds
Expand Down Expand Up @@ -156,8 +156,8 @@ export async function consumeMessages<Message extends IMessage>(
}

if (
message.properties.headers[HEADER_NAME_TARGET_QUEUE] &&
message.properties.headers[HEADER_NAME_TARGET_QUEUE] !== queueName
message.properties.headers?.[HEADER_NAME_TARGET_QUEUE] &&
message.properties.headers?.[HEADER_NAME_TARGET_QUEUE] !== queueName
) {
log(
`Skipping message "${message.fields.routingKey}" in queue "${queueName}" because it is intended for queue "${message.properties.headers[HEADER_NAME_TARGET_QUEUE]}" due to backoff.`
Expand Down

0 comments on commit d98e132

Please sign in to comment.