GithubHelp home page GithubHelp logo

spring-activemq-example's Introduction

Spring ActiveMQ Example

Application Overview

name teyp description
spring-activemq-example-lib jar Application 전체에서 사용할 Core 기능과 Consumer / Producer에서 공통으로 사용할 비지니스 로직을 포함하고 있습니다.
spring-activemq-example-producer war 간단한 CRUD Application 입니다. Google Guava 기반의 Event 방식으로 MQ에 요청을 합니다.
spring-activemq-example-consumer war MQ에 요청된 것을 처리하고 상태를 조회할 수 있는 API를 제공합니다.

ActiveMQ 구동하기 (Start ActiveMQ Message Broker)

ActiveMQ Homepage에서 Download 한 후, env 설정을 한 후, start 해 줍니다.

$ mkdir -p /d/poc/mq/src
$ cd /d/poc/mq/src

# -- 다운로드
$ wget wget http://archive.apache.org/dist/activemq/5.14.0/apache-activemq-5.14.0-bin.tar.gz

# -- 압축 해제
$ tar xvzf apache-activemq-5.14.0-bin.tar.gz

# -- 디렉토리 이동 및 Symbolic Link 생성
$ mv apache-activemq-5.14.0 .. && cd .. && ln -s ./apache-activemq-5.14.0 apache-activemq-5

# -- 설정
# env 파일의 110 line에 JAVA_HOME을 설정
$ cd apache-activemq-5
$ vi ./bin/env
...
106 # Location of the java installation
107 # Specify the location of your java installation using JAVA_HOME, or specify the
108 # path to the "java" binary using JAVACMD
109 # (set JAVACMD to "auto" for automatic detection)
110 JAVA_HOME="/usr/java/jdk1.7.0"
111 JAVACMD="auto"
112

# -- 구동
$ cd apache-activemq-5
$ bin/activemq start
INFO: Loading '/cygdrive/d/poc/mq/apache-activemq-5.14.0/bin/env'
INFO: Using java '/usr/java/jdk1.7.0/bin/java'
INFO: Starting - inspect logfiles specified in logging.properties and log4j.properties to get details
INFO: pidfile created : '/cygdrive/d/poc/mq/apache-activemq-5.14.0/data/activemq.pid' (pid '4448')

Monitoring 하기

내장 Web Console 사용하기

Standalone로 구동하면 내장된 Web Console(http://localhost:8161/admin/ with credentials admin/admin)을 통해 상태를 확인할 수 있습니다.

activemq-web-console.png

hawtio 사용하기

참고문서

ActiveMQ의 내장 Web Console도 좋기는 하지만 제공해 주는 것 이외에 다른 정보들을 확인하기 어려운 단점이 있습니다. 개인적으로 생각하는 제일 좋은 대안은 JMXTrans + InfluxDB + Grafana 입니다만 설치나 관리의 복잡도가 올라가니 여기서는 JBoss Community의 Open Source Web Console 인 hawtio를 설치하고 사용해 보도록 하겠습니다.

이미 Apache ActiveMQ는 설치했으므로 여기서는 hawtio(offline war version)만 다운로드 받아서 설치하고 확인해 보도록 하겠습니다.

# -- 다운로드
$ cd /d/poc/mq/src
$ wget https://oss.sonatype.org/content/repositories/public/io/hawt/hawtio-default-offline/1.4.65/hawtio-default-offline-1.4.65.war

# -- 압축 해제
$ unzip hawtio-default-offline-1.4.65.war -d hawtio

# -- ActiveMQ의 webapps 디렉토리로 이동
$ mv -v hawtio /d/poc/mq/apache-activemq-5/webapps
‘hawtio’ -> ‘/d/poc/mq/apache-activemq-5/webapps/hawtio’

# -- jetty에서 context 등록
$ cd /d/poc/mq/apache-activemq-5/conf
$ vi jetty
...
 61         <bean id="secHandlerCollection" class="org.eclipse.jetty.server.handler.HandlerCollection">
 62                 <property name="handlers">
 63                         <list>
 64                     <ref bean="rewriteHandler"/>
 65                                 <bean class="org.eclipse.jetty.webapp.WebAppContext">
 66                                         <property name="contextPath" value="/admin" />
 67                                         <property name="resourceBase" value="${activemq.home}/webapps/admin" />
 68                                         <property name="logUrlOnStart" value="true" />
 69                                 </bean>
 70                                 <bean class="org.eclipse.jetty.webapp.WebAppContext">
 71                                         <property name="contextPath" value="/hawtio" />
 72                                         <property name="resourceBase" value="${activemq.home}/webapps/hawtio" />
 73                                         <property name="logUrlOnStart" value="true" />
 74                                 </bean>
 75                                 <bean class="org.eclipse.jetty.webapp.WebAppContext">
 76                                         <property name="contextPath" value="/api" />
 77                                         <property name="resourceBase" value="${activemq.home}/webapps/api" />
 78                                         <property name="logUrlOnStart" value="true" />
 79                                 </bean>
...
## 70-74 line에 hawtio에 대해 등록

# -- hawtio의 권한을 activemq의 권한을 사용하도록 하기 위해 activemq/bin/env 파일에 아래의 내용 추가
# -- env파일에서 `ACTIVEMQ_OPTS`를 찾아서 아래의 3개의 설정을 추가한다.
$ cd /d/poc/mq/apache-activemq-5/bin
$ vi env
39
40 ACTIVEMQ_OPTS="${ACTIVEMQ_OPTS} -Dhawtio.realm=activemq"
41 ACTIVEMQ_OPTS="${ACTIVEMQ_OPTS} -Dhawtio.role=admins"
42 ACTIVEMQ_OPTS="${ACTIVEMQ_OPTS} -Dhawtio.rolePrincipalClasses=org.apache.activemq.jaas.GroupPrincipal"
43 

ActiveMQ를 구동하고 http://localhost:8161/hawtio로 접속하면 다음과 같은 화면을 확인할 수 있다.

activemq-hawtio-web-console.png

Networks of Borkers (Broker들의 네트워크) 구성하기

ActiveMQ의 Clustering 방법 중에 하나가 바로 Networks of Brokers 입니다. 간단히 말하면 Broker 간의 연결을 통해서 Producer와 Consumer를 연결해 주는 기능이라고 생각하시면 됩니다.

참고문서

Event 기반

Guava 관련

spring-activemq-example's People

Contributors

brainagenet avatar

Watchers

 avatar

Forkers

fairybabo

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.