

# Messaging & communications
<a name="messagingandcommunications-pattern-list"></a>

**Topics**
+ [Automate RabbitMQ configuration in Amazon MQ](automate-rabbitmq-configuration-in-amazon-mq.md)
+ [Improve call quality on agent workstations in Amazon Connect contact centers](improve-call-quality-on-agent-workstations-in-amazon-connect-contact-centers.md)
+ [More patterns](messagingandcommunications-more-patterns-pattern-list.md)

# Automate RabbitMQ configuration in Amazon MQ
<a name="automate-rabbitmq-configuration-in-amazon-mq"></a>

*Yogesh Bhatia and Afroz Khan, Amazon Web Services*

## Summary
<a name="automate-rabbitmq-configuration-in-amazon-mq-summary"></a>

[Amazon MQ](https://docs.aws.amazon.com/amazon-mq/) is a managed message broker service that provides compatibility with many popular message brokers. Using Amazon MQ with RabbitMQ provides a robust RabbitMQ cluster managed in the AWS Cloud with multiple brokers and configuration options. Amazon MQ provides a highly available, secure, and scalable infrastructure, and can process a large number of messages per second with ease. Multiple applications can use the infrastructure with different virtual hosts, queues, and exchanges. However, managing these configuration options or creating the infrastructure manually can require time and effort. This pattern describes a way to manage configurations for RabbitMQ in one step, through a single file. You can embed the code provided with this pattern within any continuous integration (CI) tool such as Jenkins or Bamboo. 

You can use this pattern to configure any RabbitMQ cluster. All it requires is connectivity to the cluster. Although there are many other ways to manage RabbitMQ configurations, this solution creates entire application configurations in one step, so you can manage queues and other details easily.

## Prerequisites and limitations
<a name="automate-rabbitmq-configuration-in-amazon-mq-prereqs"></a>

**Prerequisites**
+ AWS Command Line Interface (AWS CLI) [installed and configured](https://docs.aws.amazon.com/cli/latest/userguide/install-cliv2-linux.html) to point to your AWS account
+ Ansible installed, so you can run playbooks to create the configuration
+ **rabbitmqadmin **installed (for instructions, see the [RabbitMQ documentation](https://www.rabbitmq.com/management-cli.html))
+ A RabbitMQ cluster in Amazon MQ, created with healthy Amazon CloudWatch metrics

**Additional requirements**
+ Make sure to create the configurations for virtual hosts and users separately and not as part of JSON.
+ Make sure that the configuration JSON is part of the repository and is version-controlled.
+ The version of the **rabbitmqadmin **CLI must be the same as the version of the RabbitMQ server, so the best option is to download the CLI from the RabbitMQ console.
+ As part of the pipeline, make sure that JSON syntax is validated before each run.

**Product versions**
+ AWS CLI version 2.0
+ Ansible version 2.9.13
+ **rabbitmqadmin **version 3.9.13 (must be the same as the RabbitMQ server version)

## Architecture
<a name="automate-rabbitmq-configuration-in-amazon-mq-architecture"></a>

**Source technology stack  **
+ An RabbitMQ cluster running on an existing on-premises virtual machine (VM) or a Kubernetes cluster (on premises or in the cloud)

**Target technology stack  **
+ Automated RabbitMQ configurations on Amazon MQ for RabbitMQ

**Target architecture **

There are many ways to configure RabbitMQ. This pattern uses the import configuration functionality, where a single JSON file contains all the configurations. This file applies all settings and can be managed by a version-control system such as Bitbucket or Git. This pattern uses Ansible to implement the configuration through the **rabbitmqadmin **CLI.

![\[Automating RabbitMQ configuration in Amazon MQ\]](http://docs.aws.amazon.com/prescriptive-guidance/latest/patterns/images/pattern-img/294120b6-c95f-4cc5-bf85-5ad7e2abdad5/images/292e1284-5c9e-4c82-bb41-010fa84d8d74.png)


## Tools
<a name="automate-rabbitmq-configuration-in-amazon-mq-tools"></a>

**AWS services**
+ [Amazon MQ](https://docs.aws.amazon.com/amazon-mq/) is a managed message broker service that makes it easy to set up and operate message brokers in the cloud.
+ [AWS CloudFormation](https://docs.aws.amazon.com/AWSCloudFormation/latest/UserGuide/Welcome.html) helps you set up your AWS infrastructure and speed up cloud provisioning with infrastructure as code.
+ [AWS CLI](https://docs.aws.amazon.com/cli/latest/userguide/cli-chap-welcome.html) enables you to interact with AWS services by using commands in a command-line shell. 

**Other tools**
+ [rabbitmqadmin](https://www.rabbitmq.com/management-cli.html) is a command-line tool for the RabbitMQ HTTP-based API. It is used to manage and monitor RabbitMQ nodes and clusters.
+ [Ansible](https://www.ansible.com/) is an open-source tool for automating applications and IT infrastructure.

**Code repository**

The JSON configuration file used in this pattern and a sample Ansible playbook are provided in the attachment.

## Epics
<a name="automate-rabbitmq-configuration-in-amazon-mq-epics"></a>

### Create your AWS infrastructure
<a name="create-your-aws-infrastructure"></a>


| Task | Description | Skills required | 
| --- | --- | --- | 
| Create a RabbitMQ cluster on AWS. | If you don't already have a RabbitMQ cluster, you can use [AWS CloudFormation](https://docs.aws.amazon.com/AWSCloudFormation/latest/UserGuide/Welcome.html) to create the stack on AWS. Or, you can use the [CloudFormation module in Ansible](https://docs.ansible.com/projects/ansible/latest/collections/amazon/aws/cloudformation_module.html) to create the stack. With the latter approach, you can use Ansible for both tasks: to create the RabbitMQ infrastructure and to manage configurations.  | General AWS, Ansible | 

### Create the Amazon MQ for RabbitMQ configuration
<a name="create-the-amqlong-for-rabbitmq-configuration"></a>


| Task | Description | Skills required | 
| --- | --- | --- | 
| Create a properties file. | Download the JSON configuration file (`rabbitmqconfig.json`) in the attachment, or export it from the RabbitMQ console.  Modify it to configure queues, exchanges, and bindings. This configuration file demonstrates the following:[\[See the AWS documentation website for more details\]](http://docs.aws.amazon.com/prescriptive-guidance/latest/patterns/automate-rabbitmq-configuration-in-amazon-mq.html)These configurations are performed under the root (/) virtual host, as required by **rabbitmqadmin**.  | JSON | 
| Retrieve the details of the Amazon MQ for RabbitMQ infrastructure. | Retrieve the following details for the RabbitMQ infrastructure on AWS:[\[See the AWS documentation website for more details\]](http://docs.aws.amazon.com/prescriptive-guidance/latest/patterns/automate-rabbitmq-configuration-in-amazon-mq.html)You can use the AWS Management Console or the AWS CLI to retrieve this information. These details enable the Ansible playbook to connect to your AWS account and use the RabbitMQ cluster to run commands.The computer that runs the Ansible playbook must be able to access your AWS account, and AWS CLI must already be configured, as described in the *Prerequisites* section. | General AWS | 
| Create the `hosts_var` file. | Create the `hosts_var` file for Ansible and make sure that all the variables are defined in the file. Consider using Ansible Vault to store the password. You can configure the `hosts_var` file as follows (replace the asterisks with your information):<pre>RABBITMQ_HOST: "***********.mq.us-east-2.amazonaws.com"<br />RABBITMQ_VHOST: "/"<br />RABBITMQ_USERNAME: "admin"<br />RABBITMQ_PASSWORD: "*******"</pre> | Ansible | 
| Create an Ansible playbook. | For a sample playbook, see `ansible-rabbit-config.yaml` in the attachment. Download and save this file. The Ansible playbook imports and manages all RabbitMQ configurations, such as queues, exchanges, and bindings, that applications require. Follow best practices for Ansible playbooks, such as securing passwords. Use Ansible Vault for password encryption, and retrieve the RabbitMQ password from the encrypted file. | Ansible | 

### Deploy the configuration
<a name="deploy-the-configuration"></a>


| Task | Description | Skills required | 
| --- | --- | --- | 
| Run the playbook. | Run the Ansible playbook that you created in the previous epic.<pre>ansible-playbook ansible-rabbit-config.yaml</pre>You can verify the new configurations on the RabbitMQ console. | General AWS, RabbitMQ, Ansible | 

## Related resources
<a name="automate-rabbitmq-configuration-in-amazon-mq-resources"></a>
+ [Migrating from RabbitMQ to Amazon MQ](https://aws.amazon.com/blogs/compute/migrating-from-rabbitmq-to-amazon-mq/) (AWS blog post)
+ [Management Command Line Tool](https://www.rabbitmq.com/management-cli.html) (RabbitMQ documentation)
+ [Create or delete an AWS CloudFormation stack](https://docs.ansible.com/ansible/latest/collections/amazon/aws/cloudformation_module.html) (Ansible documentation)
+ [Migrating message driven applications to Amazon MQ for RabbitMQ](https://aws.amazon.com/blogs/compute/migrating-message-driven-applications-to-amazon-mq-for-rabbitmq/) (AWS blog post)

## Attachments
<a name="attachments-294120b6-c95f-4cc5-bf85-5ad7e2abdad5"></a>

To access additional content that is associated with this document, unzip the following file: [attachment.zip](samples/p-attach/294120b6-c95f-4cc5-bf85-5ad7e2abdad5/attachments/attachment.zip)

# Improve call quality on agent workstations in Amazon Connect contact centers
<a name="improve-call-quality-on-agent-workstations-in-amazon-connect-contact-centers"></a>

*Ernest Ozdoba, Amazon Web Services*

## Summary
<a name="improve-call-quality-on-agent-workstations-in-amazon-connect-contact-centers-summary"></a>

Call quality issues are some of the most difficult problems to troubleshoot in contact centers. To avoid voice quality issues and complex troubleshooting procedures, you must optimize your agents’ work environment and workstation settings. This pattern describes voice quality optimization techniques for agent workstations in Amazon Connect contact centers. It provides recommendations in the following areas:
+ Work environment adjustments. Agents’ surroundings don’t affect how voice is transmitted over the network, but they do have an effect on call quality. 
+ Agent workstation settings. Hardware and network configurations for contact center workstations have significant effects on call quality.
+ Browser settings. Agents use a web browser to access the Amazon Connect Contact Control Panel (CCP) website and communicate with customers, so browser settings can affect call quality.

The following components can also affect call quality, but they fall outside the scope of the workstation and aren’t covered in this pattern:
+ Traffic flows to the Amazon Web Services (AWS) Cloud over AWS Direct Connect, a full-tunnel VPN, or a split-tunnel VPN  
+ Network conditions when working in or outside the corporate office
+ Public switched telephone network (PSTN) connectivity
+ The customer’s device and telephony carrier
+ Virtual desktop infrastructure (VDI) setup

For more information relating to these areas, see [Common Contact Control Panel (CCP) Issues](https://docs.aws.amazon.com/connect/latest/adminguide/common-ccp-issues.html) and [Use the Endpoint Test Utility](https://docs.aws.amazon.com/connect/latest/adminguide/check-connectivity-tool.html) in the Amazon Connect documentation.

## Prerequisites and limitations
<a name="improve-call-quality-on-agent-workstations-in-amazon-connect-contact-centers-prereqs"></a>

**Prerequisites**
+ Headsets and workstations must comply with the requirements specified in the [Amazon Connect Administrator Guide](https://docs.aws.amazon.com/connect/latest/adminguide/ccp-agent-hardware.html). 

**Limitations**
+ The optimization techniques in this pattern apply to soft phone voice quality. They do not apply when you configure the Amazon Connect CCP in desk phone mode. However, you can use desk phone mode if your soft phone setup doesn’t provide acceptable voice quality for the call.

**Product versions**
+ For supported browsers and versions, see the [Amazon Connect Administrator Guide](https://docs.aws.amazon.com/connect/latest/adminguide/browsers.html).

## Architecture
<a name="improve-call-quality-on-agent-workstations-in-amazon-connect-contact-centers-architecture"></a>

This pattern is architecture-agnostic because it targets agent workstation settings. As the following diagram shows, the voice path from the agent to the customer is affected by the agent’s headset, browser, operating system, workstation hardware, and network.

![\[Voice path from agent to customer in Amazon Connect workstation calls\]](http://docs.aws.amazon.com/prescriptive-guidance/latest/patterns/images/pattern-img/04ac4c80-30c4-4a48-8411-e3aac7bc2887/images/04e94efc-39d1-424d-a299-89ea17d40153.png)


In Amazon Connect contact centers, the user’s audio connectivity is established with WebRTC. Voice is encoded with the [Opus interactive audio codec](https://opus-codec.org/) and encrypted with the Secure Real-time Transport Protocol (SRTP) in transit. Other network architectures are possible, including VPN, private WAN/LAN, and ISP networks.

## Tools
<a name="improve-call-quality-on-agent-workstations-in-amazon-connect-contact-centers-tools"></a>
+ [Amazon Connect Endpoint Test Utility](https://tools.connect.aws/endpoint-test/) – This utility checks network connectivity and browser settings.
+ Browser configuration editors for WebRTC settings:
  + For Firefox: **about:config**
  + For Chrome: **chrome://flags**
+ [CCP Log Parser ](https://tools.connect.aws/ccp-log-parser/index.html)– This tool helps you analyze CCP logs for troubleshooting purposes.

## Epics
<a name="improve-call-quality-on-agent-workstations-in-amazon-connect-contact-centers-epics"></a>

### Adjust the work environment
<a name="adjust-the-work-environment"></a>


| Task | Description | Skills required | 
| --- | --- | --- | 
| Reduce background noise. | Avoid noisy environments. If this is not possible, optimize the environment with these soundproofing tips:[\[See the AWS documentation website for more details\]](http://docs.aws.amazon.com/prescriptive-guidance/latest/patterns/improve-call-quality-on-agent-workstations-in-amazon-connect-contact-centers.html) | Agent, Manager | 

### Optimize agent workstation settings
<a name="optimize-agent-workstation-settings"></a>


| Task | Description | Skills required | 
| --- | --- | --- | 
| Choose the right headset. | [\[See the AWS documentation website for more details\]](http://docs.aws.amazon.com/prescriptive-guidance/latest/patterns/improve-call-quality-on-agent-workstations-in-amazon-connect-contact-centers.html) | Agent, Manager | 
| Use the headset as intended. | [\[See the AWS documentation website for more details\]](http://docs.aws.amazon.com/prescriptive-guidance/latest/patterns/improve-call-quality-on-agent-workstations-in-amazon-connect-contact-centers.html) | Agent | 
| Check workstation resources. | Make sure that your agents’ computers are performant. If they use third-party applications that consume resources, their computers might not meet the minimum [hardware requirements](https://docs.aws.amazon.com/connect/latest/adminguide/ccp-agent-hardware.html) to run CCP. If agents experience call quality issues, make sure that they have enough processing power (CPU), disk space, network bandwidth, and memory available for CCP. Agents should close any unnecessary applications and tabs to improve CCP performance and call quality. | Administrator | 
| Configure the operating system’s sound settings. | The default settings for microphone level and boost usually work fine. If you find that outbound voice is quiet or the microphone is picking up too much, it might help to adjust these settings. Microphone settings can be found in your computer’s system sound configuration (**Sound**, **Input** on [MacOS](https://support.apple.com/en-gb/guide/mac-help/mchlp2567/12.0/mac/12.0), **Microphone Properties** in [Windows](https://support.microsoft.com/en-us/windows/fix-microphone-problems-5f230348-106d-bfa4-1db5-336f35576011)). You can access advanced settings that might affect voice quality through system tools or third-party applications. Here are some of the settings you can check:[\[See the AWS documentation website for more details\]](http://docs.aws.amazon.com/prescriptive-guidance/latest/patterns/improve-call-quality-on-agent-workstations-in-amazon-connect-contact-centers.html)If you’re experiencing voice quality issues, try restoring these values to their default settings before investigating further.For more information about these and other adjustable settings, see your device manual. | Agent, Administrator | 
| Use a wired network. | Typically, wired ethernet has lower latency, so it is easier to provide the consistent transmission quality required for voice data transmission.  We recommend 100 KB bandwidth per call at the minimum. [\[See the AWS documentation website for more details\]](http://docs.aws.amazon.com/prescriptive-guidance/latest/patterns/improve-call-quality-on-agent-workstations-in-amazon-connect-contact-centers.html) | Network administrator, Agent | 
| Update hardware drivers. | When you use a USB or other type of headset that has its own firmware, we recommend that you keep it updated with the latest version. Simple headsets that use an auxiliary port use the computer’s built-in audio device, so make sure that the operating system hardware driver is up to date. In rare cases, an audio driver update can cause audio issues, and you might need to roll it back. For more information about changing firmware and driver versions, see your device manual. | Administrator | 
| Avoid USB hubs and dongles. | When you connect your headset, avoid additional devices such as dongles, port type converters, hubs, and extension cables.These devices might affect call quality. Connect your device directly to the port in your computer instead. | Agent | 
| Check CCP logs. | The CCP Log Parser provides an easy way to check application logs.[\[See the AWS documentation website for more details\]](http://docs.aws.amazon.com/prescriptive-guidance/latest/patterns/improve-call-quality-on-agent-workstations-in-amazon-connect-contact-centers.html) | Agent (advanced skills) | 

### Optimize browser settings
<a name="optimize-browser-settings"></a>


| Task | Description | Skills required | 
| --- | --- | --- | 
| Restore default WebRTC settings. | WebRTC has to be enabled to make soft phone calls with CCP. We recommend that you keep the default settings for WebRTC-related features. [\[See the AWS documentation website for more details\]](http://docs.aws.amazon.com/prescriptive-guidance/latest/patterns/improve-call-quality-on-agent-workstations-in-amazon-connect-contact-centers.html) | Administrator | 
| Disable browser extensions when troubleshooting. | Some browser extensions might affect call quality or even prevent calls from connecting properly. Use the incognito window or private mode in your browser, and disable all extensions. If that solves the problem, review your browser extensions and look for suspicious add-ons, or disable them individually. | Agent, Administrator | 
| Check the browser sample rate.  | Confirm that your microphone input is set to the optimal 48 kHz sample rate. For instructions, see the [Amazon Connect Administrator Guide](https://docs.aws.amazon.com/connect/latest/adminguide/verify-sample-rate.html). | Agent, Administrator | 

## Related resources
<a name="improve-call-quality-on-agent-workstations-in-amazon-connect-contact-centers-resources"></a>

If you’ve followed the steps in this pattern but you’re still encountering problems with call quality, see the following resources for troubleshooting tips.
+ Review [common Contact Control Panel (CCP) issues](https://docs.aws.amazon.com/connect/latest/adminguide/common-ccp-issues.html).
+ Check the connection with the [Endpoint Test Utility](https://docs.aws.amazon.com/en_us/connect/latest/adminguide/check-connectivity-tool.html).
+ Follow the [troubleshooting guide ](https://docs.aws.amazon.com/connect/latest/adminguide/troubleshooting.html)for any other issues. 

If your troubleshooting and adjustments don’t solve the call quality issue, the root cause might be external to your workstation. For further troubleshooting, contact your IT support team. 

# More patterns
<a name="messagingandcommunications-more-patterns-pattern-list"></a>

**Topics**
+ [Decompose monoliths into microservices by using CQRS and event sourcing](decompose-monoliths-into-microservices-by-using-cqrs-and-event-sourcing.md)
+ [Deploy a ChatOps solution to manage SAST scan results by using Amazon Q Developer in chat applications custom actions and CloudFormation](deploy-chatops-solution-to-manage-sast-scan-results.md)
+ [Integrate Amazon API Gateway with Amazon SQS to handle asynchronous REST APIs](integrate-amazon-api-gateway-with-amazon-sqs-to-handle-asynchronous-rest-apis.md)
+ [Streamline Amazon Lex bot development and deployment by using an automated workflow](streamline-amazon-lex-bot-development-and-deployment-using-an-automated-workflow.md)