Spring JMS 和 Oracle AQ

声明:本页面是StackOverFlow热门问题的中英对照翻译,遵循CC BY-SA 4.0协议,如果您需要使用它,必须同样遵循CC BY-SA许可,注明原文地址和作者信息,同时你必须将它归于原作者(不是我):StackOverFlow 原文地址: http://stackoverflow.com/questions/4450925/
Warning: these are provided under cc-by-sa 4.0 license. You are free to use/share it, But you must attribute it to the original authors (not me): StackOverFlow

提示:将鼠标放在中文语句上可以显示对应的英文。显示中英文
时间:2020-09-18 22:11:45  来源:igfitidea点击:

Spring JMS and Oracle AQ

javaoraclespring

提问by Damien

Has anyone got Spring JMS to work with an Oracle AQ queue?

有没有人让 Spring JMS 与 Oracle AQ 队列一起工作?

I am trying to connect to AQ based on this article http://blog.nominet.org.uk/tech/2007/10/04/spring-jms-with-oracle-aq/

我正在尝试根据这篇文章连接到 AQ http://blog.nominet.org.uk/tech/2007/10/04/spring-jms-with-oracle-aq/

but i am getting this error now JMS-137: Payload factory must be specified for destinations with ADT payloads

但我现在收到此错误 JMS-137:必须为具有 ADT 有效负载的目的地指定有效负载工厂

Any help with this is much appreciated

非常感谢您对此的任何帮助

Thanks Damien

谢谢达米安

回答by JOTN

That error indicates to me it's actually working but you're not giving it a payload factory to create the object coming off the queue. You do that when you create the receiver. In this case my payload is XMLTYPE so I just use its payload factory:

该错误向我表明它实际上正在工作,但您没有为其提供有效载荷工厂来创建从队列中出来的对象。您在创建接收器时执行此操作。在这种情况下,我的有效载荷是 XMLTYPE,所以我只使用它的有效载荷工厂:

queueReceiver = ((AQjmsSession) queueSession).
   createReceiver(queue, XMLType.getORADataFactory());

回答by Damien

You have to supply a JDBC type map when you want to en-queue or de-queue AnyDataType or User Defined Payloads.

当您想要将 AnyDataType 或用户定义的有效负载入队或出队时,您必须提供 JDBC 类型映射。

The best place to do it, in the Link you have posted will be in OracleAqDestinationFactoryBean.getObject.

执行此操作的最佳位置,在您发布的链接中将位于 OracleAqDestinationFactoryBean.getObject 中。

In my case, I wanted to de-queue Oracle LCRs which are of XMLType , so I had to do the following in the getObject

就我而言,我想使 XMLType 的 Oracle LCR 出队,因此我必须在 getObject 中执行以下操作

public Object getObject() throws Exception {
    QueueConnection queueConnection = connectionFactory.createQueueConnection();
    AQjmsSession session = (AQjmsSession) queueConnection.createQueueSession(true,
            Session.SESSION_TRANSACTED);
    Map map = session.getTypeMap();
    map.put("SYS.XMLTYPE", Class.forName("oracle.xdb.XMLTypeFactory"));
    return session.getQueue(queueUser, queueName);
}

Remember for AnyDataType Payload you have to use OCI JDBC driver, as the thin driver won't do.

请记住,对于 AnyDataType Payload,您必须使用 OCI JDBC 驱动程序,因为瘦驱动程序不会这样做。

More info on custom payload here http://download.oracle.com/docs/cd/B19306_01/server.102/b14257/aq_stage.htm#sthref2705

有关自定义负载的更多信息,请访问 http://download.oracle.com/docs/cd/B19306_01/server.102/b14257/aq_stage.htm#sthref2705

回答by mk_

This is how you can solve it if you are using Spring: http://blog.javaforge.net/post/30858904340/oracle-advanced-queuing-spring-custom-types

如果您使用 Spring,这就是您可以解决的方法:http: //blog.javaforge.net/post/30858904340/oracle-advanced-queuing-spring-custom-types

In a "springless" environment just create your own message consumer like described in the blog post above.

在“无弹簧”环境中,只需创建您自己的消息使用者,如上面的博客文章中所述。