Example configurations to publish to an Azure Service Bus (ASB) Queue or Topic and then consume it using an InboundEndpoint
Side Note: These examples where created utilizing the new VSCode MI plugin.
It seems that between EI and MI there have been some changes that need to be updated in the current ASB examples in the WSO2 documentation.
A primary aspect of this change is the migration of updating the jndi.properties file directly to the deployment.toml auto generation in the jndi.properties file. This has the impact of needing to adjust some of the naming.
For a queue you use the queue name, but for topics you need to subscribe to a subscription of the topic. That subscription is setup in the ASB console.
Format: topic name/subscriptions/subscription name
Example: <parameter name="transport.jms.Destination">topic.test/**subscriptions**/subscription.topic.test</parameter>
In these suggested configuration the API connection utilizes the name in the transport.jms.sender section of the deployment.toml. Those settings are placced in either the <MI_HOME>/conf/axis2/axis2.xml or <MI_HOME>/conf/axis2/axis2_blocking_client.xml depending on which configuration you set up.
In these examples the InboundEndpoints are utilizing the <MI_HOME>/conf/jndi.properties file connection factory settings instead.
WARNING: Now that JNDI Connection Factories values are defined you can no longer utilize the older connectionfactory.SBCF / SBTCF naming patterns some have suggested for the EI configurations.
Reminder to import the ASB certificate into your client-trustore.jks file
Do not modify jndi.properties nor axis2.xml files manually. In MI those will be overwritten when the server is started up.
[transport.jms]
sender_enable = true
listener_enable = true
[transport.jndi.connection_factories]
'connectionfactory.QueueConnectionFactory' = "amqps://sample-namespace.servicebus.windows.net?amqp.idleTimeout=-1&jms.prefetchPolicy.all=0&jms.username=test&jms.password=***"
'connectionfactory.TopicConnectionFactory' = "amqps://sample-namespace.windows.net?amqp.idleTimeout=-1&jms.prefetchPolicy.all=0&jms.username=test&jms.password=***"
[[transport.jms.sender]]
name = "azureQueueProducerConnectionFactory"
parameter.cache_level = "connection"
parameter.connection_factory_name = "QueueConnectionFactory"
parameter.connection_factory_type = "queue"
parameter.initial_naming_factory = "org.apache.qpid.jms.jndi.JmsInitialContextFactory"
parameter.provider_url = "conf/jndi.properties"
parameter.'transport.jms.MessagePropertyHyphens' = "replace"
[[transport.jms.sender]]
name = "azureTopicProducerConnectionFactory"
parameter.cache_level = "connection"
parameter.connection_factory_name = "TopicConnectionFactory"
parameter.connection_factory_type = "topic"
parameter.initial_naming_factory = "org.apache.qpid.jms.jndi.JmsInitialContextFactory"
parameter.provider_url = "conf/jndi.properties"
parameter.'transport.jms.MessagePropertyHyphens' = "replace"
[[transport.blocking.jms.sender]]
name = "azureQueueProducerConnectionFactory"
parameter.cache_level = "connection"
parameter.connection_factory_name = "QueueConnectionFactory"
parameter.connection_factory_type = "queue"
parameter.initial_naming_factory = "org.apache.qpid.jms.jndi.JmsInitialContextFactory"
parameter.provider_url = "conf/jndi.properties"
parameter.'transport.jms.MessagePropertyHyphens' = "replace"
[[transport.blocking.jms.sender]]
name = "azureTopicProducerConnectionFactory"
parameter.cache_level = "connection"
parameter.connection_factory_name = "TopicConnectionFactory"
parameter.connection_factory_type = "topic"
parameter.initial_naming_factory = "org.apache.qpid.jms.jndi.JmsInitialContextFactory"
parameter.provider_url = "conf/jndi.properties"
parameter.'transport.jms.MessagePropertyHyphens' = "replace"
See src/main/wso2mi/artifacts/ folder
[2025-02-25 17:58:45,517] INFO {LogMediator} - {api:AzureServiceBusQueuePublisher} To: /publishToQueue/sendTopic
MessageID: urn:uuid:d23970ae-771a-4928-8547-93851592c0e2
correlation_id: d23970ae-771a-4928-8547-93851592c0e2
Direction: request
DEBUG = ++++ API sending to TOPIC
Envelope: <?xml version='1.0' encoding='utf-8'?><soapenv:Envelope xmlns:soapenv="http://schemas.xmlsoap.org/soap/envelope/"><soapenv:Body><test>hi</test></soapenv:Body></soapenv:Envelope>
…
DEBUG = ++++ API sent msg to TOPIC
…
[2025-02-25 17:58:46,770] INFO {LogMediator} - {inboundendpoint:InboundASBTopicConsumer} To:
MessageID: ID:fd68a06e-6f73-4a53-b826-d6443614b187:1:1:1-1
Direction: request
DEBUG = ---- Extracted message from ASB Topic
Envelope: <?xml version='1.0' encoding='utf-8'?><soapenv:Envelope xmlns:soapenv="http://schemas.xmlsoap.org/soap/envelope/"><soapenv:Body><test>hi</test></soapenv:Body></soapenv:Envelope>
- Connecting to Azure Service Bus
- JMS Transports
- JMS Transport Listner (see: non-blocking / blocking versions)
- JMS Transport Sender (see: non-blocking / blocking versions)
- JNDI Connection Factories
