Installation and use of ActiveMQ (Springboot version)

Source: Internet
Author: User

First, installation

Web Download Tar Package

http://activemq.apache.org/

TAR-ZXVF after entering bin/linux-86-64

./activimq Start

Start

Second, use

Pom File Introduction Dependency

<dependency>            <groupId>com.alibaba</groupId>            <artifactid>fastjson</ artifactid>            <version>1.2.47</version>        </dependency>        <dependency>            <groupId>org.springframework.boot</groupId>            <artifactId>spring-boot-starter-activemq< /artifactid>        </dependency>        <dependency>            <groupid>org.apache.activemq</ groupid>            <artifactId>activemq-pool</artifactId>        </dependency>        < Dependency>

Configuration file for Application.properties

SPRING.ACTIVEMQ.BROKER-URL=TCP://39.108.83.105:61616#spring. ACTIVEMQ.BROKER-URL=TCP://  127.0.0.1:61616spring.activemq.user=spring.activemq.password=  spring.activemq.pool.enabled=truespring.activemq.pool.max-connections=50  Spring.activemq.pool.expiry-timeout=10000spring.activemq.pool.idle-timeout=30000# Topic type Message This is Truespring.jms.pub-sub-domain=true

Producer Code:

@Component  Public class JMSProducer {    @Autowired    private  jmstemplate jmstemplate;      Public void sendMessage (Destination Destination, String message) {        this. Jmstemplate.convertandsend (destination,message);    }}

Consumer Code:

@Component  Public class Jmsconsumer {    = "MyTopic")    publicvoid  receivequeue (String msg) {        System.out.println (msg);}    }

Call class:

    @PostMapping ("/posttopic")    public  String posttopic (@RequestBody jsonobject reqbody) {         New Activemqtopic ("MyTopic");        Jmsproducer.sendmessage (Mytopic,reqbody.tojsonstring ());         return "Success";    }

Installation and use of ActiveMQ (Springboot version)

Contact Us

The content source of this page is from Internet, which doesn't represent Alibaba Cloud's opinion; products and services mentioned on that page don't have any relationship with Alibaba Cloud. If the content of the page makes you feel confusing, please write us an email, we will handle the problem within 5 days after receiving your email.

If you find any instances of plagiarism from the community, please send an email to: info-contact@alibabacloud.com and provide relevant evidence. A staff member will contact you within 5 working days.

A Free Trial That Lets You Build Big!

Start building with 50+ products and up to 12 months usage for Elastic Compute Service

  • Sales Support

    1 on 1 presale consultation

  • After-Sales Support

    24/7 Technical Support 6 Free Tickets per Quarter Faster Response

  • Alibaba Cloud offers highly flexible support services tailored to meet your exact needs.