0
votes

I am fairly new to spring... I have a change whereby we need to add a message on a Tibco queue. The queue is defined in weblogic under JMS Modules as a Foreign Server (setup with a Connection Factory and Destination).

I would like to post message from my java app to the queue by making use of SPRING.

How should the wiring look in my spring applicationContext.xml file? And how can I use it from the code?

I had a look and do not find a proper tutorial that indicate this.

Can someone point me in a direction please.

Thanks a lot

1

1 Answers

2
votes

Use the following Spring config:

<bean id="jmsDestination" class="com.tibco.tibjms.TibjmsQueue">
    <constructor-arg value="queue.sample" />
</bean>
<bean id="jmsConnectionFactory" class="org.springframework.jms.connection.UserCredentialsConnectionFactoryAdapter">
    <property name="targetConnectionFactory" ref="tibcoConnectionFactory"/>
    <property name="username" value="admin"/>
    <property name="password" value=""/>
</bean>
<bean id="tibcoConnectionFactory" class="com.tibco.tibjms.TibjmsConnectionFactory">
    <property name="serverUrl" value="tcp://hostname:7222"/>
    <property name="userName" value="admin"/>
    <property name="userPassword" value=""/>
</bean>
<bean id="jmsProducerTemplate" class="org.springframework.jms.core.JmsTemplate">
    <property name="connectionFactory" ref="jmsConnectionFactory"/>
    <property name="defaultDestination" ref="jmsDestination"/>
</bean>

Then in the code, publish a message like this:

jmsProducerTemplate.send(new MessageCreator() {
    public Message createMessage(Session session) throws JMSException {
        return session.createTextMessage(dataString);
    }
});

This will publish directly to the Tibco queue, to use the JNDI of your WebLogic see this post: Configuration of tibco jms with Spring