【问题标题】:JMS Unable to consume messages from Oracle queue using spring/jmsJMS 无法使用 spring/jms 使用来自 Oracle 队列的消息
【发布时间】:2013-02-26 17:09:21
【问题描述】:

我已经按照 spring 文档设置了一个 Spring JMS 监听器。然而,即使我向队列中添加了一条消息,我的代码也没有检测到这一点。我的spring配置如下:

<bean id="dataSourceListener" class="oracle.jdbc.pool.OracleDataSource">
    <property name="URL" value="xxx"/>
    <property name="user" value="xxx"/>
    <property name="password" value="xxx"/>
</bean>

<bean id="jmsConnectionFactory" class="OracleAqFactoryBean">
    <property name="dataSource" ref="dataSourceListener" />
</bean>

<jms:listener-container connection-factory="jmsConnectionFactory" acknowledge="transacted" concurrency="1-5">
    <jms:listener destination="queuename" ref="myMessageListener"/>
</jms:listener-container>

<bean id="myMessageListener" class="Listener"/>

我的Java如下:

我的自定义监听器:

class Listener implements MessageListener {

    @Override
    void onMessage(Message message) {
        // code to handle message is here
    }
}

还有我的 OracleAqFactoryBean:

public class OracleAqFactoryBean implements FactoryBean {
private DataSource dataSource;

public void setDataSource(DataSource dataSource) {
    this.dataSource = dataSource;
}

@Override
public Object getObject() throws Exception {
    return AQjmsFactory.getConnectionFactory( dataSource );
}

@Override
public Class<?> getObjectType() {
    return ConnectionFactory.class;
}

@Override
public boolean isSingleton() {
    return true;
}

}

[编辑:上述设置现已成功运行]

【问题讨论】:

    标签: oracle spring queue jms oracle-aq


    【解决方案1】:

    我不明白您为什么要将 FactoryBean 实现连接到 Spring DMLC destination 属性。这显然是不正确的,因为 setDestinationmethod 只接受 javax.jms.Destination 类型。您已经连接了connectionFactorymessageListener。这就是开始使用消息所需的全部内容。如果删除已连接到 destination 属性的 testmq 引用,则应该成功使用消息。

    【讨论】:

    • 您好,感谢您的回复。我已经更改了我的配置,上面的设置现在可以工作了。不过,我尝试将其移植到 Grails 应用程序中,并且它不会消耗队列中的任何消息。我想没有人以前尝试过这个并且有任何想法吗?
    猜你喜欢
    • 1970-01-01
    • 2013-09-23
    • 1970-01-01
    • 2015-02-19
    • 2020-04-05
    • 2012-01-03
    • 1970-01-01
    • 2011-04-25
    • 1970-01-01
    相关资源
    最近更新 更多