En esta oportunidad mostraré como realizar un Mapping mediante SPRING, para el manejo de lanzamiento de mensajes 'JMS' y para su respectiva recepción de dichos mensajes 'JMS' mediante 'MDP' (Message Driven Pojos).
El mapping mostrado a continuación hace referencia al manejo de dos colas JMS para ello es requerido crea lo siguiente:
- 1 JNDI TEMPLATE
- 2 JNDI FACTORY
- 1 JDNI DESTINATION RESOLVER
- 2 JDNI DESTINATION (por cada cola)
- 2 JMS TEMPLATE
- 2 JMS MDP
- 2 JMS LISTENER
[?xml version="1.0" encoding="UTF-8" ?]
[beans xmlns="http://www.springframework.org/schema/beans"
xmlns:xsi="http://www.w3.org/2001/XMLSchema-instance"
xmlns:jee="http://www.springframework.org/schema/jee"
xmlns:aop="http://www.springframework.org/schema/aop"
xmlns:context="http://www.springframework.org/schema/context"
xmlns:util="http://www.springframework.org/schema/util"
xsi:schemaLocation="http://www.springframework.org/schema/beans
http://www.springframework.org/schema/beans/spring-beans-3.0.xsd
http://www.springframework.org/schema/aop
http://www.springframework.org/schema/aop/spring-aop-3.0.xsd
http://www.springframework.org/schema/context
http://www.springframework.org/schema/context/spring-context-3.0.xsd
http://www.springframework.org/schema/jee
http://www.springframework.org/schema/jee/spring-jee-3.0.xsd
http://www.springframework.org/schema/util
http://www.springframework.org/schema/util/spring-util-3.0.xsd" ]
[!-- ************** [JNDI TEMPLATE] ************** --]
[bean id="idTemplateJDNI"
class="org.springframework.jndi.JndiTemplate" ]
[property name="environment" ]
[props]
[prop key="java.naming.factory.initial" ]weblogic.jndi.WLInitialContextFactory[/prop]
[prop key="java.naming.provider.url" ]t3://localhost:7001[/prop]
[/props]
[/property]
[/bean]
[!-- **************** [JNDI FACTORY] *************** --]
[bean id="idConnectionFactoryJDNI"
class="org.springframework.jndi.JndiObjectFactoryBean" ]
[property name="jndiTemplate" ref="idTemplateJDNI" /]
[property name="lookupOnStartup" value="false" /]
[property name="cache" value="true" /]
[property name="jndiName" value="dummy.javaman.jms.factory" /]
[property name="proxyInterface" value="javax.jms.ConnectionFactory" /]
[/bean]
[!-- ********* [JDNI DESTINATION RESOLVER] ********* --]
[bean id="idDestinationResolverJNDI"
class="org.springframework.jms.support.destination.JndiDestinationResolver" ]
[property name="jndiTemplate" ref="idTemplateJDNI" /]
[property name="cache" value="true" /]
[/bean]
[!-- ************* [JDNI DESTINATION] ************** --]
[bean id="idDestination_01"
class="org.springframework.jndi.JndiObjectFactoryBean" ]
[property name="jndiName" value="jms.jndi.queue" /]
[/bean]
[bean id="idDestination_02"
class="org.springframework.jndi.JndiObjectFactoryBean" ]
[property name="jndiName" value="jms.jndi.auxiliar" /]
[/bean]
[!-- **************** [JMS TEMPLATE] *************** --]
[bean id="idTemplateJMS_01"
class="org.springframework.jms.core.JmsTemplate" ]
[property name="connectionFactory" ref="idConnectionFactoryJDNI" /]
[property name="destinationResolver" ref="idDestinationResolverJNDI" /]
[property name="defaultDestination" ref="idDestination_01" /] [!-- COLA #1 --]
[property name="sessionAcknowledgeModeName" value="CLIENT_ACKNOWLEDGE" /]
[property name="sessionTransacted" value="true" /]
[/bean]
[bean id="idTemplateJMS_02"
class="org.springframework.jms.core.JmsTemplate" ]
[property name="connectionFactory" ref="idConnectionFactoryJDNI" /]
[property name="destinationResolver" ref="idDestinationResolverJNDI" /]
[property name="defaultDestination" ref="idDestination_02" /] [!-- COLA #2 --]
[property name="sessionAcknowledgeModeName" value="CLIENT_ACKNOWLEDGE" /]
[property name="sessionTransacted" value="true" /]
[/bean]
[!-- ****************** [JMS MDP] ****************** --]
[bean id="idClaseJmsMessageListener_01"
class="pe.com.javaman.dummy.servicioLlamadasWS.jms.ServicioLlamadasMDP_A" ] [!-- PARA RECEPCIÓN [ASINCRONA] DE LA COLA --]
[/bean]
[bean id="idClaseJmsMessageListener_02"
class="pe.com.javaman.dummy.servicioLlamadasWS.jms.ServicioLlamadasMDP_B" ] [!-- PARA RECEPCIÓN [ASINCRONA] DE LA COLA --]
[/bean]
[!-- **************** [JMS LISTENER] *************** --]
[bean id="idListenerJMS_01"
class="org.springframework.jms.listener.SimpleMessageListenerContainer" ]
[property name="connectionFactory" ref="idConnectionFactoryJDNI" /]
[property name="destination" ref="idDestination_01" /] [!-- COLA #1 --]
[property name="messageListener" ref="idClaseJmsMessageListener_01" /]
[/bean]
[bean id="idListenerJMS_02"
class="org.springframework.jms.listener.SimpleMessageListenerContainer" ]
[property name="connectionFactory" ref="idConnectionFactoryJDNI" /]
[property name="destination" ref="idDestination_02" /] [!-- COLA #2 --]
[property name="messageListener" ref="idClaseJmsMessageListener_02" /]
[/bean]
[/beans]
Esto sería todo nos vemos.
No hay comentarios:
Publicar un comentario