Connecting to Azure Service Bus¶ This section describes how to configure WSO2 Integrator: MI to connect with Azure Service Bus. Azure Service Bus is a messaging service that exists on Azure Cloud. It only needs to be configured in order to work. The Azure Service Bus complies with both AMQP 1.0 and JMS 2.0. The WSO2 Integrator: MI uses its inbuilt JMS transport to send and receive messages from the Azure Service Bus. The configurations are similar to connecting with other JMS brokers. Setting up the WSO2 Integrator: MI with Azure Service Bus¶ Follow the instructions below to set up and configure WSO2 Integrator: MI to work with Azure Service Bus. To get started, download and install WSO2 Integrator: MI. Setting up Azure Service Bus¶ To set this up, configure a queue in Azure Service Bus to work with the synapse configuration. Service Bus queues can be used to communicate between various on-premise and cloud applications and components. Using queues enables you to scale your applications more easily, and enable more resiliency to your architecture. For more information on creating a queue, see the Azure Service Bus documentation. Following the above Azure Service Bus documentation to do the following. Create an Azure Service Bus named my-mq by selecting a pricing tier of your choice. Create a queue named integration-queue. Navigate to that by going to Home > my-mq | Queues Add a shared access policy named my-mq-policy assigning Send and Listen. Go to Home > my-mq | Queues > integration-queue (my-mq/integration-queue) | Shared access policies. Note The primary key will be generated by the system. If the primary key contains a + sign, encode it by replacing it with %2b in the jndi.properties file. This avoids issues in the Azure Service Bus library, which does not work correctly when the primary key contains the + sign. Alternatively, you can delete and create the policy again with the same name until you get a primary key without the + sign. The Maximum Delivery Count property is set to 5 because it reduces the testing time. The default value is 10. Navigate to Home > my-mq | Queues > integration-queue (my-mq/integration-queue) | Properties to configure this. Now the WSO2 enterprise integrator should be configured to work with Azure Service Bus. Setting up the WSO2 Integrator: MI to work with Azure Service Bus¶ The messaging flow is as shown below. To set up the messaging flow in WSO2 Integrator: MI VS Code Extension, create synapse artifacts to create a consumer and a producer. Azure Service Bus Producer <?xml version="1.0" encoding="UTF-8"?> <proxy xmlns="http://ws.apache.org/ns/synapse" name="AzureServiceBusProducer" startOnLoad="true" statistics="disable" trace="disable" transports="http,https"> <target> <inSequence> <log> <property name="in" value="==== IN =====" /> </log> <property action="remove" name="TRANSPORT_HEADERS" scope="axis2" /> <property name="OUT_ONLY" scope="default" type="STRING" value="true" /> <call blocking="true"> <endpoint> <address uri="jms://integration-queue?transport.jms.ConnectionFactory=azureQueueProducerConnectionFactory&transport.jms.Destination=integration-queue" /> </endpoint> </call> <payloadFactory media-type="json"> <format> {"status":"successful"} </format> <args /> </payloadFactory> <property name="HTTP_SC" scope="axis2" type="STRING" value="200" /> <respond /> </inSequence> <outSequence /> <faultSequence> <property name="SET_ROLLBACK_ONLY" value="true" scope="axis2" /> <payloadFactory media-type="json"> <format> {"status":"failed"} </format> <args /> </payloadFactory> <property name="HTTP_SC" scope="axis2" type="STRING" value="500" /> <respond /> </faultSequence> </target> <description /> </proxy> Azure Service Bus Consumer <?xml version="1.0" encoding="UTF-8"?> <proxy xmlns="http://ws.apache.org/ns/synapse" name="AzureServiceBusConsumer" startOnLoad="true"> <description /> <target> <inSequence> <call blocking="true"> <endpoint> <http uri-template="http://localhost:8280/data/glossary"/> </endpoint> </call> <log level="custom"> <property name="Transaction Action" value="Committed"/> </log> </inSequence> <outSequence /> <faultSequence> <property name="SET_ROLLBACK_ONLY" value="true" scope="axis2"/> <log level="custom"> <property name="Transaction Action" value="Rollbacked"/> </log> </faultSequence> </target> <parameter name="transport.jms.DestinationType">queue</parameter> <parameter name="transport.jms.Destination">integration-queue</parameter> <parameter name="transport.jms.ContentType"> <rules xmlns=""> <jmsProperty>contentType</jmsProperty> <default>text/plain</default> </rules> </parameter> <parameter name="transport.jms.ConnectionFactory">azureQueueConsumerConnectionFactory</parameter> </proxy> Sample API <?xml version="1.0" encoding="UTF-8"?> <api context="/data" name="SampleAPI" xmlns="http://ws.apache.org/ns/synapse"> <resource methods="POST" url-mapping="/glossary"> <inSequence> <log level="custom"> <property name="REQUEST" expression="json-eval($.)" /> </log> <payloadFactory media-type="json"> <format> {"status":"successful"} </format> <args /> </payloadFactory> <property name="HTTP_SC" scope="axis2" type="STRING" value="200" /> <respond /> </inSequence> <outSequence/> <faultSequence/> </resource> </api> Do the following to set this up. Copy the following external .jar files to the MI_HOME/lib directory. geronimo-jms_2.0_spec-1.0-alpha-2.jar netty-transport-native-epoll-4.0.40.Final.jar proton-j-0.27.1.jar Qpid-jms-client-0.32.0.jar If you want the WSO2 Integrator: MI to receive messages from an Azure Service Bus instance, or to send messages to an Azure Service Bus instance, you need to update the deployment.toml file with the relevant connection parameters. Add the following configurations to enable the JMS listener with Azure Service Bus connection parameters. [[transport.jms.listener]] name = "azureQueueConsumerConnectionFactory" parameter.initial_naming_factory = "org.apache.qpid.jms.jndi.JmsInitialContextFactory" parameter.provider_url = "conf/jndi.properties" parameter.connection_factory_name = "SBCF" parameter.connection_factory_type = "queue" Add the following configurations to enable the JMS sender with Azure Service Bus connection parameters. [[transport.jms.sender]] name = "azureQueueProducerConnectionFactory" parameter.initial_naming_factory = "org.apache.qpid.jms.jndi.JmsInitialContextFactory" parameter.provider_url = "conf/jndi.properties" parameter.connection_factory_name = "SBCF" parameter.connection_factory_type = "queue" 3. Start the WSO2 Integrator: MI. Now you have configured instances of Azure Service Bus and WSO2 Integrator: MI.