Skip to content

Instantly share code, notes, and snippets.

@fieldju
Created November 8, 2012 18:36
Show Gist options
  • Save fieldju/4040646 to your computer and use it in GitHub Desktop.
Save fieldju/4040646 to your computer and use it in GitHub Desktop.
activemq bean definitions / configuration
<beans
xmlns="http://www.springframework.org/schema/beans"
xmlns:amq="http://activemq.apache.org/schema/core"
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-2.0.xsd
http://activemq.apache.org/schema/core http://activemq.apache.org/schema/core/activemq-core.xsd">
<bean id="broker" class="org.apache.activemq.broker.BrokerService" scope="prototype">
<property name="persistent" value="true"/>
<property name="useLocalHostBrokerName" value="true"/>
<property name="transportConnectors">
<list>
<ref bean="transportConnector"/>
</list>
</property>
<property name="ioExceptionHandler" ref="ioExceptionHandler"/>
<property name="persistenceAdapter" ref="persistenceAdapter"/>
<property name="destinationPolicy" ref="policyMap"/>
<!--<property name="plugins">-->
<!--<list>-->
<!--<bean id="brokerFilter" class="org.apache.activemq.broker.BrokerFilter"/>-->
<!--</list>-->
<!--</property>-->
</bean>
<bean id="policyMap" class="org.apache.activemq.broker.region.policy.PolicyMap">
<property name="defaultEntry">
<ref bean="policyEntry"/>
</property>
</bean>
<bean id="dlq" class="org.apache.activemq.broker.region.policy.IndividualDeadLetterStrategy">
<property name="processExpired" value="false"/>
<property name="processNonPersistent" value="false"/>
</bean>
<bean id="policyEntry" class="org.apache.activemq.broker.region.policy.PolicyEntry">
<property name="prioritizedMessages" value="true"/>
<property name="deadLetterStrategy" ref="dlq"/>
</bean>
<bean id="ioExceptionHandler" class="org.apache.activemq.store.jdbc.JDBCIOExceptionHandler">
<property name="ignoreSQLExceptions" value="true"/>
<property name="stopStartConnectors" value="true"/>
</bean>
<bean id="persistenceAdapter" class="org.apache.activemq.store.jdbc.JDBCPersistenceAdapter">
<property name="createTablesOnStartup" value="true"/>
<property name="dataSource" ref="mysql-ds"/>
<property name="lockKeepAlivePeriod" value="2000"/>
<property name="locker" ref="leaseDatabaseLocker"/>
<property name="useLock" value="true"/>
</bean>
<bean id="leaseDatabaseLocker" class="org.apache.activemq.store.jdbc.LeaseDatabaseLocker">
<property name="lockAcquireSleepInterval" value="1000"/>
</bean>
<bean id="mysql-ds" class="org.apache.commons.dbcp.BasicDataSource" destroy-method="close">
<property name="driverClassName" value="com.mysql.jdbc.Driver"/>
<property name="url" value="jdbc:mysql://@database.host@:@database.port@/foremandb_preview?relaxAutoCommit=true"/>
<property name="username" value="@database.username@"/>
<property name="password" value="@database.password@"/>
<property name="poolPreparedStatements" value="true"/>
</bean>
<bean id="transportConnector" class="org.apache.activemq.broker.TransportConnector" scope="prototype">
<property name="name" value="default"/>
<property name="uri" value="tcp://0.0.0.0:@activeMQ.broker.port@"/>
</bean>
<bean id="activemqURL" class="java.lang.String">
<constructor-arg value="failover://(tcp://localhost:@activeMQ.broker.port@,@activeMQ.brokerServers@)?randomize=false&amp;timeout=60000"/>
</bean>
<bean id="connectionFactory" class="org.apache.activemq.ActiveMQConnectionFactory">
<property name="brokerURL" ref="activemqURL"/>
<property name="redeliveryPolicy" ref="redeliveryPolicy"/>
</bean>
<bean id="redeliveryPolicy" class="org.apache.activemq.RedeliveryPolicy">
<property name="maximumRedeliveries" value="5"/>
<property name="redeliveryDelay" value="5000"/>
<property name="useExponentialBackOff" value="true"/>
<property name="initialRedeliveryDelay" value="0"/>
</bean>
<bean id="brokerFactory" class="cnwk.foreman.ingestion.BrokerFactory">
<lookup-method name="getBean" bean="broker"/>
</bean>
</beans>
Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment