如何从远程服务器监听jms-queue

时间:2016-08-08 11:29:14

标签: jms spring-jms

我在spring应用程序中实现了jms队列和listner。 我无法从远程系统侦听jms队列。我在服务器应用程序util-sevice.xml文件中配置了Queue。

<bean id="jndiTemplate" class="org.springframework.jndi.JndiTemplate">
            <property name="environment">
                <props>
                    <prop key="java.naming.provider.url">http-remoting://182.18.177.115:80</prop>

                    <prop key="java.naming.factory.initial">org.jboss.naming.remote.client.InitialContextFactory
                    </prop>
                    <prop key="java.naming.security.principal">user</prop>
                    <prop key="java.naming.security.principal">pwd</prop>
                </props>
            </property>
        </bean>

<bean id="connectionFactory" class="org.springframework.jndi.JndiObjectFactoryBean">
        <property name="jndiTemplate">
            <ref bean="jndiTemplate" />
        </property>
        <property name="jndiName" value="jms/RemoteConnectionFactory">
        </property>
    </bean>
<bean id="credentialsconnectionfactory"
        class="org.springframework.jms.connection.UserCredentialsConnectionFactoryAdapter">
        <property name="targetConnectionFactory" ref="connectionFactory" />
        <property name="username" value="use" />
        <property name="password" value="pwd" />
    </bean>
<bean id="genricDbSyncDestination" class="org.springframework.jndi.JndiObjectFactoryBean">
        <property name="jndiTemplate" ref="jndiTemplate" />
        <property name="jndiName" value="java:/jms/queue/GenricDbSyncQueue" />
    </bean>

        <bean id="genricDbSyncTemplate" class="org.springframework.jms.core.JmsTemplate">
        <property name="connectionFactory" ref="credentialsconnectionfactory" />
        <property name="defaultDestination" ref="genricDbSyncDestination" />
    </bean>

远程服务器中的standalone-full.xml

<jms-queue name="GenricDbSyncQueue">
                        <entry name="jms/queue/GenricDbSyncQueue"/>
                        <entry name="java:jboss/exported/jms/queue/GenricDbSyncQueue"/>
                    </jms-queue>

和我的本地系统spring应用程序util-service.xml配置文件,用于侦听该队列

<bean id="genricDbSyncListener" class="com.ayotta.genericdbsync.GenericDbSyncConsumer" />

    <bean id="jndiTemplate" class="org.springframework.jndi.JndiTemplate">
        <property name="environment">
            <props>
                <prop key="java.naming.provider.url">http-remoting://182.18.177.115:80</prop>
                <prop key="java.naming.factory.initial">org.jboss.naming.remote.client.InitialContextFactory
                </prop>
                 <property name="username" value="use" />
        <property name="password" value="pwd" />
            </props>
        </property>
    </bean>

    <bean id="connectionFactory" class="org.springframework.jndi.JndiObjectFactoryBean">
        <property name="jndiTemplate">
            <ref bean="jndiTemplate" />
        </property>
        <property name="jndiName" value="jms/RemoteConnectionFactory">
        </property>
    </bean>
    <bean id="credentialsconnectionfactory"
        class="org.springframework.jms.connection.UserCredentialsConnectionFactoryAdapter">
        <property name="targetConnectionFactory" ref="connectionFactory" />
         <property name="username" value="use" />
        <property name="password" value="pwd" />
    </bean>

    <jms:listener-container connection-factory="credentialsconnectionfactory"
        concurrency="1" acknowledge="auto" destination-type="queue">
<jms:listener destination="GenricDbSyncQueue" ref="genricDbSyncListener"
            method="onMessage" />
    </jms:listener-container>

如何从本地系统应用程序中侦听远程jms队列

0 个答案:

没有答案