- Introduction
- 1. Legal Notice
- 2. Preface
- 3. Project Info
- 4. Messaging Concepts
- 5. Architecture
- 6. Using the Server
- 7. Using JMS
- 8. Using Core
- 9. Mapping JMS Concepts to the Core API
- 10. The Client Classpath
- 11. Examples
- 12. Routing Messages With Wild Cards
- 13. Understanding the Apache ActiveMQ Artemis Wildcard Syntax
- 14. Filter Expressions
- 15. Persistence
- 16. Configuring Transports
- 17. Detecting Dead Connections
- 18. Detecting Slow Consumers
- 19. Resource Manager Configuration
- 20. Flow Control
- 21. Guarantees of sends and commits
- 22. Message Redelivery and Undelivered Messages
- 23. Message Expiry
- 24. Large Messages
- 25. Paging
- 26. Queue Attributes
- 27. Scheduled Messages
- 28. Last-Value Queues
- 29. Message Grouping
- 30. Extra Acknowledge Modes
- 31. Management
- 32. Security
- 33. Resource Limits
- 34. The JMS Bridge
- 35. Client Reconnection and Session Reattachment
- 36. Diverting and Splitting Message Flows
- 37. Core Bridges
- 38. Duplicate Message Detection
- 39. Clusters
- 40. High Availability and Failover
- 41. Graceful Server Shutdown
- 42. Libaio Native Libraries
- 43. Thread management
- 44. Logging
- 45. REST Interface
- 46. Embedding Apache ActiveMQ Artemis
- 47. Spring Integration
- 48. AeroGear Integration
- 49. VertX Integration
- 50. Intercepting Operations
- 51. Protocols and Interoperability
- 52. Tools
- 53. Maven Plugin
- 54. Troubleshooting and Performance Tuning
- 55. Configuration Reference
- Published with GitBook

# ActiveMQ Artemis Documentation

# Spring Integration

Apache ActiveMQ Artemis provides a simple bootstrap class, `org.apache.activemq.integration.spring.SpringJmsBootstrap`, for integration with Spring. To use it, you configure Apache ActiveMQ Artemis as you always would, through its various configuration files like `broker.xml`, `activemq-jms.xml`, and `activemq-users.xml`. The Spring helper class starts the Apache ActiveMQ Artemis server and adds any factories or destinations configured within `activemq-jms.xml` directly into the namespace of the Spring context. Let's take this `activemq-jms.xml` file for instance:

    <configuration xmlns="urn:activemq"
       xmlns:xsi="http://www.w3.org/2001/XMLSchema-instance"
       xsi:schemaLocation="urn:activemq /schema/artemis-jms.xsd">

       <!--the queue used by the example-->
       <queue name="exampleQueue"/>
    </configuration>

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:

    <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">

       <bean id="EmbeddedJms" class="org.apache.activemq.integration.spring.SpringJmsBootstrap" init-method="start"/>

       <bean id="listener" class="org.apache.activemq.tests.integration.spring.ExampleListener"/>

       <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>

As you can see, the `listenerContainer` bean references the components defined in the `activemq-jms.xml` file. The `SpringJmsBootstrap` class extends the EmbeddedJMS class talked about in JMS API and the same defaults 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.