다음을 통해 공유


Spring 애플리케이션에서 Azure Storage 큐 사용

이 문서에서는 Spring Framework 사용하여 빌드된 Java 애플리케이션에서 Azure Storage Queue를 사용하는 방법을 보여 줍니다.

Azure Storage Queue는 분산 애플리케이션의 구성 요소 간에 통신할 수 있도록 클라우드 기반 큐를 구현합니다. 각 큐는 발신자 구성 요소에서 추가하고 수신자 구성 요소에서 처리할 수 있는 메시지 목록을 유지합니다. 큐를 사용하면 수요에 따라 애플리케이션을 즉시 확장할 수 있습니다.

Spring Cloud Azure Spring 프레임워크를 사용하여 큐에 메시지를 보내고 Azure Storage 메시지를 수신하기 위한 다양한 모듈을 제공합니다. 다음 목록에 설명된 대로 이러한 모듈을 독립적으로 사용하거나 다른 사용 사례에 대해 결합할 수 있습니다.

필수 조건

참고

리소스에 대한 액세스 권한을 계정에 부여하려면 새로 만든 Azure Storage 계정에서 현재 사용 중인 Microsoft Entra 계정에 Storage Queue Data Contributor 역할을 할당합니다. 자세한 내용은 Azure 포털을 사용하여 Azure 역할 할당 참조하세요.

중요합니다

이 자습서의 단계를 완료하려면 Spring Boot 버전 2.5 이상이 필요합니다.

로컬 환경 준비

이 자습서에서는 구성 및 코드에 인증 작업이 없습니다. 그러나 Azure 서비스에 연결하려면 인증이 필요합니다. 인증을 완료하려면 Azure ID 클라이언트 라이브러리를 사용해야 합니다. Spring Cloud Azure 코드 변경 없이 자격 증명을 가져오는 데 도움이 되도록 Azure ID 라이브러리에서 제공하는 DefaultAzureCredential 사용합니다.

DefaultAzureCredential은 여러 인증 방법을 지원하고 런타임에 사용할 방법을 결정합니다. 이 방법을 사용하면 앱이 환경별 코드를 구현하지 않고 로컬 또는 프로덕션 환경과 같은 다양한 환경에서 다양한 인증 방법을 사용할 수 있습니다. 자세한 내용은 DefaultAzureCredential 섹션을 참조하세요Azure 호스팅된 Java 애플리케이션 인증.

Azure CLI, IntelliJ 또는 기타 방법을 사용하여 로컬 개발 환경에서 인증을 완료하려면 Java 개발 환경에서 Azure 인증 참조하세요. Azure 호스팅 환경에서 인증을 완료하려면 관리 ID를 사용하는 것이 좋습니다. 자세한 내용은 Azure 리소스에 대한 관리 ID는 무엇입니까?

Spring Cloud Azure Storage Queue Starter 사용

Spring Cloud Azure Storage Queue Starter 모듈은 Spring Boot 프레임워크를 사용하여 Azure Storage Queue 클라이언트 라이브러리 for Java를 가져옵니다. 상호 배타적이지 않은 패턴으로 Spring Cloud Azure 및 Azure SDK 함께 사용할 수 있습니다. 따라서 Spring 애플리케이션에서 스토리지 큐 Java 클라이언트 API를 계속 사용할 수 있습니다.

종속성 추가

Spring Cloud Azure Storage Queue Starter 모듈을 설치하려면 pom.xml 파일에 다음 종속성을 추가합니다.

  • Spring Cloud Azure Bill of Materials (BOM):

    <dependencyManagement>
       <dependencies>
         <dependency>
           <groupId>com.azure.spring</groupId>
           <artifactId>spring-cloud-azure-dependencies</artifactId>
           <version>7.1.0</version>
           <type>pom</type>
           <scope>import</scope>
           </dependency>
       </dependencies>
    </dependencyManagement>
    

    참고

    Spring Boot 4.0.x를 사용 중이라면, spring-cloud-azure-dependencies 버전을 7.1.0로 설정해야 합니다.

    Spring Boot 3.5.x를 사용하는 경우, spring-cloud-azure-dependencies 버전을 6.2.0로 설정해야 합니다.

    Spring Boot 3.1.x-3.5.x를 사용하는 경우, spring-cloud-azure-dependencies 버전을 5.25.0로 설정해야 합니다.

    Spring Boot 2.x를 사용하는 경우 spring-cloud-azure-dependencies 버전을 4.20.0로 설정해야 합니다.

    이 BOM(자재 명세서)을 <dependencyManagement> 섹션의 pom.xml 파일에서 구성해야 합니다. 이렇게 하면 모든 Spring Cloud Azure 종속성이 동일한 버전을 사용하게 됩니다.

    이 BOM에 사용되는 버전에 대한 자세한 내용은 스프링 클라우드 Azure 사용해야 하는 경우 참조하세요.

  • Spring Cloud Azure 큐 스토리지 큐 아티팩트:

    <dependency>
      <groupId>com.azure.spring</groupId>
      <artifactId>spring-cloud-azure-starter-storage-queue</artifactId>
    </dependency>
    

메시지를 보내고 받도록 애플리케이션 코딩

이 섹션에서는 Spring 애플리케이션의 컨텍스트에서 Azure Queue Storage 클라이언트를 사용하는 방법을 보여 줍니다. 다음과 같은 두 가지 옵션이 있습니다.

  • Spring Boot 자동 구성을 사용하고 Spring 컨텍스트에서 기본 제공 클라이언트를 사용합니다(권장).
  • 프로그래밍 방식으로 클라이언트를 빌드합니다.

자동 구성을 사용하면 IoC(Spring inversion-of-control) 컨테이너에서 클라이언트 빈을 자동으로 연결합니다. 이 방법은 스토리지 큐 클라이언트를 사용하여 개발할 때 보다 유연하고 효율적인 환경을 제공합니다. 자동 구성에는 다음과 같은 이점이 있습니다.

  • 자동 구성은 다른 환경에서 동일한 애플리케이션 코드를 사용할 수 있도록 외부화된 구성 을 사용합니다.

  • Spring Boot 프레임워크에 빌더 패턴을 학습하고 애플리케이션 컨텍스트에 클라이언트를 등록하는 프로세스를 위임할 수 있습니다. 고유한 비즈니스 요구 사항으로 클라이언트를 사용하는 방법에만 초점을 맞춥니다.

  • 상태 표시기를 사용하여 애플리케이션 및 내부 구성 요소의 상태와 상태를 검사할 수 있습니다.

다음 섹션의 코드 예제에서는 설명된 두 가지 대안과 함께 사용하는 QueueClient 방법을 보여 줍니다.

Azure Java SDK for Storage Queue는 여러 클라이언트가 스토리지 큐와 상호 작용할 수 있도록 합니다. 또한 시작은 모든 Storage 큐 클라이언트 및 클라이언트 빌더에 대한 자동 구성을 제공합니다. 이 문서에서는 예제로만 QueueClient 사용합니다.

Spring Boot 자동 구성 사용

