BYU Web Service Manual
HomeToolsWeb Service manual Edit Page

Spewer

Let’s take a moment to look at that queue of events we keep talking about.

The queues for Sandbox can be found at http://poto1.byu.edu:15672/#/.

The queues for Production can be found at http://naka1.byu.edu:15672/#/.

Take a moment to check out these sites (ask around for the username and password).

Go to Queues

Look for your person number (If you don’t know it already, you can find it by calling the Persons API) and then click on it. This is your queue right now. You may need it later for debugging. If it is full, then you might have a problem somewhere. It should look a bit like this-

Now let’s make a spewer! This is so that someone else can consume an event raised by you! First let’s figure out what kind of event we want to raise. Let’s raise an event for when some one’s favorite color is changed, that way, if another person is storing favorite colors in their database they can set up a subscription and webhook to tell them when to change it. Let’s try raising an event in Event Hub in WSO2 first to get a feel for what we want.

Note that now we want to be working in sandbox, not production, so we don’t have to worry about having the event we raise and the changed name event in the same queue. Also, don’t forget to generate new keys if you need to.

You’ll notice that the entity is “WSM”, which stands for Web Service Manual. All events have an entity and a domain, which are usually set up earlier.

You won’t be making entity, but here is how you could make one-

Now that we know how to send an event, let’s write some code to do it for us.

In your favoritecolor.js controller, create a function to call the Event Hub API. It will be a lot like your callPersonsAPI function.

Make a new directory in your project called “spewer”. In spewer, make an index.js file.

This will be pretty simple. It will just create the object that the Event Hub API is looking for.

Now let’s import and use that function in our controller.

We don’t have anything that can consume the event raised here, so there’s no easy way to test it, but don’t worry- we’ll take care of that when we build a Lambda in later module!

Contributing Source Issue Tracker