title: How to Store Message ActiveMQ into SQL Server
body: <p>I did the configuration for storing the message in SQL Server according to the examples that were in the internet.</p>
  <p>Tables are created when ActiveMQ is executed, but when I create and send messages via localhost:8161/admin/queues.jsp a record is not inserted into the database table <code>ACTIVEMQ_MSGS</code>.</p>
  <p>I tested the changes that were possible, and I saw some things on the internet. I applied them in the config file, but it didn't work.</p>
  <pre class="lang-xml prettyprint-override"><code>&lt;beans
    xmlns=&quot;http://www.springframework.org/schema/beans&quot;
    xmlns:xsi=&quot;http://www.w3.org/2001/XMLSchema-instance&quot;
    xsi:schemaLocation=&quot;http://www.springframework.org/schema/beans http://www.springframework.org/schema/beans/spring-beans.xsd
    http://activemq.apache.org/schema/core http://activemq.apache.org/schema/core/activemq-core.xsd&quot;&gt;
  
      &lt;bean class=&quot;org.springframework.beans.factory.config.PropertyPlaceholderConfigurer&quot;&gt;
          &lt;property name=&quot;locations&quot;&gt;
              &lt;value&gt;file:${activemq.conf}/credentials.properties&lt;/value&gt;
          &lt;/property&gt;
      &lt;/bean&gt;
      &lt;!-- Allows accessing the server log --&gt;
      &lt;bean id=&quot;logQuery&quot; class=&quot;io.fabric8.insight.log.log4j.Log4jLogQuery&quot; lazy-init=&quot;false&quot; scope=&quot;singleton&quot; init-method=&quot;start&quot; destroy-method=&quot;stop&quot; /&gt;
      &lt;bean id=&quot;mssql-ds&quot; class=&quot;org.apache.commons.dbcp2.BasicDataSource&quot; destroy-method=&quot;close&quot;&gt;
          &lt;property name=&quot;driverClassName&quot; value=&quot;com.microsoft.sqlserver.jdbc.SQLServerDriver&quot; /&gt;
          &lt;property name=&quot;url&quot; value=&quot;jdbc:sqlserver://localhost:1433;DatabaseName=activedb&quot; /&gt;
          &lt;property name=&quot;username&quot; value=&quot;username&quot; /&gt;
          &lt;property name=&quot;password&quot; value=&quot;password&quot; /&gt;
          &lt;property name=&quot;poolPreparedStatements&quot; value=&quot;true&quot; /&gt;
      &lt;/bean&gt;
      &lt;broker xmlns=&quot;http://activemq.apache.org/schema/core&quot; brokerName=&quot;localhost&quot;&gt;
          &lt;destinationPolicy&gt;
              &lt;policyMap&gt;
                  &lt;policyEntries&gt;
                      &lt;policyEntry topic=&quot;&amp;gt;&quot; producerFlowControl=&quot;true&quot;&gt;
                          &lt;pendingMessageLimitStrategy&gt;
                              &lt;constantPendingMessageLimitStrategy limit=&quot;1000&quot; /&gt;
                          &lt;/pendingMessageLimitStrategy&gt;
                      &lt;/policyEntry&gt;
                      &lt;policyEntry queue=&quot;&amp;gt;&quot; producerFlowControl=&quot;true&quot; memoryLimit=&quot;1mb&quot; /&gt;
                  &lt;/policyEntries&gt;
              &lt;/policyMap&gt;
          &lt;/destinationPolicy&gt;
          &lt;managementContext&gt;
              &lt;managementContext createConnector=&quot;false&quot; /&gt;
          &lt;/managementContext&gt;
          &lt;persistenceAdapter&gt;
              &lt;jdbcPersistenceAdapter dataDirectory=&quot;${activemq.data}&quot; dataSource=&quot;#mssql-ds&quot; lockKeepAlivePeriod=&quot;0&quot;&gt;
                  &lt;adapter&gt;
                      &lt;transact-jdbc-adapter /&gt;
                  &lt;/adapter&gt;
                  &lt;locker&gt;
                      &lt;lease-database-locker lockAcquireSleepInterval=&quot;10000&quot; dataSource=&quot;#mssql-ds&quot;&gt;
                          &lt;statements&gt;
                              &lt;statements lockTableName=&quot;activemq_lock&quot; /&gt;
                          &lt;/statements&gt;
                      &lt;/lease-database-locker&gt;
                  &lt;/locker&gt;
              &lt;/jdbcPersistenceAdapter&gt;
          &lt;/persistenceAdapter&gt;
          &lt;systemUsage&gt;
              &lt;systemUsage&gt;
                  &lt;memoryUsage&gt;
                      &lt;memoryUsage limit=&quot;64 mb&quot; /&gt;
                  &lt;/memoryUsage&gt;
                  &lt;storeUsage&gt;
                      &lt;storeUsage limit=&quot;100 gb&quot; /&gt;
                  &lt;/storeUsage&gt;
                  &lt;tempUsage&gt;
                      &lt;tempUsage limit=&quot;50 gb&quot; /&gt;
                  &lt;/tempUsage&gt;
              &lt;/systemUsage&gt;
          &lt;/systemUsage&gt;
          &lt;transportConnectors&gt;
              &lt;transportConnector name=&quot;openwire&quot; uri=&quot;tcp://0.0.0.0:0?maximumConnections=1000&quot; /&gt;
          &lt;/transportConnectors&gt;
          &lt;shutdownHooks&gt;
              &lt;bean xmlns=&quot;http://www.springframework.org/schema/beans&quot; class=&quot;org.apache.activemq.hooks.SpringContextHook&quot; /&gt;
          &lt;/shutdownHooks&gt;
      &lt;/broker&gt;
      &lt;import resource=&quot;jetty.xml&quot; /&gt;
  &lt;/beans&gt;
  </code></pre>