Azure Storage 큐에서 메시지를 보내고 받으려면 다음 단계를 사용하여 애플리케이션을 구성합니다.

  1. 다음 예제와 같이 스토리지 계정 이름 및 큐 이름을 구성합니다.

    spring.cloud.azure.storage.queue.account-name=<your-storage-account-name>
    spring.cloud.azure.storage.queue.queue-name=<your-storage-queue-name>
    
  2. QueueClient 다음 예제와 같이 Spring 애플리케이션에 삽입하고 관련 API를 호출하여 메시지를 보냅니다.

    import com.azure.storage.queue.QueueClient;
    import com.azure.storage.queue.models.QueueMessageItem;
    import com.azure.storage.queue.models.SendMessageResult;
    import org.slf4j.Logger;
    import org.slf4j.LoggerFactory;
    import org.springframework.beans.factory.annotation.Autowired;
    import org.springframework.boot.CommandLineRunner;
    import org.springframework.boot.SpringApplication;
    import org.springframework.boot.autoconfigure.SpringBootApplication;
    
    @SpringBootApplication
    public class StorageQueueClientApplication implements CommandLineRunner {
    
        private final static Logger logger = LoggerFactory.getLogger(StorageQueueClientApplication.class);
    
        @Autowired
        private QueueClient queueClient;
    
        public static void main(String[] args) {
            SpringApplication.run(StorageQueueClientApplication.class, args);
        }
    
        @Override
        public void run(String... args) {
         // Using the QueueClient object, call the create method to create the queue in your storage account.
            queueClient.create();
            SendMessageResult sendMessageResult = queueClient.sendMessage("Hello world");
            logger.info("Send message id: {}", sendMessageResult.getMessageId());
    
            QueueMessageItem queueMessageItem = queueClient.receiveMessage();
            logger.info("Received message: {}", new String(queueMessageItem.getBody().toBytes()));
        }
    
    }
    
  3. 애플리케이션을 시작합니다. 시작 후 애플리케이션은 다음 예제와 유사한 로그를 생성합니다.

    Send message id: ...
    Received message: Hello world
    

프로그래밍 방식으로 클라이언트 빌드

클라이언트 빈을 직접 생성할 수 있지만, 프로세스는 복잡합니다. Spring Boot 애플리케이션에서는 속성을 관리하고, 작성기 패턴을 알아보고, Spring 애플리케이션 컨텍스트에 클라이언트를 등록해야 합니다. 다음 단계에서는 이 작업을 수행하는 방법을 보여줍니다.

  1. 다음 예제와 같이 Spring 애플리케이션에서 프로그래밍 방식으로 클라이언트를 빌드합니다. 자리 표시자를 사용자 고유의 <storage-account-name> 값으로 바꿔야 합니다.

    import com.azure.identity.DefaultAzureCredentialBuilder;
    import com.azure.storage.queue.QueueClient;
    import com.azure.storage.queue.QueueClientBuilder;
    import com.azure.storage.queue.models.QueueMessageItem;
    import com.azure.storage.queue.models.SendMessageResult;
    import org.slf4j.Logger;
    import org.slf4j.LoggerFactory;
    import org.springframework.boot.CommandLineRunner;
    import org.springframework.boot.SpringApplication;
    import org.springframework.boot.autoconfigure.SpringBootApplication;
    
    @SpringBootApplication
    public class StorageQueueClientApplication implements CommandLineRunner {
    
        private final static String queueName = "test-queue";
        private final static String endpoint = "https://<storage-account-name>.queue.core.windows.net/";
        private final static Logger logger = LoggerFactory.getLogger(StorageQueueClientApplication.class);
    
        QueueClient queueClient = new QueueClientBuilder()
            .endpoint(endpoint)
            .queueName(queueName)
            .credential(new DefaultAzureCredentialBuilder().build())
            .buildClient();
    
        public static void main(String[] args) {
            SpringApplication.run(StorageQueueClientApplication.class, args);
        }
    
        @Override
        public void run(String... args) {
         // Using the QueueClient object, call the create method to create the queue in your storage account.
            queueClient.create();
            SendMessageResult sendMessageResult = queueClient.sendMessage("Hello world");
            logger.info("Send message id: {}", sendMessageResult.getMessageId());
    
            QueueMessageItem queueMessageItem = queueClient.receiveMessage();
            logger.info("Received message: {}", new String(queueMessageItem.getBody().toBytes()));
        }
    
    }
    
  2. 애플리케이션을 시작합니다. 시작 후 애플리케이션은 다음 예제와 유사한 로그를 생성합니다.

    Send message id: ...
    Received message: Hello world
    

