<?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:context="http://www.springframework.org/schema/context"
    xmlns:jms="http://www.springframework.org/schema/jms"
    xmlns:oxm="http://www.springframework.org/schema/oxm"    
    xsi:schemaLocation="http://www.springframework.org/schema/beans
                  	 http://www.springframework.org/schema/beans/spring-beans-4.0.xsd
                     http://www.springframework.org/schema/jee
                     http://www.springframework.org/schema/jee/spring-jee.xsd
                     http://www.springframework.org/schema/context http://www.springframework.org/schema/context/spring-context.xsd       
                     http://www.springframework.org/schema/mvc http://www.springframework.org/schema/mvc/spring-mvc.xsd 
                     http://www.springframework.org/schema/oxm  http://www.springframework.org/schema/oxm/spring-oxm.xsd
                     http://www.springframework.org/schema/jms classpath:org/springframework/jms/config/spring-jms-4.0.xsd         
                     ">

                     
              <!-- http://www.springframework.org:9898/jms/spring-jms-4.0.xsd -->
   <context:component-scan base-package="gov.va.med.pharmacy.jms" />
   
   <import resource="classpath*:persistence-context.xml"/>

	<bean
		class="org.springframework.beans.factory.config.PropertyPlaceholderConfigurer">
		<property name="location" value="classpath:inbound_erx_jndi.properties" />
	</bean>

	<bean id="jndiTemplate" 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">${jms.server.url}</prop>
				<prop key="java.naming.security.principal">${jms.user}</prop>
				<prop key="java.naming.security.credentials">${jms.user.pwd}</prop>
			</props>
		</property>

	</bean>

	<bean id="jndiConnectionFactory" class="org.springframework.jndi.JndiObjectFactoryBean">
		<property name="jndiTemplate" ref="jndiTemplate" />
		<property name="jndiName" value="${jms.connection.factory}" />
	</bean>

	<bean id="connectionFactory"
		class="org.springframework.jms.connection.CachingConnectionFactory">
		<property name="targetConnectionFactory" ref="jndiConnectionFactory" />
		<property name="sessionCacheSize" value="1" />
	</bean>

	<bean id="destinationResolver"
		class="org.springframework.jms.support.destination.JndiDestinationResolver">
		<property name="jndiTemplate" ref="jndiTemplate" />
		<property name="cache" value="true" />
		<property name="fallbackToDynamicDestination" value="false" />
	</bean>

   <!-- Message converter - automatically marshalls and unmarshalls messages using the provided marshaller / unmarshaller-->
   <bean id="inbERxMessageConverter" class="org.springframework.jms.support.converter.MarshallingMessageConverter">
          <property name="marshaller" ref="marshaller" />
          <property name="unmarshaller" ref="marshaller" />
     </bean>

   <!-- Spring's JAXB implementation of marshaller - provided a class the JAXB generated class -->
     <oxm:jaxb2-marshaller id="marshaller">
        <oxm:class-to-be-bound name="gov.va.med.pharmacy.ncpdpmsgs.MessageType" />
     </oxm:jaxb2-marshaller>


	<bean id="jmsTemplate" class="org.springframework.jms.core.JmsTemplate">
		<property name="connectionFactory" ref="connectionFactory" />
		<property name="destinationResolver" ref="destinationResolver" />
		<property name="defaultDestinationName" value="${jms.queue}" />
		<property name="pubSubDomain" value="false" />
		<property name="messageConverter" ref="inbERxMessageConverter" />
	</bean>	

	<bean id="messageListener" 	class="org.springframework.jms.listener.adapter.MessageListenerAdapter">
		<constructor-arg>
			<bean class="gov.va.med.pharmacy.jms.messaging.InboundMsgProcessor" />
		</constructor-arg>
		<property name="defaultListenerMethod" value="getERxMessage" />
		<property name="messageConverter"><null/></property>

	</bean>

   <!--  JMS consumer concurrency setting  min/max values -->
	<jms:listener-container connection-factory="connectionFactory"		destination-resolver="destinationResolver" concurrency="50-100">
		<jms:listener destination="${jms.queue}" ref="messageListener" />
	</jms:listener-container>

     <bean id="inboundMessageProducer" class="gov.va.med.pharmacy.jms.messaging.InboundMsgProducer">
		
	</bean>	

</beans>        

















