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

在Jboss_EAP_7.0上为jms主题配置持久订户,jboss,jms-topic,Jboss,Jms Topic,在Jboss_EAP_7.0上为jms主题配置持久订户时,是否需要任何配置,例如standalone-full.xml中的客户端id,或者我应该在侦听器中初始化客户端id 这是我针对jms的单机版-full.xml配置 <subsystem xmlns="urn:jboss:domain:messaging-activemq:1.0"> <server name="default" persistence-enabled="false">

在Jboss_EAP_7.0上为jms主题配置持久订户时,是否需要任何配置,例如standalone-full.xml中的客户端id,或者我应该在侦听器中初始化客户端id

这是我针对jms的单机版-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>

下面是我的initializeConnection方法,我在其中定义了客户端id。这是正确的还是需要任何更改

 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 {

            }
        }
    }
public void initializeConnection(){
重新连接尝试++;
System.out.println(“连接…”);
Hashtable props=新的Hashtable();
props.put(Context.INITIAL\u Context\u工厂,contextFactory);
props.put(Context.PROVIDER\uURL、providerURL);
put(“java.naming.rmi.security.manager”,“yes”);
put(Context.URL_PKG_前缀,“org.jboss.naming”);
如果((用户名!=null)和&(密码!=null)){
props.put(Context.SECURITY\u主体,用户名);
props.put(Context.SECURITY\u凭证、密码);
}
试一试{
上下文=新的初始上下文(道具);
topicConnectionFactory=(topicConnectionFactory)上下文。查找(connectionFactory);
inputTopic=(主题)context.lookup(queueName);
context.close();
如果((用户名!=null)和&(密码!=null)){
topicConnection=topicConnectionFactory.createTopicConnection(用户名、密码);//发送EAP的用户名和密码
}否则{
topicConnection=topicConnectionFactory.createTopicConnection();
}
topicConnection.setClientID(“持久的”S_1“);
topicSession=topicConnection.createTopicSession(false,Session.AUTO_ACKNOWLEDGE);
topicReceiver=topicSession.createDurableSubscriber(inputTopic,“持久用户1”);
//topicReceiver=topicSession.createSubscriber(inputTopic);
topicConnection.setExceptionListener(新EL(此));
topicConnection.start();
断开连接=正确;
重新连接尝试次数=0;
系统输出打印项次(“已完成”);
}捕获(例外e){
e、 printStackTrace();
closeQueueManager();
如果(重新连接尝试次数<10次){

}else if((10您需要在standalone-full.xml中将创建持久队列的权限添加为true,以创建持久订阅者



问题是Jboss不允许我添加“create durable queue=“true”配置。但即使没有它,这也能像我预期的那样工作。除了你的建议,我相信standalone-full.xml中没有任何配置。
<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>