Announcement Announcement Module
Collapse
No announcement yet.
My service acivator is working in a weird way Page Title Module
Move Remove Collapse
X
Conversation Detail Module
Collapse
  • Filter
  • Time
  • Show
Clear All
new posts

  • My service acivator is working in a weird way

    Hi.
    Ive got a table in which I get data trough a jdbc:inbound-channel-adapter using a poller I get data and update the table so it wont get the previous data selected, periodically. The problem is that when my data reaches my service activator and I insert the retrieved data into a new table because it comes repeated Im getting sql exception for violation of keys. At first I tought that I wasnt updating my old data fast enough, but it doesnt seem to be the case.
    Any way here are my 2 spring context:

    In this context Im just getting the data and updating the table so it wont get the old data twice.
    Code:
    <?xml version="1.0" encoding="UTF-8"?>
    <beans xmlns="http://www.springframework.org/schema/beans"
    	xmlns:context="http://www.springframework.org/schema/context"
    	xmlns:xsi="http://www.w3.org/2001/XMLSchema-instance" xmlns:i="http://www.springframework.org/schema/integration"
    	xmlns:jdbc="http://www.springframework.org/schema/integration/jdbc"
    	xmlns:task="http://www.springframework.org/schema/task"
    	xsi:schemaLocation="http://www.springframework.org/schema/jdbc http://www.springframework.org/schema/jdbc/spring-jdbc.xsd
    		http://www.springframework.org/schema/integration http://www.springframework.org/schema/integration/spring-integration.xsd
    		http://www.springframework.org/schema/integration/jdbc http://www.springframework.org/schema/integration/jdbc/spring-integration-jdbc.xsd
    		http://www.springframework.org/schema/task http://www.springframework.org/schema/task/spring-task.xsd
    		http://www.springframework.org/schema/beans http://www.springframework.org/schema/beans/spring-beans.xsd
    		http://www.springframework.org/schema/context http://www.springframework.org/schema/context/spring-context-3.0.xsd">
    
    	<context:annotation-config />
    
    	<context:property-placeholder location="file:${vucem_home}/conf/vucem/database.properties" />
    
    	<bean id="dataSourceBroker" class="oracle.jdbc.pool.OracleDataSource" destroy-method="close" >
    	    <property name="URL" value="jdbc:oracle:thin:@${database.repositorio.ip}:${database.repositorio.port}:${database.repositorio.sid}"/>
            <property name="user" value="${database.repositorio.user}"/>
            <property name="password" value="${database.repositorio.password}"/>
            <property name="connectionCachingEnabled" value="true"/>
        </bean>
    
    	<bean id="ediMapper" class="com.praxis.desvucem.common.jdbc.EDIRepositorioMapper" />
    
    	<bean id="trigerConsulta" class="org.springframework.scheduling.support.PeriodicTrigger">
    		<constructor-arg name="period" value="30000"/>
    		<property name="initialDelay" value="12000"/>
    	</bean>
    
    	<jdbc:inbound-channel-adapter id="consultaEDIsTransmitir" update="update edi_repositorio set EDI_PROCESADO=1 where EDI_ID in(:id)" channel="consultarEdiRepositorio" data-source="dataSourceBroker"
    					query="select edi.EDI_ID,EDI_TIPO, edi.EDI_VERSION, edi.EDI_TX, edi.EDI_RX, edi.EDI_FECHA_MQ, edi.EDI_FECHA_EDI, edi.EDI_FECHA_PROCESO, edi.EDI_ARCHIVO_ORIG, edi.EDI_ARCHIVO_XML.getCLOBVal() as EDI_ARCHIVO_XML, edi.EDI_CONTROL, edi.EDI_PROCESADO, edi.EDI_TRANSMITIDO
    						   from EDI_REPOSITORIO edi where edi.EDI_PROCESADO = 0 and  edi.EDI_RX is null" row-mapper="ediMapper" max-rows-per-poll="100">
    		<i:poller trigger="trigerConsulta"/>
    	</jdbc:inbound-channel-adapter>
    
    	<i:splitter id="splitEdisProcesar" input-channel="consultarEdiRepositorio" output-channel="EDIProcesar"/>
    
    	<i:publish-subscribe-channel id="consultarEdiRepositorio"/>
    </beans>
    in the next context Im passing the retrieved data through a series of channels so in the end it finally arrives into my service activator.
    Code:
    <?xml version="1.0" encoding="UTF-8"?>
    <beans xmlns="http://www.springframework.org/schema/beans"
    	xmlns:context="http://www.springframework.org/schema/context"
    	xmlns:xsi="http://www.w3.org/2001/XMLSchema-instance" xmlns:i="http://www.springframework.org/schema/integration"
    	xmlns:jdbc="http://www.springframework.org/schema/integration/jdbc"
    	xmlns:task="http://www.springframework.org/schema/task"
    	xsi:schemaLocation="http://www.springframework.org/schema/jdbc http://www.springframework.org/schema/jdbc/spring-jdbc.xsd
    		http://www.springframework.org/schema/integration http://www.springframework.org/schema/integration/spring-integration.xsd
    		http://www.springframework.org/schema/integration/jdbc http://www.springframework.org/schema/integration/jdbc/spring-integration-jdbc.xsd
    		http://www.springframework.org/schema/task http://www.springframework.org/schema/task/spring-task.xsd
    		http://www.springframework.org/schema/beans http://www.springframework.org/schema/beans/spring-beans.xsd
    		http://www.springframework.org/schema/context http://www.springframework.org/schema/context/spring-context-3.0.xsd">
    
    	<context:annotation-config />
    
    	<i:publish-subscribe-channel id="EDIProcesar" />
    
    	<i:router id="EdiProcesamientoRouter" input-channel="EDIProcesar"
    		resolution-required="false" expression="payload.tipo"
    		default-output-channel="defaultChannel">
    		<i:mapping value="997" channel="procesar997" />
    	</i:router>
    
    	<i:publish-subscribe-channel id="procesar997" />
    
    	<i:publish-subscribe-channel id="defaultChannel" />
    
    	<i:service-activator input-channel="procesar997"
    		ref="servicioEDI997" method="execute" />
    </beans>
    For some reason in my log I get channel procesar997 has 1 suscriber then a couple of seconds later I get
    channel procesar997 has 2 suscribers.

    Does anyone knows how to stop spring from getting the same data twice?

    Thanks in advance.

  • #2
    Is it possible you are importing the second file twice?

    If you turn on DEBUG level logging for "org.springframework" you will see lots of debugging information as the context is parsed and beans are created. This should point out what's happening.

    If you can't figure it out, attach the log here, up to and including where you see "channel procesar997 has 2 suscribers".

    Comment


    • #3
      I found that my last 2 channels that are parallel (after my router) were publisher subscriber, so I change them to regular channel and that fixed my problem. Altough Im still not sure why.

      Comment

      Working...
      X