다음 목록에서는 이 코드가 유연하지 않거나 정상적이지 않은 이유를 보여 줍니다.

  • 스토리지 계정 및 큐 이름은 하드 코딩됩니다.
  • Spring 환경에서 구성을 가져오는 데 사용하는 @Value 경우 application.properties 파일에 IDE 힌트를 가질 수 없습니다.
  • 마이크로 서비스 시나리오가 있는 경우 각 프로젝트에서 코드를 복제해야 하며 실수를 하기 쉽고 일관성을 갖기 어렵습니다.

다행히 Spring Cloud Azure로 클라이언트 빈을 직접 빌드할 필요는 없습니다. 대신 직접 삽입하고 이미 익숙한 구성 속성을 사용하여 스토리지 큐를 구성할 수 있습니다. 자세한 내용은 Spring Cloud Azure 구성 속성 참조하세요.

또한 Spring Cloud Azure 다양한 시나리오에 대해 다음과 같은 전역 구성을 제공합니다. 자세한 내용은 Spring Cloud Azure 전역 구성 속성 참조하세요.

  • 프록시 옵션입니다.
  • 다시 시도 옵션입니다.

다른 Azure 클라우드에 연결할 수도 있습니다. 자세한 내용은 Azure 클라우드에 연결 참조하세요.

Spring Messaging Azure Storage 큐 사용하기

Spring Messaging Azure Storage Queue 모듈은 Azure Queue Storage Spring Messaging 프레임워크를 지원합니다.

Spring Messaging Azure Storage Queue를 사용하는 경우 StorageQueueTemplate 기능을 사용하여 비동기적으로 또는 동기적으로 스토리지 큐에 메시지를 보낼 수 있습니다.

다음 섹션에서는 Spring Messaging Azure Storage Queue를 사용하여 스토리지 큐에 메시지를 보내고 받는 방법을 보여 줍니다.

종속성 추가

Spring Messaging Azure Storage Queue 모듈을 설치하려면 pom.xml 파일에 다음 종속성을 추가합니다.

  • Spring Cloud Azure Bill of Materials (BOM):

    <dependencyManagement>
       <dependencies>
         <dependency>
           <groupId>com.azure.spring</groupId>
           <artifactId>spring-cloud-azure-dependencies</artifactId>
           <version>7.1.0</version>
           <type>pom</type>
           <scope>import</scope>
           </dependency>
       </dependencies>
    </dependencyManagement>
    

    참고

    Spring Boot 4.0.x를 사용 중이라면, spring-cloud-azure-dependencies 버전을 7.1.0로 설정해야 합니다.

    Spring Boot 3.5.x를 사용하는 경우, spring-cloud-azure-dependencies 버전을 6.2.0로 설정해야 합니다.

    Spring Boot 3.1.x-3.5.x를 사용하는 경우, spring-cloud-azure-dependencies 버전을 5.25.0로 설정해야 합니다.

    Spring Boot 2.x를 사용하는 경우 spring-cloud-azure-dependencies 버전을 4.20.0로 설정해야 합니다.

    이 BOM(자재 명세서)을 <dependencyManagement> 섹션의 pom.xml 파일에서 구성해야 합니다. 이렇게 하면 모든 Spring Cloud Azure 종속성이 동일한 버전을 사용하게 됩니다.

    이 BOM에 사용되는 버전에 대한 자세한 내용은 스프링 클라우드 Azure 사용해야 하는 경우 참조하세요.

  • Spring Cloud Azure 스타터 및 Spring Messaging 스토리지 큐 아티팩트:

    <dependency>
      <groupId>com.azure.spring</groupId>
      <artifactId>spring-cloud-azure-starter</artifactId>
    </dependency>
    <dependency>
      <groupId>com.azure.spring</groupId>
      <artifactId>spring-messaging-azure-storage-queue</artifactId>
    </dependency>
    

