├── .gitignore
├── .project
├── Artemis-Broker-Creation.png
├── README.md
├── consumer
├── .classpath
├── .project
├── .settings
│ ├── org.eclipse.core.resources.prefs
│ ├── org.eclipse.jdt.core.prefs
│ └── org.eclipse.m2e.core.prefs
├── artemis-consumer.iml
├── pom.xml
├── src
│ ├── main
│ │ ├── java
│ │ │ └── com
│ │ │ │ └── sbm
│ │ │ │ └── artemis
│ │ │ │ └── demo
│ │ │ │ ├── SpringBootArtemisConsumerApplication.java
│ │ │ │ └── jms
│ │ │ │ ├── ArtemisConsumer.java
│ │ │ │ └── Person.java
│ │ └── resources
│ │ │ └── application.properties
│ └── test
│ │ └── java
│ │ └── com
│ │ └── sbm
│ │ └── artemis
│ │ └── demo
│ │ └── SpringBootArtemisConsumerApplicationTests.java
└── target
│ ├── artemis-consumer-0.1.0.jar.original
│ ├── classes
│ └── application.properties
│ ├── maven-archiver
│ └── pom.properties
│ └── maven-status
│ └── maven-compiler-plugin
│ ├── compile
│ └── default-compile
│ │ ├── createdFiles.lst
│ │ └── inputFiles.lst
│ └── testCompile
│ └── default-testCompile
│ ├── createdFiles.lst
│ └── inputFiles.lst
├── pom.xml
├── producer
├── .classpath
├── .project
├── .settings
│ ├── org.eclipse.core.resources.prefs
│ ├── org.eclipse.jdt.core.prefs
│ └── org.eclipse.m2e.core.prefs
├── artemis-producer.iml
├── pom.xml
├── src
│ ├── main
│ │ ├── java
│ │ │ └── com
│ │ │ │ └── sbm
│ │ │ │ └── artemis
│ │ │ │ └── demo
│ │ │ │ ├── SpringBootArtemisProducerApplication.java
│ │ │ │ ├── controller
│ │ │ │ └── RestApiController.java
│ │ │ │ └── jms
│ │ │ │ ├── ArtemisProducer.java
│ │ │ │ ├── MessagingConfiguration.java
│ │ │ │ └── Person.java
│ │ └── resources
│ │ │ └── application.properties
│ └── test
│ │ └── java
│ │ └── com
│ │ └── sbm
│ │ └── artemis
│ │ └── demo
│ │ └── SpringBootArtemisProducerApplicationTests.java
└── target
│ ├── artemis-producer-0.1.0.jar.original
│ ├── classes
│ └── application.properties
│ ├── maven-archiver
│ └── pom.properties
│ └── maven-status
│ └── maven-compiler-plugin
│ ├── compile
│ └── default-compile
│ │ ├── createdFiles.lst
│ │ └── inputFiles.lst
│ └── testCompile
│ └── default-testCompile
│ ├── createdFiles.lst
│ └── inputFiles.lst
├── spring-boot-artemis-demo-multi-module.iml
└── springboot-artemis-architecture.png
/.gitignore:
--------------------------------------------------------------------------------
1 | # Compiled class file
2 | *.class
3 |
4 | # Log file
5 | *.log
6 |
7 | # BlueJ files
8 | *.ctxt
9 |
10 | # Mobile Tools for Java (J2ME)
11 | .mtj.tmp/
12 |
13 | # Package Files #
14 | *.jar
15 | *.war
16 | *.ear
17 | *.zip
18 | *.tar.gz
19 | *.rar
20 |
21 | # virtual machine crash logs, see http://www.java.com/en/download/help/error_hotspot.xml
22 | hs_err_pid*
23 |
24 | #idea
25 | .idea
26 | .settings
27 | .project
28 | # User-specific stuff:
29 | .idea/**/workspace.xml
30 | .idea/**/tasks.xml
31 | .idea/dictionaries
32 |
33 | # Sensitive or high-churn files:
34 | .idea/**/dataSources/
35 | .idea/**/dataSources.ids
36 | .idea/**/dataSources.xml
37 | .idea/**/dataSources.local.xml
38 | .idea/**/sqlDataSources.xml
39 | .idea/**/dynamic.xml
40 | .idea/**/uiDesigner.xml
--------------------------------------------------------------------------------
/.project:
--------------------------------------------------------------------------------
1 |
2 |
3 | spring-boot-artemis-demo-multi-module
4 |
5 |
6 |
7 |
8 |
9 | org.eclipse.m2e.core.maven2Builder
10 |
11 |
12 |
13 |
14 |
15 | org.eclipse.m2e.core.maven2Nature
16 |
17 |
18 |
--------------------------------------------------------------------------------
/Artemis-Broker-Creation.png:
--------------------------------------------------------------------------------
https://raw.githubusercontent.com/hosnimed/spring-boot-artemis-demo/ad715b453125fd8750b00100f62e48a04ffa9d4b/Artemis-Broker-Creation.png
--------------------------------------------------------------------------------
/README.md:
--------------------------------------------------------------------------------
1 | # SpringBoot Artemis Demo
2 | A sample project to demonstrate the asynchronous communication between two spring boot apps producer and consumer through Apache ActiveMQ Artemis 2.4.0
3 |
4 |
5 | # Introduction
6 | Apache ActiveMQ Artemis is a combined feature-set of ActiveMQ/HornetQ/Apollo. It provides a non blocking architecture for an outstanding performance.
7 |
8 | # Technologies
9 | - Java 8
10 | - Maven 3
11 | - Spring Boot: 1.5.4.RELEASE
12 | - Apache Artemis 2.4.0
13 |
14 | # SpringBoot Artemis applications
15 | In the Demo, we create 2 SpringBoot Artemis projects for producer/consumer:
16 | 
17 |
18 | **Run Artemis**
19 |
20 | ```sh
21 | $ ${apache-artemis-home}\bin\artemis create ${apache-artemis-broker-dest}\broker1
22 |
23 | $${apache-artemis-broker-dest}\broker1\bin\artemis run
24 |
25 | ```
26 |
27 | 
28 |
29 | **Configure artemis queue**
30 | Go to {apache-artemis-broker-dest}\broker1\etc\broker.xml
31 |
32 | ```xml
33 |
34 |
35 |
36 |
37 |
38 |
39 |
40 |
41 | ```
42 |
43 |
44 | **Run the project**
45 |
46 | ```sh
47 | $ mvn clean package
48 | $ java -jar .\target\artemis-consumer-0.1.0.jar
49 | $ java -jar .\target\artemis-producer-0.1.0.jar
50 | ```
51 |
52 |
53 | **Test it**
54 | - Simple String Message
55 | ```cmd
56 | $ curl http://localhost:8080/produce?msg="Hello Artemis!"
57 | ```
58 | - Pojo Object
59 | ```cmd
60 | $curl -X POST \
61 | http://localhost:8080/produce -H 'content-type: application/json' -d '{"id":"1000", "name":"Hosni"}'
62 | ```
63 |
64 | # References
65 |
66 | - Apache ActiveMQ Artemis https://activemq.apache.org/artemis/
67 | - amazing Tutorial
68 | http://javasampleapproach.com/spring-framework/spring-jms/apache-artemis-produceconsume-jms-messages-springboot-artemis-applications
69 | - Advanced Themes : http://nordlander.co/getting-started-with-apache-activemq-artemis/
--------------------------------------------------------------------------------
/consumer/.classpath:
--------------------------------------------------------------------------------
1 |
2 |
3 |
4 |
5 |
6 |
7 |
8 |
9 |
10 |
11 |
12 |
13 |
14 |
15 |
16 |
17 |
18 |
19 |
20 |
21 |
22 |
23 |
24 |
25 |
26 |
27 |
28 |
29 |
30 |
31 |
32 |
--------------------------------------------------------------------------------
/consumer/.project:
--------------------------------------------------------------------------------
1 |
2 |
3 | artemis-consumer
4 |
5 |
6 |
7 |
8 |
9 | org.eclipse.jdt.core.javabuilder
10 |
11 |
12 |
13 |
14 | org.eclipse.m2e.core.maven2Builder
15 |
16 |
17 |
18 |
19 |
20 | org.eclipse.jdt.core.javanature
21 | org.eclipse.m2e.core.maven2Nature
22 |
23 |
24 |
--------------------------------------------------------------------------------
/consumer/.settings/org.eclipse.core.resources.prefs:
--------------------------------------------------------------------------------
1 | eclipse.preferences.version=1
2 | encoding//src/main/java=UTF-8
3 | encoding//src/main/resources=UTF-8
4 | encoding//src/test/java=UTF-8
5 | encoding/=UTF-8
6 |
--------------------------------------------------------------------------------
/consumer/.settings/org.eclipse.jdt.core.prefs:
--------------------------------------------------------------------------------
1 | eclipse.preferences.version=1
2 | org.eclipse.jdt.core.compiler.codegen.targetPlatform=1.8
3 | org.eclipse.jdt.core.compiler.compliance=1.8
4 | org.eclipse.jdt.core.compiler.problem.forbiddenReference=warning
5 | org.eclipse.jdt.core.compiler.source=1.8
6 |
--------------------------------------------------------------------------------
/consumer/.settings/org.eclipse.m2e.core.prefs:
--------------------------------------------------------------------------------
1 | activeProfiles=
2 | eclipse.preferences.version=1
3 | resolveWorkspaceProjects=true
4 | version=1
5 |
--------------------------------------------------------------------------------
/consumer/artemis-consumer.iml:
--------------------------------------------------------------------------------
1 |
2 |
3 |
4 |
5 |
6 |
7 |
8 |
9 |
10 |
11 |
12 |
13 |
14 |
15 |
16 |
17 |
18 |
19 |
20 |
21 |
22 |
23 |
24 |
25 |
26 |
27 |
28 |
29 |
30 |
31 |
32 |
33 |
34 |
35 |
36 |
37 |
38 |
39 |
40 |
41 |
42 |
43 |
44 |
45 |
46 |
47 |
48 |
49 |
50 |
51 |
52 |
53 |
54 |
55 |
56 |
57 |
58 |
59 |
60 |
61 |
62 |
63 |
64 |
65 |
66 |
67 |
68 |
69 |
--------------------------------------------------------------------------------
/consumer/pom.xml:
--------------------------------------------------------------------------------
1 |
2 |
4 | 4.0.0
5 |
6 | artemis-consumer
7 | jar
8 |
9 | consumer
10 | SpringBootArtemisConsumer
11 |
12 |
13 | com.sbm.artemis.demo
14 | spring-boot-artemis-demo-multi-module
15 | 0.1.0
16 |
17 |
18 |
19 | UTF-8
20 | UTF-8
21 | 1.8
22 |
23 |
24 |
25 |
26 | org.springframework.boot
27 | spring-boot-starter
28 |
29 |
30 |
31 | org.springframework
32 | spring-jms
33 |
34 |
35 |
36 | org.apache.activemq
37 | artemis-jms-client
38 | 2.1.0
39 |
40 |
41 |
42 | org.springframework.boot
43 | spring-boot-starter-test
44 | test
45 |
46 |
47 |
48 |
49 |
50 |
51 | org.springframework.boot
52 | spring-boot-maven-plugin
53 |
54 |
55 |
56 |
57 |
58 |
59 |
--------------------------------------------------------------------------------
/consumer/src/main/java/com/sbm/artemis/demo/SpringBootArtemisConsumerApplication.java:
--------------------------------------------------------------------------------
1 | package com.sbm.artemis.demo;
2 |
3 | import org.springframework.boot.SpringApplication;
4 | import org.springframework.boot.autoconfigure.SpringBootApplication;
5 |
6 | @SpringBootApplication
7 | public class SpringBootArtemisConsumerApplication {
8 |
9 | public static void main(String[] args) {
10 | SpringApplication.run(SpringBootArtemisConsumerApplication.class, args);
11 | }
12 | }
13 |
--------------------------------------------------------------------------------
/consumer/src/main/java/com/sbm/artemis/demo/jms/ArtemisConsumer.java:
--------------------------------------------------------------------------------
1 | package com.sbm.artemis.demo.jms;
2 |
3 | import org.springframework.jms.annotation.JmsListener;
4 | import org.springframework.jms.listener.adapter.MessageListenerAdapter;
5 | import org.springframework.messaging.Message;
6 | import org.springframework.messaging.MessageHeaders;
7 | import org.springframework.messaging.converter.MessageConverter;
8 | import org.springframework.stereotype.Component;
9 |
10 | @Component
11 | public class ArtemisConsumer { // implements MessageConverter {
12 |
13 |
14 | @JmsListener(destination = "${jms.queue.destination}")
15 | public void receive(Message message){
16 | if(message.getPayload() instanceof String){
17 | System.out.println("Recieved Message: " + message.getPayload().toString());
18 | }else if (message.getPayload() instanceof Person){
19 | System.out.println("Recieved Person: " + message.getPayload().toString());
20 | }else {
21 | System.err.println("Message Type Unkown !");
22 | }
23 | }
24 |
25 | /*
26 |
27 | @Override
28 | public Object fromMessage(Message> message, Class> targetClass) {
29 | System.out.println("from Message.getPayload() = " + message.getPayload().toString());
30 | return message;
31 | }
32 |
33 | @Override
34 | public Message> toMessage(Object payload, MessageHeaders headers) {
35 | System.out.println("to Message.getPayload() = " + payload.toString());
36 | return (Message) ( payload );
37 | }
38 |
39 | */
40 |
41 | }
--------------------------------------------------------------------------------
/consumer/src/main/java/com/sbm/artemis/demo/jms/Person.java:
--------------------------------------------------------------------------------
1 | package com.sbm.artemis.demo.jms;
2 |
3 | import lombok.AllArgsConstructor;
4 | import lombok.Data;
5 | import lombok.NoArgsConstructor;
6 |
7 | import java.io.Serializable;
8 |
9 | //@Data
10 | //@AllArgsConstructor
11 | //@NoArgsConstructor
12 | public class Person implements Serializable{
13 |
14 | private static final long serialVersionUID = 1L;
15 |
16 | private String id;
17 | private String name;
18 |
19 | public Person() {
20 | }
21 |
22 | public Person(String id, String name) {
23 | this.id = id;
24 | this.name = name;
25 | }
26 |
27 | public String getId() {
28 | return id;
29 | }
30 |
31 | public void setId(String id) {
32 | this.id = id;
33 | }
34 |
35 | public String getName() {
36 | return name;
37 | }
38 |
39 | public void setName(String name) {
40 | this.name = name;
41 | }
42 |
43 | @Override
44 | public String toString() {
45 | return "Person{" +
46 | "id='" + id + '\'' +
47 | ", name='" + name + '\'' +
48 | '}';
49 | }
50 | }
51 |
--------------------------------------------------------------------------------
/consumer/src/main/resources/application.properties:
--------------------------------------------------------------------------------
1 | spring.artemis.mode=native
2 | spring.artemis.host=localhost
3 | spring.artemis.port=61616
4 | spring.artemis.user=user
5 | spring.artemis.password=password
6 | jms.queue.destination=demoQueue
--------------------------------------------------------------------------------
/consumer/src/test/java/com/sbm/artemis/demo/SpringBootArtemisConsumerApplicationTests.java:
--------------------------------------------------------------------------------
1 | package com.sbm.artemis.demo;
2 |
3 | import org.junit.Test;
4 | import org.junit.runner.RunWith;
5 | import org.springframework.boot.test.context.SpringBootTest;
6 | import org.springframework.test.context.junit4.SpringRunner;
7 |
8 | @RunWith(SpringRunner.class)
9 | @SpringBootTest
10 | public class SpringBootArtemisConsumerApplicationTests {
11 |
12 | @Test
13 | public void contextLoads() {
14 | }
15 |
16 | }
17 |
--------------------------------------------------------------------------------
/consumer/target/artemis-consumer-0.1.0.jar.original:
--------------------------------------------------------------------------------
https://raw.githubusercontent.com/hosnimed/spring-boot-artemis-demo/ad715b453125fd8750b00100f62e48a04ffa9d4b/consumer/target/artemis-consumer-0.1.0.jar.original
--------------------------------------------------------------------------------
/consumer/target/classes/application.properties:
--------------------------------------------------------------------------------
1 | spring.artemis.mode=native
2 | spring.artemis.host=localhost
3 | spring.artemis.port=61616
4 | spring.artemis.user=user
5 | spring.artemis.password=password
6 | jms.queue.destination=demoQueue
--------------------------------------------------------------------------------
/consumer/target/maven-archiver/pom.properties:
--------------------------------------------------------------------------------
1 | #Generated by Apache Maven
2 | #Mon Dec 04 16:20:07 WAT 2017
3 | version=0.1.0
4 | groupId=com.sbm.artemis.demo
5 | artifactId=artemis-consumer
6 |
--------------------------------------------------------------------------------
/consumer/target/maven-status/maven-compiler-plugin/compile/default-compile/createdFiles.lst:
--------------------------------------------------------------------------------
1 | com\sbm\artemis\demo\SpringBootArtemisConsumerApplication.class
2 | com\sbm\artemis\demo\jms\ArtemisConsumer.class
3 | com\sbm\artemis\demo\jms\Person.class
4 |
--------------------------------------------------------------------------------
/consumer/target/maven-status/maven-compiler-plugin/compile/default-compile/inputFiles.lst:
--------------------------------------------------------------------------------
1 | C:\java-dev\activemq-artemis\spring-boot-artemis-demo\consumer\src\main\java\com\sbm\artemis\demo\jms\ArtemisConsumer.java
2 | C:\java-dev\activemq-artemis\spring-boot-artemis-demo\consumer\src\main\java\com\sbm\artemis\demo\jms\Person.java
3 | C:\java-dev\activemq-artemis\spring-boot-artemis-demo\consumer\src\main\java\com\sbm\artemis\demo\SpringBootArtemisConsumerApplication.java
4 |
--------------------------------------------------------------------------------
/consumer/target/maven-status/maven-compiler-plugin/testCompile/default-testCompile/createdFiles.lst:
--------------------------------------------------------------------------------
1 | com\sbm\artemis\demo\SpringBootArtemisConsumerApplicationTests.class
2 |
--------------------------------------------------------------------------------
/consumer/target/maven-status/maven-compiler-plugin/testCompile/default-testCompile/inputFiles.lst:
--------------------------------------------------------------------------------
1 | C:\java-dev\activemq-artemis\spring-boot-artemis-demo\consumer\src\test\java\com\sbm\artemis\demo\SpringBootArtemisConsumerApplicationTests.java
2 |
--------------------------------------------------------------------------------
/pom.xml:
--------------------------------------------------------------------------------
1 |
2 |
4 | 4.0.0
5 |
6 | pom
7 |
8 |
9 | UTF-8
10 | 1.8
11 |
12 |
13 |
14 | producer
15 | consumer
16 |
17 |
18 |
19 | org.springframework.boot
20 | spring-boot-starter-parent
21 | 1.5.2.RELEASE
22 |
23 |
24 | com.sbm.artemis.demo
25 | spring-boot-artemis-demo-multi-module
26 | 0.1.0
27 |
28 |
29 |
30 | org.projectlombok
31 | lombok
32 | 1.16.18
33 |
34 |
35 |
36 |
37 |
38 | melhosni
39 | Mohamed ELHOSNI
40 | medhosni@gmail.com
41 | https://github.com/hosnimed
42 | SBM
43 | https://www.scheidt-bachmann-maghreb.com/en/
44 |
45 | developer
46 |
47 |
48 |
49 | A demo App for showing Consul between backednd and front microservices
50 |
51 |
52 |
53 |
54 |
55 |
56 |
--------------------------------------------------------------------------------
/producer/.classpath:
--------------------------------------------------------------------------------
1 |
2 |
3 |
4 |
5 |
6 |
7 |
8 |
9 |
10 |
11 |
12 |
13 |
14 |
15 |
16 |
17 |
18 |
19 |
20 |
21 |
22 |
23 |
24 |
25 |
26 |
27 |
28 |
29 |
30 |
31 |
32 |
--------------------------------------------------------------------------------
/producer/.project:
--------------------------------------------------------------------------------
1 |
2 |
3 | artemis-producer
4 |
5 |
6 |
7 |
8 |
9 | org.eclipse.jdt.core.javabuilder
10 |
11 |
12 |
13 |
14 | org.eclipse.m2e.core.maven2Builder
15 |
16 |
17 |
18 |
19 |
20 | org.eclipse.jdt.core.javanature
21 | org.eclipse.m2e.core.maven2Nature
22 |
23 |
24 |
--------------------------------------------------------------------------------
/producer/.settings/org.eclipse.core.resources.prefs:
--------------------------------------------------------------------------------
1 | eclipse.preferences.version=1
2 | encoding//src/main/java=UTF-8
3 | encoding//src/main/resources=UTF-8
4 | encoding//src/test/java=UTF-8
5 | encoding/=UTF-8
6 |
--------------------------------------------------------------------------------
/producer/.settings/org.eclipse.jdt.core.prefs:
--------------------------------------------------------------------------------
1 | eclipse.preferences.version=1
2 | org.eclipse.jdt.core.compiler.codegen.targetPlatform=1.8
3 | org.eclipse.jdt.core.compiler.compliance=1.8
4 | org.eclipse.jdt.core.compiler.problem.forbiddenReference=warning
5 | org.eclipse.jdt.core.compiler.source=1.8
6 |
--------------------------------------------------------------------------------
/producer/.settings/org.eclipse.m2e.core.prefs:
--------------------------------------------------------------------------------
1 | activeProfiles=
2 | eclipse.preferences.version=1
3 | resolveWorkspaceProjects=true
4 | version=1
5 |
--------------------------------------------------------------------------------
/producer/artemis-producer.iml:
--------------------------------------------------------------------------------
1 |
2 |
3 |
4 |
5 |
6 |
7 |
8 |
9 |
10 |
11 |
12 |
13 |
14 |
15 |
16 |
17 |
18 |
19 |
20 |
21 |
22 |
23 |
24 |
25 |
26 |
27 |
28 |
29 |
30 |
31 |
32 |
33 |
34 |
35 |
36 |
37 |
38 |
39 |
40 |
41 |
42 |
43 |
44 |
45 |
46 |
47 |
48 |
49 |
50 |
51 |
52 |
53 |
54 |
55 |
56 |
57 |
58 |
59 |
60 |
61 |
62 |
63 |
64 |
65 |
66 |
67 |
68 |
69 |
70 |
71 |
72 |
73 |
74 |
75 |
76 |
77 |
78 |
79 |
80 |
81 |
82 |
83 |
84 |
85 |
86 |
87 |
88 |
89 |
90 |
91 |
92 |
--------------------------------------------------------------------------------
/producer/pom.xml:
--------------------------------------------------------------------------------
1 |
2 |
4 | 4.0.0
5 |
6 | artemis-producer
7 | jar
8 |
9 | producer
10 | SpringBootArtemisProducer
11 |
12 |
13 | com.sbm.artemis.demo
14 | spring-boot-artemis-demo-multi-module
15 | 0.1.0
16 |
17 |
18 |
19 | UTF-8
20 | UTF-8
21 | 1.8
22 |
23 |
24 |
25 |
26 | org.springframework.boot
27 | spring-boot-starter
28 |
29 |
30 | org.springframework.boot
31 | spring-boot-starter-artemis
32 |
33 |
34 |
35 | org.springframework.boot
36 | spring-boot-starter-web
37 |
38 |
39 |
40 | org.springframework.boot
41 | spring-boot-starter-test
42 | test
43 |
44 |
45 |
46 |
47 |
48 |
49 | org.springframework.boot
50 | spring-boot-maven-plugin
51 |
52 |
53 |
54 |
55 |
56 |
57 |
--------------------------------------------------------------------------------
/producer/src/main/java/com/sbm/artemis/demo/SpringBootArtemisProducerApplication.java:
--------------------------------------------------------------------------------
1 | package com.sbm.artemis.demo;
2 |
3 | import com.fasterxml.jackson.databind.ObjectMapper;
4 | import org.springframework.boot.SpringApplication;
5 | import org.springframework.boot.autoconfigure.SpringBootApplication;
6 | import org.springframework.boot.autoconfigure.jms.DefaultJmsListenerContainerFactoryConfigurer;
7 | import org.springframework.context.annotation.Bean;
8 | import org.springframework.jms.annotation.EnableJms;
9 | import org.springframework.jms.config.DefaultJmsListenerContainerFactory;
10 | import org.springframework.jms.config.JmsListenerContainerFactory;
11 | import org.springframework.jms.support.converter.MessageType;
12 | import org.springframework.messaging.converter.MappingJackson2MessageConverter;
13 | import org.springframework.messaging.converter.MessageConverter;
14 |
15 | import javax.jms.ConnectionFactory;
16 |
17 | @SpringBootApplication
18 | public class SpringBootArtemisProducerApplication {
19 |
20 |
21 | public static void main(String[] args) {
22 | SpringApplication.run(SpringBootArtemisProducerApplication.class, args);
23 | }
24 |
25 |
26 | }
27 |
--------------------------------------------------------------------------------
/producer/src/main/java/com/sbm/artemis/demo/controller/RestApiController.java:
--------------------------------------------------------------------------------
1 | package com.sbm.artemis.demo.controller;
2 |
3 | import com.sbm.artemis.demo.jms.Person;
4 | import org.springframework.beans.factory.annotation.Autowired;
5 | import org.springframework.web.bind.annotation.*;
6 |
7 | import com.sbm.artemis.demo.jms.ArtemisProducer;
8 |
9 | import java.lang.invoke.MethodType;
10 |
11 | @RestController
12 | public class RestApiController {
13 |
14 | @Autowired
15 | ArtemisProducer producer;
16 |
17 | @RequestMapping(value="/produce")
18 | public String produce(@RequestParam("msg")String msg){
19 | producer.send(msg);
20 | return "Done";
21 | }
22 | @RequestMapping(value="/produce",method = RequestMethod.POST)
23 | public String produce(@RequestBody Person p){
24 | producer.send(p);
25 | return "Send Person Done" + p.toString();
26 | }
27 | }
--------------------------------------------------------------------------------
/producer/src/main/java/com/sbm/artemis/demo/jms/ArtemisProducer.java:
--------------------------------------------------------------------------------
1 | package com.sbm.artemis.demo.jms;
2 |
3 | import org.springframework.beans.factory.annotation.Autowired;
4 | import org.springframework.beans.factory.annotation.Value;
5 | import org.springframework.jms.annotation.EnableJms;
6 | import org.springframework.jms.core.JmsTemplate;
7 | import org.springframework.stereotype.Component;
8 |
9 | @Component
10 | @EnableJms
11 | public class ArtemisProducer {
12 | @Autowired
13 | JmsTemplate jmsTemplate;
14 |
15 | @Value("${jms.queue.destination}")
16 | String destinationQueue;
17 |
18 | public void send(String msg){
19 | jmsTemplate.convertAndSend(destinationQueue, msg);
20 | }
21 | public void send(Person p){
22 | jmsTemplate.convertAndSend(destinationQueue, p);
23 | }
24 |
25 |
26 | }
--------------------------------------------------------------------------------
/producer/src/main/java/com/sbm/artemis/demo/jms/MessagingConfiguration.java:
--------------------------------------------------------------------------------
1 | /*
2 | package com.sbm.artemis.demo.jms;
3 |
4 | import org.apache.activemq.artemis.jms.client.ActiveMQConnectionFactory;
5 | import org.springframework.beans.factory.annotation.Autowired;
6 | import org.springframework.context.annotation.Bean;
7 | import org.springframework.context.annotation.Configuration;
8 | import org.springframework.jms.connection.CachingConnectionFactory;
9 | import org.springframework.jms.core.JmsTemplate;
10 | import org.springframework.jms.listener.DefaultMessageListenerContainer;
11 | import org.springframework.jms.listener.MessageListenerContainer;
12 | import org.springframework.messaging.converter.MessageConverter;
13 | import org.springframework.messaging.converter.SimpleMessageConverter;
14 |
15 | import javax.jms.ConnectionFactory;
16 | import javax.jms.JMSConnectionFactory;
17 |
18 | @Configuration
19 | public class MessagingConfiguration {
20 |
21 | @Bean
22 | public ConnectionFactory connectionFactory(){
23 | ActiveMQConnectionFactory connectionFactory = new ActiveMQConnectionFactory();
24 | return connectionFactory;
25 | }
26 |
27 | */
28 | /*
29 | * Optionally you can use cached connection factory if performance is a big concern.
30 | *//*
31 |
32 | @Bean
33 | public ConnectionFactory cachingConnectionFactory(){
34 | CachingConnectionFactory connectionFactory = new CachingConnectionFactory();
35 | connectionFactory.setTargetConnectionFactory(connectionFactory());
36 | connectionFactory.setSessionCacheSize(10);
37 | return connectionFactory;
38 | }
39 |
40 | */
41 | /*
42 | * Message listener container, used for invoking messageReceiver.onMessage on message reception.
43 | *//*
44 |
45 | @Bean
46 | public MessageListenerContainer getContainer(){
47 | DefaultMessageListenerContainer container = new DefaultMessageListenerContainer();
48 | container.setConnectionFactory(connectionFactory());
49 | return container;
50 | }
51 |
52 | */
53 | /*
54 | * Used for Sending Messages.
55 | *//*
56 |
57 | @Bean
58 | public JmsTemplate jmsTemplate(){
59 | JmsTemplate template = new JmsTemplate();
60 | template.setConnectionFactory(connectionFactory());
61 | return template;
62 | }
63 |
64 |
65 | @Bean
66 | MessageConverter converter(){
67 | return new SimpleMessageConverter();
68 | }
69 |
70 | }*/
71 |
--------------------------------------------------------------------------------
/producer/src/main/java/com/sbm/artemis/demo/jms/Person.java:
--------------------------------------------------------------------------------
1 | package com.sbm.artemis.demo.jms;
2 |
3 | import lombok.AllArgsConstructor;
4 | import lombok.Data;
5 | import lombok.NoArgsConstructor;
6 |
7 | import java.io.Serializable;
8 |
9 | @Data
10 | @AllArgsConstructor
11 | @NoArgsConstructor
12 | public class Person implements Serializable{
13 | private static final long serialVersionUID = 1L;
14 |
15 | private String id;
16 | private String name;
17 |
18 |
19 | }
20 |
--------------------------------------------------------------------------------
/producer/src/main/resources/application.properties:
--------------------------------------------------------------------------------
1 | spring.artemis.mode=native
2 | spring.artemis.host=localhost
3 | spring.artemis.port=61616
4 | spring.artemis.user=user
5 | spring.artemis.password=password
6 | jms.queue.destination=demoQueue
--------------------------------------------------------------------------------
/producer/src/test/java/com/sbm/artemis/demo/SpringBootArtemisProducerApplicationTests.java:
--------------------------------------------------------------------------------
1 | package com.sbm.artemis.demo;
2 |
3 | import org.junit.Test;
4 | import org.junit.runner.RunWith;
5 | import org.springframework.boot.test.context.SpringBootTest;
6 | import org.springframework.test.context.junit4.SpringRunner;
7 |
8 | @RunWith(SpringRunner.class)
9 | @SpringBootTest
10 | public class SpringBootArtemisProducerApplicationTests {
11 |
12 | @Test
13 | public void contextLoads() {
14 | }
15 |
16 | }
17 |
--------------------------------------------------------------------------------
/producer/target/artemis-producer-0.1.0.jar.original:
--------------------------------------------------------------------------------
https://raw.githubusercontent.com/hosnimed/spring-boot-artemis-demo/ad715b453125fd8750b00100f62e48a04ffa9d4b/producer/target/artemis-producer-0.1.0.jar.original
--------------------------------------------------------------------------------
/producer/target/classes/application.properties:
--------------------------------------------------------------------------------
1 | spring.artemis.mode=native
2 | spring.artemis.host=localhost
3 | spring.artemis.port=61616
4 | spring.artemis.user=user
5 | spring.artemis.password=password
6 | jms.queue.destination=demoQueue
--------------------------------------------------------------------------------
/producer/target/maven-archiver/pom.properties:
--------------------------------------------------------------------------------
1 | #Generated by Apache Maven
2 | #Mon Dec 04 16:20:05 WAT 2017
3 | version=0.1.0
4 | groupId=com.sbm.artemis.demo
5 | artifactId=artemis-producer
6 |
--------------------------------------------------------------------------------
/producer/target/maven-status/maven-compiler-plugin/compile/default-compile/createdFiles.lst:
--------------------------------------------------------------------------------
1 | com\sbm\artemis\demo\SpringBootArtemisProducerApplication.class
2 | com\sbm\artemis\demo\controller\RestApiController.class
3 | com\sbm\artemis\demo\jms\ArtemisProducer.class
4 | com\sbm\artemis\demo\jms\Person.class
5 |
--------------------------------------------------------------------------------
/producer/target/maven-status/maven-compiler-plugin/compile/default-compile/inputFiles.lst:
--------------------------------------------------------------------------------
1 | C:\java-dev\activemq-artemis\spring-boot-artemis-demo\producer\src\main\java\com\sbm\artemis\demo\jms\Person.java
2 | C:\java-dev\activemq-artemis\spring-boot-artemis-demo\producer\src\main\java\com\sbm\artemis\demo\jms\ArtemisProducer.java
3 | C:\java-dev\activemq-artemis\spring-boot-artemis-demo\producer\src\main\java\com\sbm\artemis\demo\controller\RestApiController.java
4 | C:\java-dev\activemq-artemis\spring-boot-artemis-demo\producer\src\main\java\com\sbm\artemis\demo\SpringBootArtemisProducerApplication.java
5 | C:\java-dev\activemq-artemis\spring-boot-artemis-demo\producer\src\main\java\com\sbm\artemis\demo\jms\MessagingConfiguration.java
6 |
--------------------------------------------------------------------------------
/producer/target/maven-status/maven-compiler-plugin/testCompile/default-testCompile/createdFiles.lst:
--------------------------------------------------------------------------------
1 | com\sbm\artemis\demo\SpringBootArtemisProducerApplicationTests.class
2 |
--------------------------------------------------------------------------------
/producer/target/maven-status/maven-compiler-plugin/testCompile/default-testCompile/inputFiles.lst:
--------------------------------------------------------------------------------
1 | C:\java-dev\activemq-artemis\spring-boot-artemis-demo\producer\src\test\java\com\sbm\artemis\demo\SpringBootArtemisProducerApplicationTests.java
2 |
--------------------------------------------------------------------------------
/spring-boot-artemis-demo-multi-module.iml:
--------------------------------------------------------------------------------
1 |
2 |
3 |
4 |
5 |
6 |
7 |
8 |
9 |
10 |
11 |
12 |
13 |
--------------------------------------------------------------------------------
/springboot-artemis-architecture.png:
--------------------------------------------------------------------------------
https://raw.githubusercontent.com/hosnimed/spring-boot-artemis-demo/ad715b453125fd8750b00100f62e48a04ffa9d4b/springboot-artemis-architecture.png
--------------------------------------------------------------------------------