2014-12-11 07:17:29 -05:00
|
|
|
# Spring Integration
|
2014-12-04 10:25:29 -05:00
|
|
|
|
2015-04-27 17:32:30 -04:00
|
|
|
Apache ActiveMQ Artemis provides a simple bootstrap class,
|
2014-12-04 10:25:29 -05:00
|
|
|
`org.apache.activemq.integration.spring.SpringJmsBootstrap`, for
|
2015-04-27 17:32:30 -04:00
|
|
|
integration with Spring. To use it, you configure Apache ActiveMQ Artemis as you always
|
2014-12-04 10:25:29 -05:00
|
|
|
would, through its various configuration files like
|
2017-03-09 05:11:48 -05:00
|
|
|
`broker.xml`.
|
2014-12-04 10:25:29 -05:00
|
|
|
|
|
|
|
Here we've specified a `javax.jms.ConnectionFactory` we want bound to a
|
|
|
|
`ConnectionFactory` entry as well as a queue destination bound to a
|
|
|
|
`/queue/exampleQueue` entry. Using the `SpringJmsBootStrap` bean will
|
|
|
|
automatically populate the Spring context with references to those beans
|
|
|
|
so that you can use them. Below is an example Spring JMS bean file
|
|
|
|
taking advantage of this feature:
|
|
|
|
|
2018-03-08 15:46:38 -05:00
|
|
|
```xml
|
|
|
|
<beans xmlns="http://www.springframework.org/schema/beans"
|
|
|
|
xmlns:xsi="http://www.w3.org/2001/XMLSchema-instance"
|
|
|
|
xsi:schemaLocation="http://www.springframework.org/schema/beans
|
|
|
|
http://www.springframework.org/schema/beans/spring-beans-3.0.xsd">
|
2014-12-04 10:25:29 -05:00
|
|
|
|
2018-03-08 15:46:38 -05:00
|
|
|
<bean id="EmbeddedJms" class="org.apache.activemq.integration.spring.SpringJmsBootstrap" init-method="start"/>
|
2014-12-04 10:25:29 -05:00
|
|
|
|
2018-03-08 15:46:38 -05:00
|
|
|
<bean id="listener" class="org.apache.activemq.tests.integration.spring.ExampleListener"/>
|
2015-02-25 08:37:19 -05:00
|
|
|
|
2018-03-08 15:46:38 -05:00
|
|
|
<bean id="listenerContainer" class="org.springframework.jms.listener.DefaultMessageListenerContainer">
|
|
|
|
<property name="connectionFactory" ref="ConnectionFactory"/>
|
|
|
|
<property name="destination" ref="/queue/exampleQueue"/>
|
|
|
|
<property name="messageListener" ref="listener"/>
|
|
|
|
</bean>
|
|
|
|
</beans>
|
|
|
|
```
|
2014-12-04 10:25:29 -05:00
|
|
|
|
|
|
|
As you can see, the `listenerContainer` bean references the components
|
|
|
|
defined in the `activemq-jms.xml` file. The `SpringJmsBootstrap` class
|
2014-12-11 07:17:29 -05:00
|
|
|
extends the EmbeddedJMS class talked about in [JMS API](embedding-activemq.md) and the same defaults
|
2014-12-04 10:25:29 -05:00
|
|
|
and configuration options apply. Also notice that an `init-method` must
|
|
|
|
be declared with a start value so that the bean's lifecycle is executed.
|
|
|
|
See the javadocs for more details on other properties of the bean class.
|