Creating Your First Queue
After Getting Started with PubSub+ Cloud and Trying Out Your Event Broker Service, you may want to create a queue so you can send and receive some guaranteed messages. This tutorial walks you through creating a queue. You will also make sure the queue is working by connecting a publisher and publishing a matching message to that queue.
This tutorial shows you how to do the following tasks:
- Creating a Queue
- Mapping a Topic to a Queue
- Publishing a Message to the Queue
- Confirming the Message Is In the Queue
To create a queue, do the following:
Log in to the PubSub+ Cloud Console if you have not done so yet. The URL to access the Cloud Console differs based on your authentication scheme. For more information, see Login URLs for PubSub+ Cloud Console.
- On the navigation bar, click Cluster Manager .
- On the Services page, click the card for your event broker service to navigate to details of the service.
- On the service details page, select the Manage tab.
The Manage page shows various options to manage your event broker service.
- On the Manage page, click the Queues tile.
The Queues page connects you to another web interface called PubSub+ Broker Manager. You are logged into the event broker.
- Click the +Queue button.
- Enter a name for your queue and click Create. You can use most characters in your queue name, including spaces. Some punctuation marks ('<>*?&;) are not allowed. If you use a slash (/) in the name, it cannot be the first character.
- On the Edit Queue Settings page, click Apply to accept all the default settings.
- Your new queue is displayed on the summary page. The queue is empty, so you will see zeros (0) in both the Messages Queued columns.
While it is possible to publish directly to a queue by its name, it's best to map a topic to a queue for more flexibility. In this case, mapping a topic to a queue allows us to use the Try Me! tab to publish a message to our queue to test it out.
To map a topic to a queue, do the following.
- From the queue summary, click anywhere in the row describing the queue to open the Queue Detail pages.
- From the queue detail view, select the Subscriptions tab.
On the Subscriptions tab, click Subscription.
- Enter the topic
try-meas the subscription and click the Create button. This is the default topic of the Try Me! tab.
- The topic
try-meis now mapped to the queue. Messages published to that topic will go into the queue.
We will use the publisher CodePen project on the Try Me! tab to publish a message into our queue. We are not going to use a subscriber connection.
To publish a message to the queue, follow the steps below.
- On the page for your service, select the Try Me! tab.
- In the Publisher CodePen, click Connect.
- Validate that the publisher is connected.
- In the Publisher CodePen (step 2), publish a message with try-me as the topic name.
In PubSub+ Broker Manager, you can confirm that the message is in the queue.
- In the PubSub+ Broker Manager, on the Queues page, your queue is listed on the summary page.
- Verify that the Messages Queued column shows 1 message (or more if you published multiple messages), and that a non-zero value is shown in the Messages Queued Quota (MB) column.
Congratulations! Your queue is working.
- To see more details about the message in the queue, click anywhere in the row describing the queue, then select the Messages Queued tab.
For example, you can see the message ID assigned to the message and the time when it was published.
Well done. You have now created a queue in your event broker service and published a message to it. Want to learn more?