# Connecting to Microsoft Message Queue

Microsoft Message Queue (MSMQ) is a robust messaging platform developed by Microsoft. It enables asynchronous communication between applications, allowing them to exchange messages reliably and securely.

With MSMQ, developers can build distributed systems, decouple components, and enhance scalability. It provides a flexible and efficient solution for queuing and processing messages, ensuring seamless integration and smooth data flow across various software applications.

### Types of Queues

MSMQ offers three types of message queues: private, public, and system.

Private queues are local to a computer, while public queues can be accessed over a network. Both types ensure reliable and secure message delivery for diverse communication needs.

System queues are specifically managed by the underlying messaging system or infrastructure. They serve as internal components for managing message delivery and processing.

In Astera, the user can read and write from both public and private queues.

### Setting Up Microsoft Message Queue on a Windows Machine

1. To start, open the control panel on your windows.

![](https://3083465318-files.gitbook.io/~/files/v0/b/gitbook-x-prod.appspot.com/o/spaces%2FsR50Wa7EwZGlmPSAMkkf%2Fuploads%2FJnQn0mNt2nmw70S98w3B%2F01-Control-Panel.PNG?alt=media\&token=51e30c33-f091-4463-8c18-bb3b0ed7062b)

2. Select *Programs and Features*

This will lead us to a new screen.

![](https://3083465318-files.gitbook.io/~/files/v0/b/gitbook-x-prod.appspot.com/o/spaces%2FsR50Wa7EwZGlmPSAMkkf%2Fuploads%2FyJHv5sHNNdFQTC78cK4L%2F02-Program-Features.PNG?alt=media\&token=aba2a120-97f1-472e-a621-1ce136cd1c5e)

3. On the left side of the window, select *Turn Windows features on or off*

This will open a new window.

![](https://3083465318-files.gitbook.io/~/files/v0/b/gitbook-x-prod.appspot.com/o/spaces%2FsR50Wa7EwZGlmPSAMkkf%2Fuploads%2FHZUmPETAAbSDmgKoRRd1%2F03-Windows-Features.PNG?alt=media\&token=29e8bee9-bae8-45ee-883d-eb515850eae8)

4. Scroll down and select the *Microsoft Message Queue (MSMQ) Server* package.

By default, it is not selected.

![](https://3083465318-files.gitbook.io/~/files/v0/b/gitbook-x-prod.appspot.com/o/spaces%2FsR50Wa7EwZGlmPSAMkkf%2Fuploads%2FNDT0LfPt5RO9QYddwtH4%2F04-Message-Option-Select.PNG?alt=media\&token=57154111-2882-4fa2-beda-76f9a1254654)

5. Click *OK* and the package will be installed.

{% hint style="info" %}
**Note:** It is important to check whether *Message Queuing Server* and *Message Queuing Triggers* are checked before installing.
{% endhint %}

Once the package is installed, click on *Close*.

{% hint style="info" %}
**Note:** There might be a prompt to restart the machine once the package has been installed.
{% endhint %}

![](https://3083465318-files.gitbook.io/~/files/v0/b/gitbook-x-prod.appspot.com/o/spaces%2FsR50Wa7EwZGlmPSAMkkf%2Fuploads%2FLbfMFwsjIqIMMzynq9gF%2F05-Changes-Complete.PNG?alt=media\&token=12fcdcec-ef4e-4056-a1a4-165f3bdb7c76)

### Testing Microsoft Message Queue

1. Once the message queue package has been installed, head to the *Computer Management* application on your machine.

![](https://3083465318-files.gitbook.io/~/files/v0/b/gitbook-x-prod.appspot.com/o/spaces%2FsR50Wa7EwZGlmPSAMkkf%2Fuploads%2FOs3vFvlQWNQ57VTTvzdV%2F06-Comp-Mng.PNG?alt=media\&token=49275f9e-24cf-4a6c-a975-44e11bb4e476)

2. In the *Services and Applications* drop-down, upon expanding, we can see the *Message Queue* node.

![](https://3083465318-files.gitbook.io/~/files/v0/b/gitbook-x-prod.appspot.com/o/spaces%2FsR50Wa7EwZGlmPSAMkkf%2Fuploads%2F8tEfRI8QFTW1GLGq045t%2F07-Message-Queue-Node.PNG?alt=media\&token=7e14c945-1237-4c7d-b170-2cb19a15bd7e)

3. To create a new queue, simply right-click on either public or private and select *New* from the context menu.

![](https://3083465318-files.gitbook.io/~/files/v0/b/gitbook-x-prod.appspot.com/o/spaces%2FsR50Wa7EwZGlmPSAMkkf%2Fuploads%2FPBo93ND4CKtheqzCVsuB%2F08-New-Queue.PNG?alt=media\&token=88710bd4-4058-4fcb-b717-6de16413bfd3)

4. To check if permissions for a queue have been given to read and write, right-click on the desired queue name and select *Properties* from the context menu.

![](https://3083465318-files.gitbook.io/~/files/v0/b/gitbook-x-prod.appspot.com/o/spaces%2FsR50Wa7EwZGlmPSAMkkf%2Fuploads%2FoYv5x20hgYylI9GECGIF%2F09-Queue-Properties.PNG?alt=media\&token=689e6ddb-98be-4c14-a611-04cdd566ea4a)

This will open a new window.

5. Head to the *Security* tab to see if the permissions have been assigned or not.

![](https://3083465318-files.gitbook.io/~/files/v0/b/gitbook-x-prod.appspot.com/o/spaces%2FsR50Wa7EwZGlmPSAMkkf%2Fuploads%2FwJ2AH3B7hGazjAr0N9zm%2F10-Security.PNG?alt=media\&token=6bc2c5b9-267f-4781-96c7-9aa993f96007)

{% hint style="info" %}
**Note:** It is a must for the queue to have permission given to the user that is accessing the Astera service.
{% endhint %}

### Using the Microsoft Message Queue in Astera

In Astera, we have objects for both *Message Queue Source* and *Message Queue Destination.*

{% hint style="info" %}
**Note:** We can read messages from and write messages to both public and private queues using Astera.
{% endhint %}

![](https://3083465318-files.gitbook.io/~/files/v0/b/gitbook-x-prod.appspot.com/o/spaces%2FsR50Wa7EwZGlmPSAMkkf%2Fuploads%2FKt1YIC9JCMBQVFIeARlR%2F11-Message-Queue.PNG?alt=media\&token=818b1131-82ac-4b22-b10d-68e85399dbae)

1. Right-click on the *Message Queue Source* object and select properties from the context menu.

This will open a new window.

![](https://3083465318-files.gitbook.io/~/files/v0/b/gitbook-x-prod.appspot.com/o/spaces%2FsR50Wa7EwZGlmPSAMkkf%2Fuploads%2FnuVgSn3Cm7iq5EkIMkpx%2F12-Message-Queue-Source.PNG?alt=media\&token=c3a55a1e-57e5-49f1-864a-d5dd14a6d145)

*Message Queue Provider:* This drop-down lets us select from available message queue providers.

*Channel Name:* The full name of the queue we are trying to access.

2. As we can see in our management window, there is 1 message present in our required queue.

![](https://3083465318-files.gitbook.io/~/files/v0/b/gitbook-x-prod.appspot.com/o/spaces%2FsR50Wa7EwZGlmPSAMkkf%2Fuploads%2FoGormsTwYg9WHEG8dH6f%2F13-Messages-Available.PNG?alt=media\&token=0ddcf268-baaf-4abc-a61a-6d085919a4da)

3. Upon previewing the output of our object by right-click> *Preview Output*, we can see the following result.

![](https://3083465318-files.gitbook.io/~/files/v0/b/gitbook-x-prod.appspot.com/o/spaces%2FsR50Wa7EwZGlmPSAMkkf%2Fuploads%2FPc4EkXtZBqXkOrZJRzbn%2F14-Preview.PNG?alt=media\&token=1a07a387-7b80-4846-ad48-34b05b7c978a)

4. Now let’s look at the *Message Queue Destination* object.

After dragging and dropping the object onto the designer, we see a field inside the *Message Queue Destination* object by the name of *Value*.

![](https://3083465318-files.gitbook.io/~/files/v0/b/gitbook-x-prod.appspot.com/o/spaces%2FsR50Wa7EwZGlmPSAMkkf%2Fuploads%2FKqb5Zofc4FTe1fagv9X8%2F15-Destination.PNG?alt=media\&token=271fe6be-995f-406d-b97e-4b133a80a654)

{% hint style="info" %}
**Note:** If using a source other than the *Message Queue Source*, then the incoming data needs to be serialized before loading to a destination.
{% endhint %}

![](https://3083465318-files.gitbook.io/~/files/v0/b/gitbook-x-prod.appspot.com/o/spaces%2FsR50Wa7EwZGlmPSAMkkf%2Fuploads%2FexKx3I3xAywaniLdSkvL%2F17-Flow.PNG?alt=media\&token=976e2405-c4a1-4046-8faf-245fef14ac0a)

5. Right-click on the *Message Queue Destination* object and select *Properties* from the context menu.

This will open a new window.

![](https://3083465318-files.gitbook.io/~/files/v0/b/gitbook-x-prod.appspot.com/o/spaces%2FsR50Wa7EwZGlmPSAMkkf%2Fuploads%2F4TtJHTb4o58pC5G1rLWo%2F19-Destination.png?alt=media\&token=59cc4057-9e0d-4ac1-b376-d7943235d9fc)

*Channel:* This is where the user inputs the name of the queue from where the source data is coming.

*Create Message Queue:* Selecting this checkbox will create a message queue if it is not already created.

6. Click *OK* and map the *Value* field from the *Message Queue Source* onto the *value* field of the *Message Queue Destination*.

![](https://3083465318-files.gitbook.io/~/files/v0/b/gitbook-x-prod.appspot.com/o/spaces%2FsR50Wa7EwZGlmPSAMkkf%2Fuploads%2Fke2B5TzQA3wUQ6Fw8wEE%2F18-FlowFinal.png?alt=media\&token=bbfa5133-bc95-40d2-9518-9f4dfd95e595)

As you can see below, there is a new queue created by the name of *Destination* with one message that is migrated from the source queue named *Order Queue*.

![](https://3083465318-files.gitbook.io/~/files/v0/b/gitbook-x-prod.appspot.com/o/spaces%2FsR50Wa7EwZGlmPSAMkkf%2Fuploads%2FWvQ0pDgXJuLrJf8UzGJn%2F20-Mgmt.png?alt=media\&token=fbe22a73-1bf1-427f-951a-f45468f2589d)

This concludes the working of the *Message Queue Source* and *Message Queue Destination* objects in Astera Data Stack.
