2016-07-29 2 views
1

임베디드 JMS 대기열을 사용하는 간단한 스프링 부트 응용 프로그램을 설정하려고합니다. HornetQ는 성공했지만 Artemis로 전환하려고 시도 할 때 ArtemisConnectionFactory에서 오류가 발생했습니다. 여기에 HornetQ에 사용하는 코드가 있습니다. 도움이된다면 감사 할 것입니다.스프링 부트 Apache Artemis 임베디드 JMS 대기열 샘플

package com.comporium.log.server; 

import javax.jms.ConnectionFactory; 

import org.springframework.beans.factory.annotation.Autowired; 
import org.springframework.boot.SpringApplication; 
import org.springframework.boot.autoconfigure.SpringBootApplication; 
import org.springframework.context.annotation.Bean; 
import org.springframework.context.annotation.PropertySource; 
import org.springframework.jms.listener.DefaultMessageListenerContainer; 

import com.comporium.log.server.services.LogListener; 

@SpringBootApplication 
public class Application { 
@Autowired 
private ConnectionFactory connectionFactory; 

@Autowired 
LogListener logListener; 

@Bean 
public DefaultMessageListenerContainer messageListener() { 
    DefaultMessageListenerContainer container = new DefaultMessageListenerContainer(); 
    container.setConnectionFactory(this.connectionFactory); 
    container.setDestinationName("loggerQueue"); 
    container.setMessageListener(logListener); 
    return container; 
} 

public static void main(String[] args) throws Exception { 
    SpringApplication.run(Application.class, args); 
    } 
} 

답변

0

제게는 코드가 작동했습니다. 응용 프로그램을 테스트하기 위해 메시지를 생성하는 CommandLineRunner을 추가했습니다.

@Bean 
CommandLineRunner sendMessage(JmsTemplate jmsTemplate) { 
    return args -> { 
     jmsTemplate.convertAndSend("loggerQueue", "Message to Artemis"); 
    }; 
} 

소비자는이 대기열로 보낸 메시지를 소비합니다. 속성을 선언 할 필요는 없지만 프로젝트에 다음 컴파일 시간 종속성을 정의했습니다.

compile('org.springframework.boot:spring-boot-starter-artemis') 
compile('org.apache.activemq:artemis-jms-server')