2016-07-29 10 views
1

埋め込みJMSキューを使用する単純なSpringブートアプリケーションを設定しようとしています。私はHornetQで成功していますが、Artemisに変換しようとするとArtemisConnectionFactoryに失敗します。ここで私がHornetQに使用するコードを示します。どんな助けでも感謝します。Springブート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') 
関連する問題