From 6d51a3bee3691a84b9344dd06b7dda6b45c12055 Mon Sep 17 00:00:00 2001 From: Balazs Czoma Date: Fri, 9 Feb 2024 10:35:35 -0500 Subject: [PATCH] Added exclusive queue example --- README.md | 2 +- examples/exclusive-queue/README.md | 51 ++++++++++++++++++++++++++ examples/exclusive-queue/main.tf | 30 +++++++++++++++ examples/exclusive-queue/providers.tf | 9 +++++ examples/non-exclusive-queue/README.md | 2 +- examples/non-exclusive-queue/main.tf | 6 +-- 6 files changed, 95 insertions(+), 5 deletions(-) create mode 100644 examples/exclusive-queue/README.md create mode 100644 examples/exclusive-queue/main.tf create mode 100644 examples/exclusive-queue/providers.tf diff --git a/README.md b/README.md index 7b41d1c..5d0cd38 100644 --- a/README.md +++ b/README.md @@ -64,7 +64,7 @@ The following table shows the resources created for each `endpoint-type` value. Refer to the following configuration examples: - Queue - - Exclusive queue + - [Exclusive queue](examples/exclusive-queue) - [Non-exclusive queue](examples/non-exclusive-queue) - Partitioned queue - Queue with topic subscriptions diff --git a/examples/exclusive-queue/README.md b/examples/exclusive-queue/README.md new file mode 100644 index 0000000..8579f84 --- /dev/null +++ b/examples/exclusive-queue/README.md @@ -0,0 +1,51 @@ +# Exclusive Queue Example + +Configuration in this directory creates an [exclusive queue](https://docs.solace.com/Messaging/Guaranteed-Msg/Configuring-Queues.htm#Configuring_Access_Types_..49) on the PubSub+ event broker leveraging the Queue Endpoint Terraform module. + +## Module Configuration in the Example + +### Mandatory Inputs + +* `msg_vpn_name` - set to `default` in the example +* `endpoint_type` - set to `queue` +* `endpoint_name` - set to `testQ` in the example +* `permission` - set to `consume` to enable the receiver app to remove consumed messages from the queue + +### Optional Inputs + +Optional module input variables have the same name and defaults if omitted, as the attributes of the underlying provider resource. Refer to the [documentation of "solacebroker_msg_vpn_queue"](https://registry.terraform.io/providers/SolaceProducts/solacebroker/latest/docs/resources/msg_vpn_queue#optional). + +The `access_type` module input variable defines if a queue is "exclusive" or "non-exclusive". The default is "exclusive", so the variable doesn't need to be strictly specified. + +### Output + +The module `queue` output refers to the created queue. + +## Running the Example + +### Access to a PubSub+ broker + +If you don't already have access to a broker, refer to the [Developers page](https://www.solace.dev/) for options to get started. + +### Adjust Provider Configuration + +Adjust the [provider parameters](https://registry.terraform.io/providers/SolaceProducts/solacebroker/latest/docs#schema) in `main.tf` according to your broker. The example configuration shows settings for a local broker running in Docker. + +### Create the resource + +Hint: You can verify configuration changes on the broker, before and after, using the [PubSub+ Broker Manager Web UI](https://docs.solace.com/Admin/Broker-Manager/PubSub-Manager-Overview.htm) + +Execute from this folder: + +```bash +$ terraform init +$ terraform plan +$ terraform apply +``` + +Run `terraform destroy` to clean up created resources when no longer needed. + +## Additional Documentation + +Refer to the [Configuring Queues](https://docs.solace.com/Messaging/Guaranteed-Msg/Configuring-Queues.htm#Configuring_Queues) section in the PubSub+ documentation. + diff --git a/examples/exclusive-queue/main.tf b/examples/exclusive-queue/main.tf new file mode 100644 index 0000000..8293f05 --- /dev/null +++ b/examples/exclusive-queue/main.tf @@ -0,0 +1,30 @@ +provider solacebroker { + username = "admin" + password = "admin" + url = "http://localhost:8080" +} + +module "exclusive_queue" { + # update with the module location + source = "../.." + + msg_vpn_name = "default" + endpoint_type = "queue" + endpoint_name = "testEQ" + + # permission "consume" enables messaging a messaging client to connect, read and consume messages to/from the queue + permission = "consume" + + # access_type "exclusive" is the default queue access type. While it has been specified here for clarity, it is not strictly required. + access_type = "exclusive" + + # ingress and egress are enabled by default in the module, no need to enable here + # ingress_enabled = true + # egress_enabled = true +} + +output "provisioned_queue" { + value = module.exclusive_queue.queue + description = "The provisioned queue resource" +} + diff --git a/examples/exclusive-queue/providers.tf b/examples/exclusive-queue/providers.tf new file mode 100644 index 0000000..46c4322 --- /dev/null +++ b/examples/exclusive-queue/providers.tf @@ -0,0 +1,9 @@ +# Terraform configuration + +terraform { + required_providers { + solacebroker = { + source = "registry.terraform.io/solaceproducts/solacebroker" + } + } +} diff --git a/examples/non-exclusive-queue/README.md b/examples/non-exclusive-queue/README.md index 510734b..9670218 100644 --- a/examples/non-exclusive-queue/README.md +++ b/examples/non-exclusive-queue/README.md @@ -15,7 +15,7 @@ Configuration in this directory creates a [non-exclusive queue](https://docs.sol Optional module input variables have the same name and defaults if omitted, as the attributes of the underlying provider resource. Refer to the [documentation of "solacebroker_msg_vpn_queue"](https://registry.terraform.io/providers/SolaceProducts/solacebroker/latest/docs/resources/msg_vpn_queue#optional). -The `access_type` module input variable defines if a queue is "exclusive" or "non-exclusive". The default is "non-exclusive", so the variable doesn't need to be strictly specified. +The `access_type` module input variable defines if a queue is "exclusive" or "non-exclusive". This needs to be specified for a "non-exclusive" queue. ### Output diff --git a/examples/non-exclusive-queue/main.tf b/examples/non-exclusive-queue/main.tf index fd729fb..804db95 100644 --- a/examples/non-exclusive-queue/main.tf +++ b/examples/non-exclusive-queue/main.tf @@ -10,13 +10,13 @@ module "non_exclusive_queue" { msg_vpn_name = "default" endpoint_type = "queue" - endpoint_name = "testQ" + endpoint_name = "testNEQ" # permission "consume" enables messaging a messaging client to connect, read and consume messages to/from the queue permission = "consume" - # access_type "non-exclusive" is the default queue access type, no need to specify here - # access_type = "non-exclusive" + # access_type "exclusive" is the default queue access type. This variable needs to be specified here to configure a non-exclusive queue + access_type = "non-exclusive" # ingress and egress are enabled by default in the module, no need to enable here # ingress_enabled = true