使用Spring和JBOSS eap-6.1抛出Exception时,回滚不能与WMQ一起使用

时间:2015-10-15 05:14:27

标签: jboss spring-jms

I am using JBOSS eap-6.1 ,wmq with spring.when I am rolling back the messages , its not going to backout and even its not staying inqueue.But its working with ActiveMq.Below are my configuration files,Please help me if I am doing anything wrong.  

 jboss/standalone.xml configuration is

  <subsystem xmlns="urn:jboss:domain:resource-adapters:1.1">
                <resource-adapters>
                    <resource-adapter id="wmq.jmsra.rar">
                        <archive>
                            wmq.jmsra.rar
                        </archive>
                        <transaction-support>XATransaction</transaction-support>
                        <connection-definitions>
                            <connection-definition class-name="com.ibm.mq.connector.outbound.ManagedConnectionFactoryImpl" jndi-name="java:jboss/MQ.CONNECTIONFACTORY.NAME" pool-name="MQ.CONNECTIONFACTORY.NAME">
                                <config-property name="port">
                                    ${queue.port}
                                </config-property>
                                <config-property name="hostName">
                                    ${queue.host}
                                </config-property>
                                <config-property name="UserName">
                                    ${queue.server.username}
                                </config-property>
                                <config-property name="channel">
                                    ${queue.server.channel}
                                </config-property>
                                <config-property name="transportType">
                                    ${queue.transporttype}
                                </config-property>
                                <config-property name="queueManager">
                                    ${queue.manager}
                                </config-property>
                            </connection-definition>
                        </connection-definitions>
                        <admin-objects>
                            <admin-object class-name="com.ibm.mq.connector.outbound.MQQueueProxy" jndi-name="java:jboss/MQ.QUEUE.NAME.IN" pool-name="MQ.QUEUE.NAME.IN">
                                <config-property name="baseQueueName">
                                    ${queue.name.in}
                                </config-property>
                            </admin-object>
                            <admin-object class-name="com.ibm.mq.connector.outbound.MQQueueProxy" jndi-name="java:jboss/MQ.QUEUE.NAME.BACKOUT" pool-name="MQ.QUEUE.NAME.BACKOUT">
                                <config-property name="baseQueueName">
                                    ${queue.name.backout}
                                </config-property>
                            </admin-object>

                        </admin-objects>
                    </resource-adapter>
                </resource-adapters>

    Spring configuration file jms.xml is

    <jee:jndi-lookup id="AVTConnectionFactory"
    jndi-name="java:jboss/MQ.CONNECTIONFACTORY.NAME" />
    <jee:jndi-lookup id="AVTMessageQueue" jndi-name="java:jboss/MQ.QUEUE.NAME.IN" />
    <jee:jndi-lookup id="driverIdRequestQueue" jndi-name="java:jboss/MQ.QUEUE.NAME.OUT" />
    <jee:jndi-lookup id="backOutQueue" jndi-name="java:jboss/MQ.QUEUE.NAME.BACKOUT" />

    <bean id="vehiclePositionReplyListener"
    class="org.springframework.jms.listener.DefaultMessageListenerContainer">
    <property name="connectionFactory" ref="AVTConnectionFactory" />
    <property name="destination" ref="AVTMessageQueue" />
    <property name="messageListener" ref="vehicleReplyMdp" />
    <property name="sessionTransacted" value="true" />
    </bean>

    listener file is
    @Named("vehicleReplyMdp")
    @TransactionAttribute(TransactionAttributeType.NOT_SUPPORTED)
    public class VCGListenerMDP implements VCGListenerMDPService {
    @Override
    public void onMessage(Message message, Session session) throws JMSException {

    LOG.debug("----------------- QueueIN Listener--------------");
    try {
    if (message instanceof TextMessage) {
    boolean val=processInComingMessage(message, session);
    if(!val){
    throw new JMSException("JMSException");
    }
    }
    } catch (JMSException e) {
    LOG.error("Exception processing mesage: {}", e.toString());
    throw new RuntimeException(e);
    } catch (NamingException e) {
    e.printStackTrace();
    } 
    }

    public boolean processInComingMessage(Message message, Session session)
    throws JMSException, NamingException {
    InitialContext ctx = new InitialContext();
    NamingEnumeration<NameClassPair> list = ctx.list("");
    boolean isActiveMQFlg = false;
    while (list.hasMore()) {
    NameClassPair next = list.next();

    if (next.getName().contains(ACTIVE_MQ_JNDI_REF)) {
    isActiveMQFlg = true;
    break;
    }
    }

    try {
    // Checking database connectivity
    jurisdictionService.getJurisdictionCount();
    } catch (Exception ex) {
    if (isActiveMQFlg) {
    session.rollback();
    } else {
    ex.printStackTrace();
    }
    return false;
    }

当我使用session.rollback工作为activemq时,对于WMQ,当我抛出异常时它没有回滚而且回退阈值的事件触发器不起作用。阈值是3次,它只是第一次触发

0 个答案:

没有答案