{"id":13989589,"url":"https://github.com/knockaway/sqsiphon","last_synced_at":"2025-07-22T11:30:52.941Z","repository":{"id":48121963,"uuid":"279591152","full_name":"knockaway/sqsiphon","owner":"knockaway","description":null,"archived":false,"fork":false,"pushed_at":"2021-08-05T16:27:10.000Z","size":31,"stargazers_count":18,"open_issues_count":0,"forks_count":0,"subscribers_count":4,"default_branch":"master","last_synced_at":"2024-11-29T08:39:20.162Z","etag":null,"topics":["aws","knock-oss","library","nodejs","sqs"],"latest_commit_sha":null,"homepage":"","language":"JavaScript","has_issues":true,"has_wiki":null,"has_pages":null,"mirror_url":null,"source_name":null,"license":"mit","status":null,"scm":"git","pull_requests_enabled":true,"icon_url":"https://github.com/knockaway.png","metadata":{"files":{"readme":"Readme.md","changelog":null,"contributing":null,"funding":null,"license":"LICENSE","code_of_conduct":null,"threat_model":null,"audit":null,"citation":null,"codeowners":null,"security":null,"support":null}},"created_at":"2020-07-14T13:21:54.000Z","updated_at":"2024-01-15T03:10:41.000Z","dependencies_parsed_at":"2022-08-12T19:01:06.780Z","dependency_job_id":null,"html_url":"https://github.com/knockaway/sqsiphon","commit_stats":null,"previous_names":[],"tags_count":5,"template":false,"template_full_name":null,"purl":"pkg:github/knockaway/sqsiphon","repository_url":"https://repos.ecosyste.ms/api/v1/hosts/GitHub/repositories/knockaway%2Fsqsiphon","tags_url":"https://repos.ecosyste.ms/api/v1/hosts/GitHub/repositories/knockaway%2Fsqsiphon/tags","releases_url":"https://repos.ecosyste.ms/api/v1/hosts/GitHub/repositories/knockaway%2Fsqsiphon/releases","manifests_url":"https://repos.ecosyste.ms/api/v1/hosts/GitHub/repositories/knockaway%2Fsqsiphon/manifests","owner_url":"https://repos.ecosyste.ms/api/v1/hosts/GitHub/owners/knockaway","download_url":"https://codeload.github.com/knockaway/sqsiphon/tar.gz/refs/heads/master","sbom_url":"https://repos.ecosyste.ms/api/v1/hosts/GitHub/repositories/knockaway%2Fsqsiphon/sbom","host":{"name":"GitHub","url":"https://github.com","kind":"github","repositories_count":266483486,"owners_count":23936348,"icon_url":"https://github.com/github.png","version":null,"created_at":"2022-05-30T11:31:42.601Z","updated_at":"2022-07-04T15:15:14.044Z","status":"online","status_checked_at":"2025-07-22T02:00:09.085Z","response_time":66,"last_error":null,"robots_txt_status":null,"robots_txt_updated_at":null,"robots_txt_url":"https://github.com/robots.txt","online":true,"can_crawl_api":true,"host_url":"https://repos.ecosyste.ms/api/v1/hosts/GitHub","repositories_url":"https://repos.ecosyste.ms/api/v1/hosts/GitHub/repositories","repository_names_url":"https://repos.ecosyste.ms/api/v1/hosts/GitHub/repository_names","owners_url":"https://repos.ecosyste.ms/api/v1/hosts/GitHub/owners"}},"keywords":["aws","knock-oss","library","nodejs","sqs"],"created_at":"2024-08-09T13:01:47.374Z","updated_at":"2025-07-22T11:30:52.681Z","avatar_url":"https://github.com/knockaway.png","language":"JavaScript","funding_links":[],"categories":["JavaScript"],"sub_categories":[],"readme":"# @knockaway/sqsiphon\n\n_sqsiphon_ provides a framework for writing [Amazon SQS][sqs] polling\napplications. It is designed to poll, and process messages, as quickly as\npossible. FIFO queues are supported.\n\n[sqs]: https://aws.amazon.com/sqs/\n\n## Queue Processing\n\n1. _sqsiphon_ polls for up to 10 messages (the SQS allowed maximum).\n2. The retrieved messages are inspected to determine if any are tagged as being\n   members of a FIFO queue.\n3. Messages that are not tagged for a FIFO queue are placed into a general\n   processing batch. Any FIFO tagged messages are added to a batch specifically\n   for the tagged FIFO queue. For example, consider a poll event returns three\n   messages: message `A` is untagged, message `B` is tagged for \"foo\", and\n   message `C` is tagged for \"bar\". Message `A` will be put on the general\n   processing batch and two new batches will be created: \"foo\" and \"bar\", each\n   with one message added for processing.\n4. All available processing batches are processed: the general batch's messages\n   are processed concurrently, and each FIFO batch is processed sequentially.\n5. Messages that generate an error during processing are left on the queue.\n\n**FIFO Errors:** When a message on a FIFO queue cannot be processed successfully,\nthe message, and any remaining messages in the batch, will be left on the queue.\nIt is recommened that a corresponding dead letter queue be configured so that\nthese messages will be moved there by SQS.\n\n## Example\n\n```js\nconst { SQS } = require('aws-sdk');\nconst sqs = new SQS({\n  apiVersion: '2012-11-05',\n  region: 'us-east-1'\n});\nconst sqsiphonFactory = require('@knockaway/sqsiphon');\nconst app = sqsiphonFactory({\n  sqs,\n  queueUrl: 'url for the sqs queue',\n  handler: messageHandler\n});\n\nfunction shutdown(signal) {\n  app.stop();\n}\n['SIGTERM', 'SIGINT'].forEach(signal =\u003e process.on(signal, shutdown));\n\nif ((require.main === module) === true) {\n  app.start();\n}\n\nasync function messageHandler(message) {\n  // `message` is an SQS message as returned by the `aws-sdk`\n  // ...\n  // Do something with the message or `throw Error('failed')`\n}\n```\n\n## Factory Options\n\nThis module exports a factory function which accepts an options object with the\nfollowing properties:\n\n- `logger` (optional): An object that follows the Log4j logger interface.\n  The default is an instance of [`abstract-logging`](https://npm.im/abstract-logging).\n- `sqs` (required): An instance of `SQS` from the [`aws-sdk`](https://npm.im/aws-sdk).\n- `queueUrl` (required): A string URL pointing to the SQS instance to poll.\n- `handler` (required): A function to handle received messages. Must be an\n  `async function`. The function will receive one parameter: `message`. The\n  parameter is an instance of\n  [SQS Message](https://docs.aws.amazon.com/AWSSimpleQueueService/latest/APIReference/API_Message.html).\n  If the message cannot be processed for any reason, an instance of `Error`\n  should be thrown. If no error is thrown, the message has been considered to\n  be successfully processed.\n- `tracer` (optional): an OpenTracing compliant tracer instance.\n- `receiveMessageParameters` (optional): an object that conforms to the object\n  described by\n  [`sqs.receiveMessage`](https://docs.aws.amazon.com/AWSJavaScriptSDK/latest/AWS/SQS.html#receiveMessage-property).\n  The default has: `AttributeNames: ['All']`, `MaxNumberOfMessages: 10`,\n  `MessageAttributeNames: ['All']`, and `VisibilityTimeout: 30`. The `QueueUrl`\n  is always overridden by the passed in `queueUrl` value.\n\n## App Instance\n\nThe factory returns an application instance. The application instance is\nan event emitter.\n\n### Instance Methods And Properties\n\n- `isRunning` (boolean): indicates if the application is polling for messages\n  or not.\n- `start()`: initiates the application to start polling for messages.\n- `stop()`: initiates the application to stop polling for messages. Any\n  messages currently being processed will be completed.\n\n### Instance Events\n\n- `error`: fired when an unexpected error occurs. Receives an `Error` object.\n- `request-error`: fired when a communication error occurs. Receives an\n  `Error` object.\n- `processing-error`: fired when an error occurs while processing a message.\n  Receives an object with `error` and `message` properties.\n- `fifo-processing-aborted`: fired when a FIFO batch stop processing due to an\n  error. Receives an object with `message` and `messages` properties. This event\n  will fire subsequent to a `processing-error` event.\n- `received-messages`: fired when a new batch of messages has been received.\n  Receives an array of SQS message objects.\n- `handled-message`: fired when a message has been successfully handled.\n  Receives an SQS message object.\n","project_url":"https://awesome.ecosyste.ms/api/v1/projects/github.com%2Fknockaway%2Fsqsiphon","html_url":"https://awesome.ecosyste.ms/projects/github.com%2Fknockaway%2Fsqsiphon","lists_url":"https://awesome.ecosyste.ms/api/v1/projects/github.com%2Fknockaway%2Fsqsiphon/lists"}