메시지를 보내고 받도록 애플리케이션 코딩

다음 단계를 사용하여 애플리케이션을 구성하고 코딩합니다.

  1. 다음 예제와 같이 스토리지 큐에 대한 Azure Storage 계정 이름을 구성합니다.

    spring.cloud.azure.storage.queue.account-name=<your-storage-account-name>
    
  2. 다음 예제와 같이 보낸 사람과 수신자를 연결하여 Spring을 사용하여 메시지를 보내고 받습니다. 자리 표시자를 사용자 고유의 <storage-queue-name> 값으로 바꿔야 합니다.

    import com.azure.spring.messaging.AzureHeaders;
    import com.azure.spring.messaging.checkpoint.Checkpointer;
    import com.azure.spring.messaging.storage.queue.core.StorageQueueTemplate;
    import org.slf4j.Logger;
    import org.slf4j.LoggerFactory;
    import org.springframework.beans.factory.annotation.Autowired;
    import org.springframework.boot.CommandLineRunner;
    import org.springframework.boot.SpringApplication;
    import org.springframework.boot.autoconfigure.SpringBootApplication;
    import org.springframework.messaging.Message;
    import org.springframework.messaging.support.MessageBuilder;
    import java.time.Duration;
    
    @SpringBootApplication
    public class StorageQueueMessagingApplication implements CommandLineRunner {
    
        private static final Logger LOGGER = LoggerFactory.getLogger(StorageQueueMessagingApplication.class);
        private static final String STORAGE_QUEUE_NAME = "<storage-queue-name>";
    
        @Autowired
        StorageQueueTemplate storageQueueTemplate;
    
        public static void main(String[] args) {
            SpringApplication.run(StorageQueueMessagingApplication.class, args);
        }
    
        @Override
        public void run(String... args) {
            storageQueueTemplate
                .sendAsync(STORAGE_QUEUE_NAME, MessageBuilder.withPayload("Hello world").build())
                .subscribe();
            LOGGER.info("Message was sent successfully.");
    
            Message<?> message = storageQueueTemplate.receiveAsync(STORAGE_QUEUE_NAME, Duration.ofSeconds(30)).block();
            LOGGER.info("Received message: {}", new String((byte[]) message.getPayload()));
        }
    
    }
    
  3. 애플리케이션을 시작합니다. 시작 후 애플리케이션은 다음 예제와 유사한 로그를 생성합니다.

    Message was sent successfully.
    ...
    Received message: Hello World
    

Spring Integration Azure Storage 큐 사용

Spring Integration Azure Storage Queue 모듈은 스토리지 큐가 있는 Spring Integration 프레임워크를 지원합니다.

Spring 애플리케이션에서 Spring Integration 메시지 채널을 사용하는 경우 채널 어댑터를 사용하여 메시지 채널과 스토리지 큐 간에 메시지를 라우팅할 수 있습니다. 인바운드 채널 어댑터는 스토리지 큐에서 메시지 채널로 메시지를 전달합니다. 아웃바운드 채널 어댑터는 메시지 채널의 메시지를 스토리지 큐에 게시합니다.

다음 섹션에서는 Spring Integration Azure Storage Queue를 사용하여 스토리지 큐에서 메시지를 보내고 받는 방법을 보여 줍니다.

종속성 추가

