使用Websphere MQ的Spring JMS-未能启动BEAN ORG.SPRINGFRAMEWORK.JMS.LISTENER.ENDPOINT.JMSMESSAGEENDPOINTMANAGER

时间:2018-08-21 20:32:34

标签: spring-mvc websphere ibm-mq spring-jms

我正在尝试将Spring MVC应用程序与Websphere MQ连接。它对我来说是不可能的。请有人可以帮助我解决。我将在下面发布代码:

在Websphere Application Server中,我创建了Queue和QueueConnectionFactory资源

mcv-dispatcher-servlet.xml

<beans xmlns="http://www.springframework.org/schema/beans"
       xmlns:context="http://www.springframework.org/schema/context"
       xmlns:amq="http://activemq.apache.org/schema/core"
       xmlns:aop="http://www.springframework.org/schema/aop"
       xmlns:jee="http://www.springframework.org/schema/jee" 
       xmlns:tx="http://www.springframework.org/schema/tx"
       xmlns:util="http://www.springframework.org/schema/util" 
       xmlns:task="http://www.springframework.org/schema/task"
       xmlns:mvc="http://www.springframework.org/schema/mvc" 
       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-3.0.xsd
        http://www.springframework.org/schema/context 
        http://www.springframework.org/schema/context/spring-context-3.0.xsd
        http://www.springframework.org/schema/mvc
        http://www.springframework.org/schema/mvc/spring-mvc-3.0.xsd
http://www.springframework.org/schema/aop 
http://www.springframework.org/schema/aop/spring-aop.xsd 
http://www.springframework.org/schema/util http://www.springframework.org/schema/util/spring-util.xsd">

    <context:component-scan base-package="cl.scotiabank.controller" />
    <mvc:resources mapping="/resources/**" location="/resources/" />
    <mvc:annotation-driven />

    <bean class="cl.scotiabank.util.XmlUtil" id="xmlUtil"/>
    <bean id="avisame.properties"
          class="org.springframework.beans.factory.config.PropertyPlaceholderConfigurer">
        <property name="location" value="classpath:avisame.properties" />
        <property name="systemPropertiesModeName" value="SYSTEM_PROPERTIES_MODE_NEVER" />
    </bean>   


    <bean id="simpleMessageListener" class="cl.scotiabank.jms.ConsumerListener" />


    <bean class="org.springframework.jms.listener.endpoint.JmsMessageEndpointManager">
        <property name="activationSpec">
            <bean class="com.ibm.mq.connector.inbound.ActivationSpecImpl">
                <property name="destinationType" value="javax.jms.Queue"/>
                <property name="destination" value="PTAVISAME"/>
                <property name="hostName" value="10.000.000.25"/>
                <property name="queueManager" value="DESAVI002"/>
                <property name="port" value="1414"/>
                <property name="channel" value="DESAVISAME"/> 
            </bean>
        </property>
        <property name="messageListener" ref="simpleMessageListener"/>
        <property name="resourceAdapter" ref="myResourceAdapterBean"/>
    </bean>

    <bean id="myResourceAdapterBean" class ="org.springframework.jca.support.ResourceAdapterFactoryBean">
        <property name="resourceAdapter">
            <bean class="com.ibm.mq.connector.ResourceAdapterImpl">
                <property name="maxConnections" value="50"/>
            </bean>
        </property>
        <property name="workManager">
            <bean class="org.springframework.jca.work.SimpleTaskWorkManager"/>
        </property>
    </bean>
</beans>

ConsumerListerner.class

package cl.scotiabank.jms;

import cl.scotiabank.controller.DebitCardController;
import cl.scotiabank.dao.HistoryDAO;
import cl.scotiabank.exception.DaoException;
import cl.scotiabank.to.HistoryTO;
import java.util.logging.Level;
import java.util.logging.Logger;
import javax.jms.JMSException;
import javax.jms.Message;
import javax.jms.MessageListener;
import javax.jms.TextMessage;

public class ConsumerListener implements MessageListener {

@Override
public void onMessage(Message message) {
        System.out.println(" ##########################################  CONSUMER LISTENER  ##########################################");
    if (message instanceof TextMessage) {
        try {
            String history = ((TextMessage) message).getText();
            JmsHistory jmsHistory = new JmsHistory(history);

            HistoryDAO historyDAO = new HistoryDAO();
            HistoryTO historyTO = new HistoryTO();
            historyTO.setEstado("1");
            historyTO.setNombreComercio("1");
            historyTO.setObservacion("Desde Cola MQ");
            try {
                historyDAO.insertarHistory(historyTO);
            } catch (DaoException ex) {
                Logger.getLogger(DebitCardController.class.getName()).log(Level.SEVERE, null, ex);
                System.out.println(" ##########################################  ERROR  DB - > CONSUMER LISTENER  ##########################################");

            }
        } catch (JMSException ex) {
            System.out.println(" ##########################################  ERROR - > CONSUMER LISTENER  ##########################################");

            throw new RuntimeException(ex);
        }

    }
}

}

