Skip to content
Projects
Groups
Snippets
Help
Loading...
Help
Submit feedback
Sign in / Register
Toggle navigation
S
spring-boot
Project
Project
Details
Activity
Releases
Cycle Analytics
Repository
Repository
Files
Commits
Branches
Tags
Contributors
Graph
Compare
Charts
Issues
0
Issues
0
List
Board
Labels
Milestones
Merge Requests
0
Merge Requests
0
CI / CD
CI / CD
Pipelines
Jobs
Schedules
Charts
Wiki
Wiki
Snippets
Snippets
Members
Members
Collapse sidebar
Close sidebar
Activity
Graph
Charts
Create a new issue
Jobs
Commits
Issue Boards
Open sidebar
DEMO
spring-boot
Commits
629ec3d1
Commit
629ec3d1
authored
Mar 17, 2015
by
Stephane Nicoll
Browse files
Options
Browse Files
Download
Plain Diff
Merge pull request #2527 from eddumelendez/gh-2375
* gh-2375: add spring-boot-sample-activemq
parents
d266639c
3bd1ec68
Changes
7
Hide whitespace changes
Inline
Side-by-side
Showing
7 changed files
with
212 additions
and
0 deletions
+212
-0
pom.xml
spring-boot-samples/pom.xml
+1
-0
pom.xml
spring-boot-samples/spring-boot-sample-activemq/pom.xml
+46
-0
Consumer.java
...mple-activemq/src/main/java/sample/activemq/Consumer.java
+30
-0
Producer.java
...mple-activemq/src/main/java/sample/activemq/Producer.java
+45
-0
SampleActiveMQApplication.java
.../main/java/sample/activemq/SampleActiveMQApplication.java
+40
-0
application.properties
...sample-activemq/src/main/resources/application.properties
+2
-0
SampleActiveMqTests.java
...mq/src/test/java/sample/activemq/SampleActiveMqTests.java
+48
-0
No files found.
spring-boot-samples/pom.xml
View file @
629ec3d1
...
@@ -20,6 +20,7 @@
...
@@ -20,6 +20,7 @@
<main.basedir>
${basedir}/..
</main.basedir>
<main.basedir>
${basedir}/..
</main.basedir>
</properties>
</properties>
<modules>
<modules>
<module>
spring-boot-sample-activemq
</module>
<module>
spring-boot-sample-actuator
</module>
<module>
spring-boot-sample-actuator
</module>
<module>
spring-boot-sample-actuator-log4j
</module>
<module>
spring-boot-sample-actuator-log4j
</module>
<module>
spring-boot-sample-actuator-log4j2
</module>
<module>
spring-boot-sample-actuator-log4j2
</module>
...
...
spring-boot-samples/spring-boot-sample-activemq/pom.xml
0 → 100644
View file @
629ec3d1
<?xml version="1.0" encoding="UTF-8"?>
<project
xmlns=
"http://maven.apache.org/POM/4.0.0"
xmlns:xsi=
"http://www.w3.org/2001/XMLSchema-instance"
xsi:schemaLocation=
"http://maven.apache.org/POM/4.0.0 http://maven.apache.org/xsd/maven-4.0.0.xsd"
>
<parent>
<artifactId>
spring-boot-samples
</artifactId>
<groupId>
org.springframework.boot
</groupId>
<version>
1.3.0.BUILD-SNAPSHOT
</version>
</parent>
<modelVersion>
4.0.0
</modelVersion>
<artifactId>
spring-boot-sample-activemq
</artifactId>
<name>
Spring Boot ActiveMQ Sample
</name>
<description>
Spring Boot ActiveMQ Sample
</description>
<url>
http://projects.spring.io/spring-boot/
</url>
<dependencies>
<dependency>
<groupId>
org.springframework.boot
</groupId>
<artifactId>
spring-boot-starter
</artifactId>
</dependency>
<dependency>
<groupId>
org.springframework
</groupId>
<artifactId>
spring-jms
</artifactId>
</dependency>
<dependency>
<groupId>
org.apache.activemq
</groupId>
<artifactId>
activemq-broker
</artifactId>
</dependency>
<dependency>
<groupId>
org.springframework.boot
</groupId>
<artifactId>
spring-boot-starter-test
</artifactId>
<scope>
test
</scope>
</dependency>
</dependencies>
<build>
<plugins>
<plugin>
<groupId>
org.springframework.boot
</groupId>
<artifactId>
spring-boot-maven-plugin
</artifactId>
</plugin>
</plugins>
</build>
</project>
spring-boot-samples/spring-boot-sample-activemq/src/main/java/sample/activemq/Consumer.java
0 → 100644
View file @
629ec3d1
/*
* Copyright 2012-2015 the original author or authors.
*
* Licensed under the Apache License, Version 2.0 (the "License");
* you may not use this file except in compliance with the License.
* You may obtain a copy of the License at
*
* http://www.apache.org/licenses/LICENSE-2.0
*
* Unless required by applicable law or agreed to in writing, software
* distributed under the License is distributed on an "AS IS" BASIS,
* WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied.
* See the License for the specific language governing permissions and
* limitations under the License.
*/
package
sample
.
activemq
;
import
org.springframework.jms.annotation.JmsListener
;
import
org.springframework.stereotype.Component
;
@Component
public
class
Consumer
{
@JmsListener
(
destination
=
"sample.queue"
)
public
void
receiveQueue
(
String
text
)
{
System
.
out
.
println
(
text
);
}
}
spring-boot-samples/spring-boot-sample-activemq/src/main/java/sample/activemq/Producer.java
0 → 100644
View file @
629ec3d1
/*
* Copyright 2012-2015 the original author or authors.
*
* Licensed under the Apache License, Version 2.0 (the "License");
* you may not use this file except in compliance with the License.
* You may obtain a copy of the License at
*
* http://www.apache.org/licenses/LICENSE-2.0
*
* Unless required by applicable law or agreed to in writing, software
* distributed under the License is distributed on an "AS IS" BASIS,
* WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied.
* See the License for the specific language governing permissions and
* limitations under the License.
*/
package
sample
.
activemq
;
import
javax.jms.Queue
;
import
org.springframework.beans.factory.annotation.Autowired
;
import
org.springframework.boot.CommandLineRunner
;
import
org.springframework.jms.core.JmsMessagingTemplate
;
import
org.springframework.stereotype.Component
;
@Component
public
class
Producer
implements
CommandLineRunner
{
@Autowired
private
JmsMessagingTemplate
jmsMessagingTemplate
;
@Autowired
private
Queue
queue
;
@Override
public
void
run
(
String
...
args
)
throws
Exception
{
send
(
"Sample message"
);
System
.
out
.
println
(
"Message was sent to the Queue"
);
}
public
void
send
(
String
msg
)
{
jmsMessagingTemplate
.
convertAndSend
(
queue
,
msg
);
}
}
spring-boot-samples/spring-boot-sample-activemq/src/main/java/sample/activemq/SampleActiveMQApplication.java
0 → 100644
View file @
629ec3d1
/*
* Copyright 2012-2015 the original author or authors.
*
* Licensed under the Apache License, Version 2.0 (the "License");
* you may not use this file except in compliance with the License.
* You may obtain a copy of the License at
*
* http://www.apache.org/licenses/LICENSE-2.0
*
* Unless required by applicable law or agreed to in writing, software
* distributed under the License is distributed on an "AS IS" BASIS,
* WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied.
* See the License for the specific language governing permissions and
* limitations under the License.
*/
package
sample
.
activemq
;
import
org.apache.activemq.command.ActiveMQQueue
;
import
org.springframework.boot.SpringApplication
;
import
org.springframework.boot.autoconfigure.SpringBootApplication
;
import
org.springframework.context.annotation.Bean
;
import
org.springframework.jms.annotation.EnableJms
;
import
javax.jms.Queue
;
@SpringBootApplication
@EnableJms
public
class
SampleActiveMQApplication
{
@Bean
public
Queue
queue
()
{
return
new
ActiveMQQueue
(
"sample.queue"
);
}
public
static
void
main
(
String
[]
args
)
{
SpringApplication
.
run
(
SampleActiveMQApplication
.
class
,
args
);
}
}
spring-boot-samples/spring-boot-sample-activemq/src/main/resources/application.properties
0 → 100644
View file @
629ec3d1
spring.activemq.in-memory
=
true
spring.activemq.pooled
=
false
\ No newline at end of file
spring-boot-samples/spring-boot-sample-activemq/src/test/java/sample/activemq/SampleActiveMqTests.java
0 → 100644
View file @
629ec3d1
/*
* Copyright 2012-2015 the original author or authors.
*
* Licensed under the Apache License, Version 2.0 (the "License");
* you may not use this file except in compliance with the License.
* You may obtain a copy of the License at
*
* http://www.apache.org/licenses/LICENSE-2.0
*
* Unless required by applicable law or agreed to in writing, software
* distributed under the License is distributed on an "AS IS" BASIS,
* WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied.
* See the License for the specific language governing permissions and
* limitations under the License.
*/
package
sample
.
activemq
;
import
org.junit.Rule
;
import
org.junit.Test
;
import
org.junit.runner.RunWith
;
import
org.springframework.beans.factory.annotation.Autowired
;
import
org.springframework.boot.test.OutputCapture
;
import
org.springframework.boot.test.SpringApplicationConfiguration
;
import
org.springframework.test.context.junit4.SpringJUnit4ClassRunner
;
import
javax.jms.JMSException
;
import
static
org
.
junit
.
Assert
.
assertTrue
;
@RunWith
(
SpringJUnit4ClassRunner
.
class
)
@SpringApplicationConfiguration
(
classes
=
{
SampleActiveMQApplication
.
class
})
public
class
SampleActiveMqTests
{
@Rule
public
OutputCapture
outputCapture
=
new
OutputCapture
();
@Autowired
private
Producer
producer
;
@Test
public
void
sendSimpleMessage
()
throws
InterruptedException
,
JMSException
{
producer
.
send
(
"Test message"
);
Thread
.
sleep
(
1000L
);
assertTrue
(
outputCapture
.
toString
().
contains
(
"Test message"
));
}
}
Write
Preview
Markdown
is supported
0%
Try again
or
attach a new file
Attach a file
Cancel
You are about to add
0
people
to the discussion. Proceed with caution.
Finish editing this message first!
Cancel
Please
register
or
sign in
to comment