Spring Integration Azure Storage Queue 모듈을 설치하려면 pom.xml 파일에 다음 종속성을 추가합니다.

  • Spring Cloud Azure Bill of Materials (BOM):

    <dependencyManagement>
       <dependencies>
         <dependency>
           <groupId>com.azure.spring</groupId>
           <artifactId>spring-cloud-azure-dependencies</artifactId>
           <version>7.1.0</version>
           <type>pom</type>
           <scope>import</scope>
           </dependency>
       </dependencies>
    </dependencyManagement>
    

    참고

    Spring Boot 4.0.x를 사용 중이라면, spring-cloud-azure-dependencies 버전을 7.1.0로 설정해야 합니다.

    Spring Boot 3.5.x를 사용하는 경우, spring-cloud-azure-dependencies 버전을 6.2.0로 설정해야 합니다.

    Spring Boot 3.1.x-3.5.x를 사용하는 경우, spring-cloud-azure-dependencies 버전을 5.25.0로 설정해야 합니다.

    Spring Boot 2.x를 사용하는 경우 spring-cloud-azure-dependencies 버전을 4.20.0로 설정해야 합니다.

    이 BOM(자재 명세서)을 <dependencyManagement> 섹션의 pom.xml 파일에서 구성해야 합니다. 이렇게 하면 모든 Spring Cloud Azure 종속성이 동일한 버전을 사용하게 됩니다.

    이 BOM에 사용되는 버전에 대한 자세한 내용은 스프링 클라우드 Azure 사용해야 하는 경우 참조하세요.

  • Spring Integration Azure Storage Queue 아티팩트:

    <dependency>
      <groupId>com.azure.spring</groupId>
      <artifactId>spring-cloud-azure-starter-integration-storage-queue</artifactId>
    </dependency>
    

메시지를 보내고 받도록 애플리케이션 코딩

