Giter Club home page Giter Club logo

azure-spring-integration-sample-servicebus's Introduction

Spring Cloud Azure Service Bus Integration Code Sample shared library for Java

Key concepts

This code sample demonstrates how to use Spring Integration for Azure Service Bus to receive messages from one queue in a Service Bus namespace and then forward them to a queue in another Service Bus namespace.

Getting started

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

Create Azure resources

  1. Create two Azure Service Bus namespaces and queues. Please see how to create.

  2. [Optional] if you want to use managed identity, please follow create managed identity to set up managed identity.

Configure properties

  1. Update application.yaml with the required information of the Service Bus namespace used to receive messages from.
    spring:
      cloud:
        azure:
          msi-enabled: true
          client-id: [the-id-of-managed-identity]
          resource-group: [resource-group]
          subscription-id: [subscription-id]
    #     Uncomment below configurations if you want to enable auto creating resources.
    #
    #      subscription-id: [subscription-id]
    #      auto-create-resources: true
    #      environment: Azure
    #      region: [region]
          servicebus:
            namespace: [servicebus-namespace]
  2. Update QueueReceiveController.java
Constant Name Constant meaning
INPUT_QUEUE_NAME Name of the Queue in Service Bus namespace 1 to receive messages from
OUTPUT_QUEUE_NAME Name of the Queue in Service Bus namespace 2 to forward messages to
OUTPUT_SERVICEBUS_MSI_CLIENT_ID MSI of the Service Bus namespace 2
OUTPUT_SERVICEBUS_FQDN Fully qualified domain name of Service Bus namespace 2

Enable auto create

If you want to auto create the Azure Service Bus instances, make sure you add such properties (only support the service principal and managed identity cases):

spring:
  cloud:
    azure:
      subscription-id: [subscription-id]
      auto-create-resources: true
      environment: Azure
      region: [region]

Run the sample

  1. Run the mvn spring-boot:run in the root of the code sample to get the app running.

  2. Using Azure Service Bus Explorer to send a message to the receiving queue.

  3. Verify in your app’s logs that 3 similar message was posted:

    New message received: 'xxxx'
    Message 'xxxx' successfully checkpointed
    Message was sent successfully.
    
  4. Check your another Service Bus queue to see that the above message should be forwarded to it.

Redeploy Application

If you update the spring.cloud.azure.managed-identity.client-id property after deploying the app, or update the role assignment for services, please try to redeploy the app again.

You can follow Deploy a Spring Boot JAR file to Azure App Service to deploy this application to App Service

Recommend Projects

  • React photo React

    A declarative, efficient, and flexible JavaScript library for building user interfaces.

  • Vue.js photo Vue.js

    🖖 Vue.js is a progressive, incrementally-adoptable JavaScript framework for building UI on the web.

  • Typescript photo Typescript

    TypeScript is a superset of JavaScript that compiles to clean JavaScript output.

  • TensorFlow photo TensorFlow

    An Open Source Machine Learning Framework for Everyone

  • Django photo Django

    The Web framework for perfectionists with deadlines.

  • D3 photo D3

    Bring data to life with SVG, Canvas and HTML. 📊📈🎉

Recommend Topics

  • javascript

    JavaScript (JS) is a lightweight interpreted programming language with first-class functions.

  • web

    Some thing interesting about web. New door for the world.

  • server

    A server is a program made to process requests and deliver data to clients.

  • Machine learning

    Machine learning is a way of modeling and interpreting data that allows a piece of software to respond intelligently.

  • Game

    Some thing interesting about game, make everyone happy.

Recommend Org

  • Facebook photo Facebook

    We are working to build community through open source technology. NB: members must have two-factor auth.

  • Microsoft photo Microsoft

    Open source projects and samples from Microsoft.

  • Google photo Google

    Google ❤️ Open Source for everyone.

  • D3 photo D3

    Data-Driven Documents codes.