Search code examples
springspring-jmsjmstemplate

JMSTemplate and recipient list


I've read the documentation and I've seen a similiar question (from late 2005) but it seems no one got an answer. ( http://forum.spring.io/forum/spring-projects/integration/jms/9152-jmstemplate-oracle-jms )

I'm trying to send a message to a Topic using JmsTemplate while specifying the subscriber but either I'm not able to find the correct documentation or I can't find the correct API.

Is it possible to achieve something like this with JmsTemplate?

If you need any additional information please let me know.


Solution

  • The JMSTemplate high-level methods only support the JMS Standard.

    This is an extension to JMS...

    Adds Oracle Streams Advanced Queuing specific extensions to javax.jms.TopicPublisher

    Sometimes you can handle such extensions with JmsTemplate.execute with a session callback but I think, in this case, you need to create a specific type of session. So, I think you are stuck with rolling your own code.

    You could subclass JmsTemplate and override createSession to create the right kind of session; then you can use...

        Boolean result = template.execute(new SessionCallback<Boolean>() {
    
            @Override
            public Boolean doInJms(Session session) throws JMSException {
                Topic topic = ((AQjmsSession) session).getTopic(...);
                ((AQjmsTopicPublisher) publisher).publish(topic, topicSession.createTextMessage(message),recipientL ist1);
                return true;
            }
        });