简体   繁体   English

在Jboss_EAP_7.0上为jms配置持久订户

[英]Configuring durable subscriber for jms topic on Jboss_EAP_7.0

When configuring durable subscriber for jms topic on Jboss_EAP_7.0, is it require any configurations such as client id in standalone-full.xml or should i initialize client id inside my listener 在Jboss_EAP_7.0上为jms主题配置持久订阅者时,是否需要任何配置,例如standalone-full.xml中的客户端ID,还是应该在侦听器中初始化客户端ID?

This is my standalone-full.xml configurations for jms 这是我对jms的standalone-full.xml配置

 <subsystem xmlns="urn:jboss:domain:messaging-activemq:1.0">
            <server name="default" persistence-enabled="false">
                <security-setting name="#">
                    <role name="guest" delete-non-durable-queue="true" create-non-durable-queue="true" consume="true" send="true" create-durable-queue="true"/>
                </security-setting>
                <address-setting name="jms.queue.FromExchange" message-counter-history-day-limit="10" page-size-bytes="2097152" max-size-bytes="10485760" max-delivery-attempts="3" redelivery-multiplier="2.0" redelivery-delay="6000" expiry-address="jms.queue.ExpiryQueue" dead-letter-address="jms.queue.DLQ"/>
                <http-connector name="http-connector" endpoint="http-acceptor" socket-binding="http"/>
                <http-connector name="http-connector-throughput" endpoint="http-acceptor-throughput" socket-binding="http">
                    <param name="batch-delay" value="50"/>
                </http-connector>
                <in-vm-connector name="in-vm" server-id="0"/>
                <http-acceptor name="http-acceptor" http-listener="default"/>
                <http-acceptor name="http-acceptor-throughput" http-listener="default">
                    <param name="batch-delay" value="50"/>
                    <param name="direct-deliver" value="false"/>
                </http-acceptor>
                <in-vm-acceptor name="in-vm" server-id="0"/>
                <jms-queue name="ExpiryQueue" entries="java:/jms/queue/ExpiryQueue"/>
                <jms-queue name="DLQ" entries="java:/jms/queue/DLQ"/>
                <jms-queue name="ToExchange" durable="false" entries="java:/jms/queue/ToExchange java:jboss/exported/jms/queue/ToExchange"/>
                <jms-queue name="FromExchange" durable="false" entries="java:/jms/queue/FromExchange java:jboss/exported/jms/queue/FromExchange"/>
                <jms-topic name="ORD_CLINT_PUSH" entries="java:/jms/topic/ORD_CLINT_PUSH java:/jboss/exported/jms/topic/ORD_CLINT_PUSH"/>
                <jms-topic name="ORD_CLINT" entries="java:/jms/topic/ORD_CLINT java:/jboss/exported/jms/topic/ORD_CLINT"/>
                <connection-factory name="InVmConnectionFactory" thread-pool-max-size="100" entries="java:/ConnectionFactory" connectors="in-vm"/>
                <connection-factory name="RemoteConnectionFactory" entries="java:jboss/exported/jms/RemoteConnectionFactory" connectors="http-connector"/>
                <connection-factory name="RemoteConnectionFactorySTP" thread-pool-max-size="10" failover-on-initial-connection="true" reconnect-attempts="-1" block-on-acknowledge="true" client-failure-check-period="10000" ha="true" entries="java:jboss/exported/jms/RemoteConnectionFactorySTP" connectors="http-connector"/>
                <pooled-connection-factory name="activemq-ra" max-pool-size="50" min-pool-size="20" transaction="xa" entries="java:/JmsXA java:jboss/DefaultJMSConnectionFactory" connectors="in-vm"/>
            </server>
        </subsystem>

and following is my initializeConnection method where i have defined client id. 以下是我的initializeConnection方法,其中已定义了客户端ID。 Is this correct or required any changes 这是正确的还是需要任何更改

 public void initializeConnection() {
        reconnectAttempts++;
        System.out.println("connecting.....");

        Hashtable props = new Hashtable();
        props.put(Context.INITIAL_CONTEXT_FACTORY, contextFactory);
        props.put(Context.PROVIDER_URL, providerURL);
        props.put("java.naming.rmi.security.manager", "yes");
        props.put(Context.URL_PKG_PREFIXES, "org.jboss.naming");
        if ((userName != null) && (password != null)) {
            props.put(Context.SECURITY_PRINCIPAL, userName);
            props.put(Context.SECURITY_CREDENTIALS, password);
        }

        try {
            Context context = new InitialContext(props);
            topicConnectionFactory = (TopicConnectionFactory) context.lookup(connectionFactory);
            inputTopic = (Topic) context.lookup(queueName);
            context.close();

            if ((userName != null) && (password != null)) {
                topicConnection = topicConnectionFactory.createTopicConnection(userName, password);   //send username and password for EAP
            } else {
                topicConnection = topicConnectionFactory.createTopicConnection();
            }
            topicConnection.setClientID("Durable_S_1");
            topicSession = topicConnection.createTopicSession(false, Session.AUTO_ACKNOWLEDGE);
            topicReceiver = topicSession.createDurableSubscriber(inputTopic,"Durable_S_1");
           // topicReceiver = topicSession.createSubscriber(inputTopic);
            topicConnection.setExceptionListener(new EL(this));
            topicConnection.start();

            isConnected = true;
            reconnectAttempts = 0;
            System.out.println("completed.......");
        } catch (Exception e) {
            e.printStackTrace();
            closeQueueManager();
            if (reconnectAttempts < 10) {

            } else if ((10 <= reconnectAttempts) && (reconnectAttempts < 20)) {

            } else {

            }
        }
    }

You need to add permission create-durable-queue to true in standalone-full.xml to create durable subscriber. 您需要在standalone-full.xml中将权限create-durable-queue添加为true以创建持久订阅者。

 <security-setting name="#"> <role name="guest" delete-non-durable-queue="true" create-non-durable-queue="true" create-durable-queue="true" consume="true" send="true"/> </security-setting> 

声明:本站的技术帖子网页,遵循CC BY-SA 4.0协议,如果您需要转载,请注明本站网址或者原文地址。任何问题请咨询:yoyou2525@163.com.

 
粤ICP备18138465号  © 2020-2024 STACKOOM.COM