home | career | drupal | java | mac | mysql | perl | scala | uml | unix  

ActiveMQ example source code file (spring-embedded.xml)

This example ActiveMQ source code file (spring-embedded.xml) is included in the DevDaily.com "Java Source Code Warehouse" project. The intent of this project is to help you "Learn Java by Example" TM.

Java - ActiveMQ tags/keywords

apache, asf, asf, jms, license, license, pojo, see, see, snippet, spring, start, you, you

The ActiveMQ spring-embedded.xml source code

<?xml version="1.0" encoding="UTF-8"?>
    Licensed to the Apache Software Foundation (ASF) under one or more
    contributor license agreements.  See the NOTICE file distributed with
    this work for additional information regarding copyright ownership.
    The ASF licenses this file to You 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
    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.

<!-- START SNIPPET: spring -->
<!DOCTYPE beans PUBLIC "-//SPRING//DTD BEAN//EN" "http://www.springframework.org/dtd/spring-beans.dtd">


    <bean id="brokerContainer" class="org.apache.activemq.xbean.BrokerFactoryBean">
      <property name="config" value="classpath:activemq.xml"/>

    <!-- JMS ConnectionFactory to use, configuring the embedded broker using XML -->
    <bean id="jmsFactory" class="org.apache.activemq.ActiveMQConnectionFactory">
        <property name="brokerURL" value="vm://localhost" />

    <!-- Spring JMS Template -->
    <bean id="myJmsTemplate" class="org.springframework.jms.core.JmsTemplate">
        <property name="connectionFactory">
            <!-- lets wrap in a pool to avoid creating a connection per send -->
            <bean class="org.springframework.jms.connection.SingleConnectionFactory">
                <property name="targetConnectionFactory">
                    <ref local="jmsFactory"/>
    <bean id="consumerJmsTemplate" class="org.springframework.jms.core.JmsTemplate">
        <property name="connectionFactory" ref="jmsFactory"/>

    <!-- a sample POJO which uses a Spring JmsTemplate -->
    <bean id="producer" class="org.apache.activemq.spring.SpringProducer">
        <property name="template">
            <ref bean="myJmsTemplate">

        <property name="destination">
            <ref bean="destination"/>

        <property name="messageCount">

    <!-- a sample POJO consumer -->
    <bean id="consumer" class="org.apache.activemq.spring.SpringConsumer">
        <property name="template">
            <ref bean="consumerJmsTemplate">

        <property name="destination">
            <ref bean="destination"/>

    <bean id="destination" class="org.apache.activemq.command.ActiveMQQueue" autowire="constructor">

<!-- END SNIPPET: spring -->

Other ActiveMQ examples (source code examples)

Here is a short list of links related to this ActiveMQ spring-embedded.xml source code file:

new blog posts


Copyright 1998-2016 Alvin Alexander, alvinalexander.com
All Rights Reserved.

A percentage of advertising revenue from
pages under the /java/jwarehouse URI on this website is
paid back to open source projects.