这是我的pom.xml

<project xmlns="http://maven.apache.org/POM/4.0.0" xmlns:xsi="http://www.w3.org/2001/XMLSchema-instance"
     xsi:schemaLocation="http://maven.apache.org/POM/4.0.0 http://maven.apache.org/maven-v4_0_0.xsd">
<modelVersion>4.0.0</modelVersion>
<groupId>cl.scotiabscotiabankank</groupId>
<artifactId>avisame</artifactId>
<packaging>war</packaging>
<version>2.0.1</version>
<name>avisame_backend</name>
<url>http://maven.apache.org</url>

<properties>
    <spring.version>3.0.5.RELEASE</spring.version>
    <jackson.version>1.9.13</jackson.version>
    <databind.version>2.2.4</databind.version>
    <hibernate.version>3.5.5-Final</hibernate.version>
    <junit.version>5.1.0</junit.version>
    <junit.jupiter.version>5.1.1</junit.jupiter.version>
    <junit.vintage.version>${junit.version}.0</junit.vintage.version>
    <junit.jupiter.version>5.1.1</junit.jupiter.version>
    <junit.platform.version>1.1.1</junit.platform.version>
    <springfox-version>2.7.0</springfox-version>
</properties>

<dependencies>

    <!-- Spring 3 dependencies -->
    <dependency>
        <groupId>org.springframework</groupId>
        <artifactId>spring-core</artifactId>
        <version>${spring.version}</version>
    </dependency>

    <dependency>
        <groupId>org.springframework</groupId>
        <artifactId>spring-web</artifactId>
        <version>${spring.version}</version>
    </dependency>

    <dependency>
        <groupId>org.springframework</groupId>
        <artifactId>spring-webmvc</artifactId>
        <version>${spring.version}</version>
    </dependency>

    <dependency>
        <groupId>io.jsonwebtoken</groupId>
        <artifactId>jjwt</artifactId>
        <version>0.7.0</version>
    </dependency>

    <dependency>
        <groupId>javax.servlet</groupId>
        <artifactId>servlet-api</artifactId>
        <version>2.5</version>
    </dependency>

    <!-- https://mvnrepository.com/artifact/org.codehaus.jackson/jackson-mapper-asl -->
    <dependency>
        <groupId>org.codehaus.jackson</groupId>
        <artifactId>jackson-mapper-asl</artifactId>
        <version>${jackson.version}</version>
    </dependency>

    <!-- https://mvnrepository.com/artifact/org.codehaus.jackson/jackson-core-asl -->
    <dependency>
        <groupId>org.codehaus.jackson</groupId>
        <artifactId>jackson-core-asl</artifactId>
        <version>${jackson.version}</version>
    </dependency>

    <!-- https://mvnrepository.com/artifact/com.fasterxml.jackson.core/jackson-databind -->
    <dependency>
        <groupId>com.fasterxml.jackson.core</groupId>
        <artifactId>jackson-databind</artifactId>
        <version>${databind.version}</version>
    </dependency>

    <!-- https://mvnrepository.com/artifact/com.sun.jersey/jersey-client -->
    <dependency>
        <groupId>com.sun.jersey</groupId>
        <artifactId>jersey-client</artifactId>
        <version>1.19.3</version>
    </dependency>

    <!-- https://mvnrepository.com/artifact/org.slf4j/slf4j-api -->
    <dependency>
        <groupId>org.slf4j</groupId>
        <artifactId>slf4j-api</artifactId>
        <version>1.7.14</version>
    </dependency>
    <!-- https://mvnrepository.com/artifact/org.slf4j/slf4j-log4j12 -->
    <dependency>
        <groupId>org.slf4j</groupId>
        <artifactId>slf4j-log4j12</artifactId>
        <version>1.7.14</version>
    </dependency>

    <!-- Hibernate -->
    <dependency>
        <groupId>org.hibernate</groupId>
        <artifactId>hibernate-core</artifactId>
        <version>${hibernate.version}</version>
    </dependency>
    <dependency>
        <groupId>org.hibernate</groupId>
        <artifactId>hibernate-entitymanager</artifactId>
        <version>${hibernate.version}</version>
    </dependency>
    <!-- https://mvnrepository.com/artifact/net.sourceforge.jtds/jtds -->
    <dependency>
        <groupId>net.sourceforge.jtds</groupId>
        <artifactId>jtds</artifactId>
        <version>1.2.4</version>
    </dependency>

    <!-- https://mvnrepository.com/artifact/joda-time/joda-time -->
    <dependency>
        <groupId>joda-time</groupId>
        <artifactId>joda-time</artifactId>
        <version>2.3</version>
    </dependency>

    <!-- https://mvnrepository.com/artifact/org.apache.axis/axis -->
    <dependency>
        <groupId>org.apache.axis</groupId>
        <artifactId>axis</artifactId>
        <version>1.4</version>
    </dependency>

    <!-- https://mvnrepository.com/artifact/javax.mail/mail -->
    <dependency>
        <groupId>com.sun.mail</groupId>
        <artifactId>javax.mail</artifactId>
        <version>1.4.5</version>
    </dependency>
    <!-- https://mvnrepository.com/artifact/org.apache.axis/axis-jaxrpc -->
    <dependency>
        <groupId>org.apache.axis</groupId>
        <artifactId>axis-jaxrpc</artifactId>
        <version>1.4</version>
    </dependency>
    <!-- https://mvnrepository.com/artifact/commons-discovery/commons-discovery -->
    <dependency>
        <groupId>commons-discovery</groupId>
        <artifactId>commons-discovery</artifactId>
        <version>0.5</version>
    </dependency>
    <dependency>
        <groupId>wsdl4j</groupId>
        <artifactId>wsdl4j</artifactId>
        <version>1.6.2</version>
    </dependency>
    <!-- https://mvnrepository.com/artifact/org.apache.httpcomponents/httpclient -->
    <dependency>
        <groupId>org.apache.httpcomponents</groupId>
        <artifactId>httpclient</artifactId>
        <version>4.3-alpha1</version>
    </dependency>

    <!-- https://mvnrepository.com/artifact/javax.jms/javax.jms-api -->
    <dependency>
        <groupId>javax.jms</groupId>
        <artifactId>javax.jms-api</artifactId>
        <version>2.0.1</version>
    </dependency>

    <dependency>
        <groupId>org.junit.jupiter</groupId>
        <artifactId>junit-jupiter-engine</artifactId>
        <version>${junit.jupiter.version}</version>
        <scope>test</scope>
    </dependency>

    <dependency>
        <groupId>org.junit.platform</groupId>
        <artifactId>junit-platform-runner</artifactId>
        <version>${junit.platform.version}</version>
        <scope>test</scope>
    </dependency>
    <!--        <dependency>
        <groupId>org.junit.vintage</groupId>
        <artifactId> junit-vintage-engine</artifactId>
        <version>${junit.vintage.version}</version>
        <scope>test</scope>
    </dependency>-->
    <dependency>
        <groupId>junit</groupId>
        <artifactId>junit</artifactId>
        <version>4.12</version>
        <scope>test</scope>
    </dependency>
    <dependency>
        <groupId>org.hamcrest</groupId>
        <artifactId>hamcrest-core</artifactId>
        <version>1.3</version>
        <scope>test</scope>
    </dependency>

    <dependency>
        <groupId>io.springfox</groupId>
        <artifactId>springfox-swagger2</artifactId>
        <version>${springfox-version}</version>
    </dependency>
    <dependency>
        <groupId>io.springfox</groupId>
        <artifactId>springfox-swagger-ui</artifactId>
        <version>${springfox-version}</version>
    </dependency>
    <dependency>
        <groupId>org.springframework.ws</groupId>
        <artifactId>spring-ws-core</artifactId>
        <version>3.0.1.RELEASE</version>
        <type>jar</type>
    </dependency>

    <!--JMS Dependecies-->
    <dependency>
        <groupId>org.springframework</groupId>
        <artifactId>spring-jms</artifactId>
        <version>3.0.7.RELEASE</version>
        <type>jar</type>
    </dependency>
</dependencies>



<build>
    <finalName>avisame</finalName>
    <plugins>
        <plugin>
            <artifactId>maven-compiler-plugin</artifactId>
            <version>3.5.1</version>
            <configuration>
                <source>1.8</source>
                <target>1.8</target>
            </configuration>
        </plugin>
        <plugin>
            <artifactId>maven-surefire-plugin</artifactId>
            <version>2.19.1</version>
            <dependencies>
                <dependency>
                    <groupId>org.junit.platform</groupId>
                    <artifactId>junit-platform-surefire-provider</artifactId>
                    <version>${junit.platform.version}</version>
                </dependency>
            </dependencies>
        </plugin>
    </plugins>
</build>

1 个答案:

答案 0 :(得分:0)

IBM MQ documentation中,您没有在/hotels/:hotel_id/check_ins/new bean中使用destinationLookupuseJNDI属性来配置JNDI查找。

因此,将不会使用在WebSphere Application Server中定义的队列和连接工厂资源。