다음 단계를 사용하여 애플리케이션을 구성하고 코딩합니다.

  1. 스토리지 큐에 대한 Azure Storage 계정 이름을 구성합니다.

    spring.cloud.azure.storage.queue.account-name=<your-storage-account-name>
    
  2. 다음 예제와 같이 새 QueueReceiveConfiguration Java 클래스를 만듭니다. 이 클래스는 메시지 수신자를 정의하는 데 사용됩니다. 자리 표시자를 사용자 고유의 <storage-queue-name> 값으로 바꿔야 합니다.

    import com.azure.spring.integration.storage.queue.inbound.StorageQueueMessageSource;
    import com.azure.spring.messaging.AzureHeaders;
    import com.azure.spring.messaging.checkpoint.Checkpointer;
    import com.azure.spring.messaging.storage.queue.core.StorageQueueTemplate;
    import org.slf4j.Logger;
    import org.slf4j.LoggerFactory;
    import org.springframework.context.annotation.Bean;
    import org.springframework.context.annotation.Configuration;
    import org.springframework.integration.annotation.InboundChannelAdapter;
    import org.springframework.integration.annotation.Poller;
    import org.springframework.integration.annotation.ServiceActivator;
    import org.springframework.messaging.handler.annotation.Header;
    
    @Configuration
    public class QueueReceiveConfiguration {
    
        private static final Logger LOGGER = LoggerFactory.getLogger(QueueReceiveConfiguration.class);
        private static final String STORAGE_QUEUE_NAME = "<storage-queue-name>";
        private static final String INPUT_CHANNEL = "input";
    
        @Bean
        @InboundChannelAdapter(channel = INPUT_CHANNEL, poller = @Poller(fixedDelay = "1000"))
        public StorageQueueMessageSource storageQueueMessageSource(StorageQueueTemplate storageQueueTemplate) {
            return new StorageQueueMessageSource(STORAGE_QUEUE_NAME, storageQueueTemplate);
        }
    
        @ServiceActivator(inputChannel = INPUT_CHANNEL)
        public void messageReceiver(byte[] payload, @Header(AzureHeaders.CHECKPOINTER) Checkpointer checkpointer) {
            String message = new String(payload);
            LOGGER.info("Received message: {}", message);
        }
    
    }
    
  3. 다음 예제와 같이 새 QueueSendConfiguration Java 클래스를 만듭니다. 이 클래스는 메시지 발신자를 정의하는 데 사용됩니다. 자리 표시자를 사용자 고유의 <storage-queue-name> 값으로 바꿔야 합니다.

    import com.azure.spring.integration.core.handler.DefaultMessageHandler;
    import com.azure.spring.messaging.storage.queue.core.StorageQueueTemplate;
    import org.slf4j.Logger;
    import org.slf4j.LoggerFactory;
    import org.springframework.context.annotation.Bean;
    import org.springframework.context.annotation.Configuration;
    import org.springframework.integration.annotation.MessagingGateway;
    import org.springframework.integration.annotation.ServiceActivator;
    import org.springframework.messaging.MessageHandler;
    import org.springframework.util.concurrent.ListenableFutureCallback;
    
    @Configuration
    public class QueueSendConfiguration {
    
        private static final Logger LOGGER = LoggerFactory.getLogger(QueueSendConfiguration.class);
        private static final String STORAGE_QUEUE_NAME = "<storage-queue-name>";
        private static final String OUTPUT_CHANNEL = "output";
    
        @Bean
        @ServiceActivator(inputChannel = OUTPUT_CHANNEL)
        public MessageHandler messageSender(StorageQueueTemplate storageQueueTemplate) {
            DefaultMessageHandler handler = new DefaultMessageHandler(STORAGE_QUEUE_NAME, storageQueueTemplate);
            handler.setSendCallback(new ListenableFutureCallback<Void>() {
                @Override
                public void onSuccess(Void result) {
                    LOGGER.info("Message was sent successfully.");
                }
    
                @Override
                public void onFailure(Throwable ex) {
                    LOGGER.info("There was an error sending the message.");
                }
            });
            return handler;
        }
    
        @MessagingGateway(defaultRequestChannel = OUTPUT_CHANNEL)
        public interface StorageQueueOutboundGateway {
            void send(String text);
        }
    
    }
    
  4. 보낸 사람과 수신자를 연결하여 Spring을 사용하여 메시지를 보내고 받습니다.

    import org.springframework.boot.SpringApplication;
    import org.springframework.boot.autoconfigure.SpringBootApplication;
    import org.springframework.context.ConfigurableApplicationContext;
    import org.springframework.context.annotation.Configuration;
    import org.springframework.integration.config.EnableIntegration;
    
    @SpringBootApplication
    @EnableIntegration
    @Configuration(proxyBeanMethods = false)
    public class StorageQueueIntegrationApplication {
    
        public static void main(String[] args) {
            ConfigurableApplicationContext applicationContext = SpringApplication.run(StorageQueueIntegrationApplication.class, args);
            QueueSendConfiguration.StorageQueueOutboundGateway storageQueueOutboundGateway = applicationContext.getBeanQueueSendConfiguration.StorageQueueOutboundGateway.class);
            storageQueueOutboundGateway.send("Hello World");
        }
    
    }
    

    Spring Integration 인프라를 활용하기 위해 @EnableIntegration 주석을 추가하는 것을 잊지 마세요.

  5. 애플리케이션을 시작합니다. 시작 후 애플리케이션은 다음 예제와 유사한 로그를 생성합니다.

    Message was sent successfully.
    Received message: Hello World
    

Azure Spring Apps 배포

이제 Spring Boot 애플리케이션을 로컬로 실행했으므로 이제 프로덕션으로 이동해야 합니다. Azure Spring Apps 사용하면 코드를 변경하지 않고도 Azure Spring Boot 애플리케이션을 쉽게 배포할 수 있습니다. 이 서비스는 개발자가 코드에 집중할 수 있도록 Spring 애플리케이션의 인프라를 관리합니다. Azure Spring Apps 포괄적인 모니터링 및 진단, 구성 관리, 서비스 검색, CI/CD 통합, 청록색 배포 등을 사용하여 수명 주기 관리를 제공합니다. Azure Spring Apps 애플리케이션을 배포하려면 Azure Spring Apps 첫 번째 애플리케이션 배포를 참조하세요.

다음 단계

참고 항목

Microsoft Azure 사용할 수 있는 Spring Boot Starters에 대한 자세한 내용은 Spring Cloud Azure?