I have the below program of spring jms in which a message is been send to a tibco queue , rite now i am using active MQ as a message broker, i want to configure it with tibco ems , so what i want to configure is the xml of active mq to be replaced with the xml of tibco one so please advise how can i configure the xml for tibco , at last i have shown below also can you please advise what necessary changes i need to done in the xml of tibco one.. the below program is
the interface :-
package com.abc.springrecipes.post;
public interface FrontDesk {
public void sendMail(Mail mail);
}
class to send the message :-
package com.abc.springrecipes.post;
import javax.jms.Destination;
import javax.jms.JMSException;
import javax.jms.MapMessage;
import javax.jms.Message;
import javax.jms.Session;
import org.springframework.jms.core.JmsTemplate;
import org.springframework.jms.core.MessageCreator;
public class FrontDeskImpl implements FrontDesk {
private JmsTemplate jmsTemplate;
private Destination destination;
public void setJmsTemplate(JmsTemplate jmsTemplate) {
this.jmsTemplate = jmsTemplate;
}
public void setDestination(Destination destination) {
this.destination = destination;
}
public void sendMail(final Mail mail) {
jmsTemplate.send(destination, new MessageCreator() {
public Message createMessage(Session session) throws JMSException {
MapMessage message = session.createMapMessage();
message.setString("mailId", mail.getMailId());
message.setString("country", mail.getCountry());
message.setDouble("weight", mail.getWeight());
return message;
}
});
}
}
and the main class which will send the message ..
package com.abc.springrecipes.post;
import org.springframework.context.ApplicationContext;
import org.springframework.context.support.ClassPathXmlApplicationContext;
public class FrontDeskMain {
public static void main(String[] args) {
ApplicationContext context =
new ClassPathXmlApplicationContext("beans-front.xml");
FrontDesk frontDesk = (FrontDesk) context.getBean("frontDesk");
frontDesk.sendMail(new Mail("1234", "US", 1.5));
}
}
rite now active mq configuration is done but i want to configure with tibco ems so what i have tried is shown below but now please advise is it correct
<bean id="tibcoEMSJndiTemplate" class="org.springframework.jndi.JndiTemplate">
<property name="environment">
<props>
<prop key="java.naming.factory.initial">com.tibco.tibjms.naming.TibjmsInitialContextFactory</prop>
<prop key="java.naming.provider.url">http://tcpabcnet:707</prop>
<prop key="java.naming.security.principal">abc</prop>
<prop key="java.naming.security.credentials">abc</prop>
</props>
</property>
</bean>
<bean id="tibcoEMSConnFactory" class="org.springframework.jndi.JndiObjectFactoryBean">
<property name="jndiTemplate">
<ref bean="tibcoEMSJndiTemplate" />
</property>
<property name="jndiName">
<value>GenericConnectionFactory</value>
</property>
</bean>
<bean id="tibcosendJMSTemplate" class="org.springframework.jms.core.JmsTemplate">
<property name="connectionFactory">
<ref local="tibcoEMSConnFactory" />
</property>
<property name="defaultDestinationName">
<value>test.data</value>
</property>
<property name="pubSubDomain">
<value>false</value>
</property>
<property name ="receiveTimeout">
<value>120000</value>
</property>
</bean>
the earlier of a ctive mq is shown below..
<beans ...>
<bean id="connectionFactory"
class="org.apache.activemq.ActiveMQConnectionFactory">
<property name="brokerURL" value="tcp://localhost:61616" />
</bean>
<bean id="mailDestination"
class="org.apache.activemq.command.ActiveMQQueue">
<constructor-arg value="mail.queue" />
</bean>
<bean id="jmsTemplate"
class="org.springframework.jms.core.JmsTemplate">
<property name="connectionFactory" ref="connectionFactory" />
</bean>
<bean id="frontDesk"
class="com.abc.springrecipes.post.FrontDeskImpl">
<property name="destination" ref="mailDestination" />
<property name="jmsTemplate" ref="jmsTemplate" />
</bean>
</beans>
Aucun commentaire:
Enregistrer un commentaire