Has anyone got Spring JMS to work with an Oracle AQ queue?
I am trying to connect to AQ based on this article http://blog.nominet.org.uk/tech/2007/10/04/spring-jms-with-oracle-a开发者_Go百科q/
but i am getting this error now JMS-137: Payload factory must be specified for destinations with ADT payloads
Any help with this is much appreciated
Thanks Damien
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:
queueReceiver = ((AQjmsSession) queueSession).
createReceiver(queue, XMLType.getORADataFactory());
You have to supply a JDBC type map when you want to en-queue or de-queue AnyDataType or User Defined Payloads.
The best place to do it, in the Link you have posted will be in 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
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.
More info on custom payload here http://download.oracle.com/docs/cd/B19306_01/server.102/b14257/aq_stage.htm#sthref2705
This is how you can solve it if you are using 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.
精彩评论