【问题标题】:How to Store Message ActiveMQ into SQL Server如何将消息 ActiveMQ 存储到 SQL Server
【发布时间】:2021-11-29 14:57:29
【问题描述】:

我根据网上的例子做了将消息存储在SQL Server中的配置。

在执行 ActiveMQ 时会创建表,但是当我通过 localhost:8161/admin/queues.jsp 创建和发送消息时,不会将记录插入到数据库表 ACTIVEMQ_MSGS

我测试了可能的更改,并在互联网上看到了一些东西。我在配置文件中应用了它们,但是没有用。

<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.xsd
  http://activemq.apache.org/schema/core http://activemq.apache.org/schema/core/activemq-core.xsd">

    <bean class="org.springframework.beans.factory.config.PropertyPlaceholderConfigurer">
        <property name="locations">
            <value>file:${activemq.conf}/credentials.properties</value>
        </property>
    </bean>
    <!-- Allows accessing the server log -->
    <bean id="logQuery" class="io.fabric8.insight.log.log4j.Log4jLogQuery" lazy-init="false" scope="singleton" init-method="start" destroy-method="stop" />
    <bean id="mssql-ds" class="org.apache.commons.dbcp2.BasicDataSource" destroy-method="close">
        <property name="driverClassName" value="com.microsoft.sqlserver.jdbc.SQLServerDriver" />
        <property name="url" value="jdbc:sqlserver://localhost:1433;DatabaseName=activedb" />
        <property name="username" value="username" />
        <property name="password" value="password" />
        <property name="poolPreparedStatements" value="true" />
    </bean>
    <broker xmlns="http://activemq.apache.org/schema/core" brokerName="localhost">
        <destinationPolicy>
            <policyMap>
                <policyEntries>
                    <policyEntry topic="&gt;" producerFlowControl="true">
                        <pendingMessageLimitStrategy>
                            <constantPendingMessageLimitStrategy limit="1000" />
                        </pendingMessageLimitStrategy>
                    </policyEntry>
                    <policyEntry queue="&gt;" producerFlowControl="true" memoryLimit="1mb" />
                </policyEntries>
            </policyMap>
        </destinationPolicy>
        <managementContext>
            <managementContext createConnector="false" />
        </managementContext>
        <persistenceAdapter>
            <jdbcPersistenceAdapter dataDirectory="${activemq.data}" dataSource="#mssql-ds" lockKeepAlivePeriod="0">
                <adapter>
                    <transact-jdbc-adapter />
                </adapter>
                <locker>
                    <lease-database-locker lockAcquireSleepInterval="10000" dataSource="#mssql-ds">
                        <statements>
                            <statements lockTableName="activemq_lock" />
                        </statements>
                    </lease-database-locker>
                </locker>
            </jdbcPersistenceAdapter>
        </persistenceAdapter>
        <systemUsage>
            <systemUsage>
                <memoryUsage>
                    <memoryUsage limit="64 mb" />
                </memoryUsage>
                <storeUsage>
                    <storeUsage limit="100 gb" />
                </storeUsage>
                <tempUsage>
                    <tempUsage limit="50 gb" />
                </tempUsage>
            </systemUsage>
        </systemUsage>
        <transportConnectors>
            <transportConnector name="openwire" uri="tcp://0.0.0.0:0?maximumConnections=1000" />
        </transportConnectors>
        <shutdownHooks>
            <bean xmlns="http://www.springframework.org/schema/beans" class="org.apache.activemq.hooks.SpringContextHook" />
        </shutdownHooks>
    </broker>
    <import resource="jetty.xml" />
</beans>

【问题讨论】:

  • 我从localhost:8161/admin/queues.jsp 创建一个队列,然后通过@JustinBertram 表单发送消息
  • 我的意思是通过localhost:8161/admin/queues.jsp创建和发送消息
  • ACTIVEMQ_ACKS - ACTIVEMQ_LOCK - ACTIVEMQ_MSGS @JustinBertram
  • 我没有选择Persistent Delivery检查,所以没有存入数据库
  • 感谢您的帮助 打扰一下,我还有一个问题,如何将消息保存在自定义表格中? @贾斯汀伯特伦

标签: sql-server activemq


【解决方案1】:

确保在通过 Web 控制台发送消息时选中“持久传递”复选框。

【讨论】:

    猜你喜欢
    • 2014-09-24
    • 2017-08-03
    • 1970-01-01
    • 1970-01-01
    • 1970-01-01
    • 2016-05-07
    • 1970-01-01
    • 2017-07-21
    • 1970-01-01
    相关资源
    最近更新 更多