PracHub
QuestionsPremiumCoachesLearningGuidesInterview Prep
|Home/Coding & Algorithms/Amazon

Implement Event Filtering and Queue Routing

Last updated: Jun 13, 2026

Quick Overview

This question evaluates parsing and evaluation of domain-specific filter expressions, JSON traversal and type-aware comparisons, boolean logic handling, and in-memory routing with subscription-order preservation.

  • medium
  • Amazon
  • Coding & Algorithms
  • Software Engineer

Implement Event Filtering and Queue Routing

Company: Amazon

Role: Software Engineer

Category: Coding & Algorithms

Difficulty: medium

Interview Round: Technical Screen

An upstream event pipeline continuously emits events as JSON strings. You need to implement an in-memory routing service that decides which downstream queues should receive each event. Implement an `EventRouter` with the following behavior: - `void subscribe(String queueName, String filterExpression)`: registers a queue with a filter expression. - `List<String> route(String eventJson)`: parses the incoming JSON event, evaluates all registered filters, and returns the names of every queue whose filter matches the event. Return queue names in subscription order. In a real system this method would send to queues, but for this exercise returning queue names is enough. Filter-expression requirements: - A filter compares JSON fields using dot paths, such as `type`, `region`, or `detail.userId`. - Support comparison operators: `==`, `!=`, `>`, `>=`, `<`, `<=`. - Support boolean operators: `AND`, `OR`, `NOT`, and parentheses. - Values may be quoted strings, numbers, booleans, or `null`. - Missing fields should be treated as `null`. - Use JSON type-aware comparison where possible; for example, numeric comparisons should only be applied to numbers. Example: ```text subscribe("usOrders", "type == \"order\" AND region == \"us\"") subscribe("largeOrders", "type == \"order\" AND amount >= 100") subscribe("errors", "detail.level == \"error\" OR type == \"failure\"") route("{\"type\":\"order\",\"region\":\"us\",\"amount\":125}") => ["usOrders", "largeOrders"] ``` You may assume a standard JSON parser/helper is available for converting the event string into a traversable JSON object. Focus on the service structure, filter parsing/evaluation, and routing behavior.

Quick Answer: This question evaluates parsing and evaluation of domain-specific filter expressions, JSON traversal and type-aware comparisons, boolean logic handling, and in-memory routing with subscription-order preservation.

Related Interview Questions

  • Implement Datacenter Router Commands - Amazon (hard)
  • Determine if all courses can be completed - Amazon (medium)
  • Replace Delimited Tokens in a String - Amazon (medium)
  • Minimize Circular Redistribution Cost - Amazon (medium)
  • Find the Most Common Visit Pattern - Amazon (hard)
Amazon logo
Amazon
May 30, 2026, 12:00 AM
Software Engineer
Technical Screen
Coding & Algorithms
0
0

An upstream event pipeline continuously emits events as JSON strings. You need to implement an in-memory routing service that decides which downstream queues should receive each event.

Implement an EventRouter with the following behavior:

  • void subscribe(String queueName, String filterExpression) : registers a queue with a filter expression.
  • List<String> route(String eventJson) : parses the incoming JSON event, evaluates all registered filters, and returns the names of every queue whose filter matches the event. Return queue names in subscription order. In a real system this method would send to queues, but for this exercise returning queue names is enough.

Filter-expression requirements:

  • A filter compares JSON fields using dot paths, such as type , region , or detail.userId .
  • Support comparison operators: == , != , > , >= , < , <= .
  • Support boolean operators: AND , OR , NOT , and parentheses.
  • Values may be quoted strings, numbers, booleans, or null .
  • Missing fields should be treated as null .
  • Use JSON type-aware comparison where possible; for example, numeric comparisons should only be applied to numbers.

Example:

subscribe("usOrders", "type == \"order\" AND region == \"us\"")
subscribe("largeOrders", "type == \"order\" AND amount >= 100")
subscribe("errors", "detail.level == \"error\" OR type == \"failure\"")

route("{\"type\":\"order\",\"region\":\"us\",\"amount\":125}")
=> ["usOrders", "largeOrders"]

You may assume a standard JSON parser/helper is available for converting the event string into a traversable JSON object. Focus on the service structure, filter parsing/evaluation, and routing behavior.

Submit Your Answer

Sign in to leave a comment

Loading comments...

Browse More Questions

More Coding & Algorithms•More Amazon•More Software Engineer•Amazon Software Engineer•Amazon Coding & Algorithms•Software Engineer Coding & Algorithms
PracHub

Master your tech interviews with 8,500+ real questions from top companies.

Product

  • Questions
  • Learning Tracks
  • Interview Guides
  • Resources
  • Premium
  • For Universities
  • Student Access

Browse

  • By Company
  • By Role
  • By Category
  • Topic Hubs
  • SQL Questions
  • Compare Platforms
  • Discord Community

Support

  • support@prachub.com
  • (916) 541-4762

Legal

  • Privacy Policy
  • Terms of Service
  • About Us

© 2026 PracHub. All rights reserved.