Skip to content

Latest commit

 

History

History
 
 

Folders and files

NameName
Last commit message
Last commit date

parent directory

..
 
 
 
 
 
 
page_type languages products description urlFragment
sample
java
azure-service-bus
Azure Spring Boot Sample project for Spring JMS with Service Bus Queue client library
azure-spring-boot-sample-service-bus-jms-queue

Sample for Spring JMS with Azure Service Bus Queue Spring Boot client library for Java

Key concepts

This sample project demonstrates how to use Spring JMS for Azure Service Bus Queue via Spring Boot Starter azure-spring-boot-starter-servicebus-jms.

Running this sample will be charged by Azure. You can check the usage and bill at this link.

Getting started

Create Service Bus on Azure

  1. Go to Azure portal and create the service by following this link.

Examples

Config the sample

  1. Update application.properties

    # Fill service bus namespace connection string copied from portal
    spring.jms.servicebus.connection-string=[servicebus-namespace-connection-string]
    
    # The idle timeout in milliseconds after which the connection will be failed if the peer sends no AMQP frames
    # Default is 1800000
    spring.jms.servicebus.idle-timeout=[idle-timeout]
    
    #Fill service bus pricing tier according to the one you created. Supported values are premium, standard and basic.
    spring.jms.servicebus.pricing-tier=[pricing-tier]
  2. Specify your queue name. Update QUEUE_NAME in QueueSendController and QueueReceiveController .

How to run

  1. Run with Maven

    cd azure-spring-boot-samples/servicebus/azure-spring-boot-sample-servicebus-jms-queue
    mvn spring-boot:run
    
  2. Send a POST request to service bus queue.

    $ curl -X POST localhost:8080/queue?message=hello
    
  3. Verify in your app's logs that a similar message was posted:

    Sending message
    Received message from queue: hello
    
  4. Delete the resources on Azure Portal to avoid extra charges.

Troubleshooting

Next steps

Please check the following table for reference links of detailed Service Bus usage.

Type Reference Link
Queues https://docs.microsoft.com/azure/service-bus-messaging/service-bus-java-how-to-use-queues

Contributing