Active MQ

Uploaded on

made by Kris.jey …

made by Kris.jey

What is ActiveMQ

More in: Technology , Education
  • Full Name Full Name Comment goes here.
    Are you sure you want to
    Your message goes here
    Be the first to comment
No Downloads


Total Views
On Slideshare
From Embeds
Number of Embeds



Embeds 0

No embeds

Report content

Flagged as inappropriate Flag as inappropriate
Flag as inappropriate

Select your reason for flagging this presentation as inappropriate.

    No notes for slide


  • 1. - JMS 시스템의 이해 미디어 검색팀 정경석 2012. 05 .09
  • 2.  What is JMS? Why JMS? Producer/Consumer Type of JMS model About ActiveMQ When is the right time to use ActiveMQ? How to use ActiveMQ? How to monitoring in ActiveMQ? Fault tolerance and High availability
  • 3.  JMS is Java Message Service Standard J2EE messaging API JMS is asynchronous in nature Producer/Consumer pattern의 구현체 Producer, Message, Consumer로 구성됨. Message broker system  메시지 전송 중계를 담당.  Message의 전송을 보장.  즉, JMS를 통해 전송된 메시지는 반드시 목적지에 도달함.
  • 4.  Heterogeneous application integration  Unix <-> IBM Host, Java <-> C++  이기종, 다른 언어로 작성된 Applicaion간의 업무 통 합이 가능함. High reliability and the performance Do not need to concern about communication.  데이터의 통신은 JMS가 담당 하므로 개발자는 순수 하게 메시지에만 관심을 가질 수 있음  메시지 전송의 투명성을 가짐.
  • 5. Broker(JMS) Producer Consumer 생산자는 메시지를 만들어서 Broker에게 전송. 소비자는 Broker로 부터 메시지를 수신 즉, 메시지가 생성되어 소비하기까지의 과정을 중계하는 역할
  • 6.  Point to Point(Sender/Receiver)  하나의 메시지는 하나의 목적지로만 전달됨.  특정한 App이 메시지를 수신하도록 유도 가능. Sender Queue Receiver 1 Receiver 2 Publish and Subscribe  하나의 메시지는 다중의 목적지로 전달됨.  모든 App이 메시지를 수신 Publisher Topic Subscriber Subscriber
  • 7.  Most popular and powerful open source Message Broker Java based JMS implementation Spring Integration with ActiveMQ Fault tolerance(High availability) Easy to Scale out Supports a large number of Cross Language Clients(C#, C++, Perl, PHP, Python, Ruby, Delphi…)
  • 8.  RPC의 대체(Async) Event Driven Architecture with POJOs (Shopping) Software적인 scalability를 보장받고자 하는 경 우(SOA) 메시지 전송의 보장이 필요한 경우(System간) Transaction load balancing 필요한 경우 각 시스템에 동일한 메시지를 전달해야 하는 경 우(Notification)
  • 9.  Install ActiveMQ(using default setting). Write sender application(using ActiveMQ Lib) Write receiver application(using ActiveMQ Lib) Broker(JMS) Producer Consumer (Sender) (Receiver)
  • 10. Write sender applicationActiveMQConnectionFactory connectionFactory = newActiveMQConnectionFactory(“tcp://”);Connection connection = connectionFactory.createConnection();connection.start();// Create the sessionsession = connection.createSession(true, Session.AUTO_ACKNOWLEDGE);destination = session.createQueue(“com.jjanglive.jPush”);// Create the producer.producer = session.createProducer(destination);producer.setDeliveryMode(DeliveryMode.NON_PERSISTENT);TextMessage textMessage = session.createTextMessage(“This is a sample message!!”);producer.send(textMessage);
  • 11. Write receiver application with Springpublic class SampleMessageHandler implements MessageListener {@Overridepublic void onMessage(Message message) { // do something System.out.println(“Message Received!!!!!!!!”);}
  • 12. Spring setting<bean id="connectionFactory"class="org.apache.activemq.spring.ActiveMQConnectionFactory"><property name="brokerURL" value="failover:tcp://" /></bean><bean id="jPushQueue" class="org.apache.activemq.command.ActiveMQQueue"><constructor-arg index="0" value="com.jjanglive.jPush" /></bean><bean class="org.springframework.jms.listener.DefaultMessageListenerContainer"><property name="connectionFactory" ref="connectionFactory" /><property name="destination" ref="jPushQueue" /><property name="messageListener" ref="jMessageListenerAdapter" /></bean><bean id="jMessageListenerAdapter"class="org.springframework.jms.listener.adapter.MessageListenerAdapter"><constructor-arg><bean class="com.jjanglive.jpush.message.handler.JPushMessageHandler"></bean></constructor-arg></bean>
  • 13. Connect to http://server_address:8161/admin
  • 14. Broker down case MQ Client MQ Client … MQ Client Broker Agent Failover connect Active Active Active MQ 1 MQ 2 … MQ n Receiver 1 Receiver 2 … Receiver n 특정 Broker가 Down된 경우 MQ Client와 Receiver는 자동으로 down을 감 지하고 살아 있는 Broker를 찾아 auto reconnect