2

I need to work with Oracle AQ with ADT payload messages through JMS. Enqueing was simple (follow article http://blog.nominet.org.uk/tech/2007/10/04/spring-jms-with-oracle-aq/):

transactionTemplate.execute(new TransactionCallbackWithoutResult() {
    public void doInTransactionWithoutResult(TransactionStatus status) {
      // some code....
      jmsTemplate.send(new MyMessageCreator(myADTMessage));
      // some code...

    }
  });

where MyMessageCreator wrapped myADTMessage (created using jpub) into Message. It Works fine and within transaction - exception rolls back enquing and message is not inserting into the queue.

Problem starded with dequeing. I have to receive messages synchronisly, so the first try was:

Message messaege = jmsTemplate.receive();

and I get "JMS-137 Payload factory must be specified for destinations with ADT payloads"

I cant't find solution of that problem, so I tried to initialize underlying objects manually:

transactionTemplate.execute(new TransactionCallbackWithoutResult() {
    public void doInTransactionWithoutResult(TransactionStatus status) {
      QueueConnection queueCon = aqConnectionFactory.createQueueConnection();
        AQjmsSession queueSession = (AQjmsSession) queueCon.createQueueSession(true, Session.AUTO_ACKNOWLEDGE);
            QueueReceiver receiver = queueSession.createReceiver(myQueue, MyADTMessageType.getORADataFactory());
            queueCon.start();
            Message message = receiver.receiveNoWait();
            queueCon.stop();
            // some code....
    }
  });

where aqConnectionFactory is autowired Spring bean.

Messages are dequeued properly, but in local jms transaction! Without queueSession.commit() they stayed in the queue, and when I change creating session to createQueueSession(false, Session.AUTO_ACKNOWLEDGE), dequeing is performing in auto-commit mode.

So here I stucked. Has anyone idea, how to use JmsTemplate to dequeue ADT type messages with receive() method, or how to push AQjmsSession into existing transaction?

j0k
  • 22,600
  • 28
  • 79
  • 90
Jarek
  • 21
  • 2

0 Answers0