imodeljsjumpstart.github.io

View on GitHub

Challenge: Improve Your iModel.js Agent’s Reliability!

Summary

By completing this you will learn how to:

Setup

  1. Install the required tools

  2. Clone the jumpstart-agent repo

  3. Follow the setup instructions in the jumpstart-agent README

Goals

Goal Follow the instructions to update the agent so you never miss an iModelHub event.

Bonus Create a new “start:prod” npm script to automatically restart the agent anytime a fatal error occurs.

Solution

The best way to learn is by doing! But, if you want to skip ahead you can go right to the full solution.

Instructions

  1. Update MyAgent.ts to reuse an existing iModelHub subscription ID (only creating a new event subscription in iModelHub when necessary).

    If you need help try these hints.

  2. Update MyAgent.ts to never delete the iModelHub subscription.

    If you need help try these hints.

  3. Test out your new behavior!
    • Start your agent via npm start, wait for it to begin listening, and then stop it.
    • While your agent is stopped, synchronize new changes via the iTwin Synchronizer.
    • Re-start your agent (npm start) after iTwin Synchronizer has finished pushing the changeset(s).
    • If you completed steps 1 & 2 correctly, your agent will pick right up where it left off and see the event it missed!
  4. (Bonus) Create a new start:prod npm script in package.json to automatically restart the agent anytime a fatal error occurs.

    If you need help try these hints.

    Conclusion

So, were you up to the challenge? Check out how we solved it by viewing our full solution. Let us know if you have a better way.

Feedback is welcome! Let us know via the iModel.js community.