samedi 28 mars 2015

spring integration program to send a message to a tibco ems queue

I am new to the world of spring integration , i am using spring integration jars of version 2.0.5 the xml one , now i have to design a program in which i have to send a message to a tibco queue named "rest.data" that is a tibco ems queue


now i have query please advise first is my below approach is correct in just sending a text message to jms queue


now for this what i have tries is that i have my below spring integration xml..



<?xml version="1.0" encoding="UTF-8"?>
<beans xmlns="http://ift.tt/GArMu6"
xmlns:xsi="http://ift.tt/ra1lAU"
xmlns:int="http://ift.tt/1eF5VEE"
xmlns:jms="http://ift.tt/TAOyvj"
xmlns:context="http://ift.tt/GArMu7"
xsi:schemaLocation="http://ift.tt/1iMF6wC http://ift.tt/1ofECj3
http://ift.tt/1eF5VEE http://ift.tt/TAOyvn
http://ift.tt/TAOyvj http://ift.tt/1reKI9Q
http://ift.tt/GArMu6 http://ift.tt/QEDs1e
http://ift.tt/GArMu7 http://ift.tt/QEDs1k">

<context:component-scan base-package="com.apress.prospringintegration" />

<int:poller id="poller" default="true" >
<int:interval-trigger interval="200"/>
</int:poller>



<int:channel id="input">
<int:queue capacity="10"/>
</int:channel>

<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://tcpert:33</prop>
<prop key="java.naming.security.principal">tre</prop>
<prop key="java.naming.security.credentials">tre</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>rest.data</value>
</property>
<property name="pubSubDomain">
<value>false</value>
</property>
<property name ="receiveTimeout">
<value>120000</value>
</property>
</bean>

<jms:outbound-channel-adapter channel="input" destination-name="rest.data" connection-factory="tibcoEMSConnFactory" />



</beans>


now my main java class is as shown below..



public class test {
public static void main(String[] args) {

try{
ApplicationContext context = new ClassPathXmlApplicationContext("jms-spring-context.xml");
MessageChannel input = (MessageChannel) context.getBean("input");
input.send(MessageBuilder.withPayload("Pro Spring Integration Example1")
.setHeader("type", "inventory")
.build());
}catch (Exception e){
e.printStackTrace();}

}

}

Aucun commentaire:

Enregistrer un commentaire