Announcement Announcement Module
Collapse
No announcement yet.
Spring file integration issue Page Title Module
Move Remove Collapse
X
Conversation Detail Module
Collapse
  • Filter
  • Time
  • Show
Clear All
new posts

  • Spring file integration issue

    I am new to File Integration. We are using Spring+SpringBatch to poll a file and process the file . This used to work for sometime and now we see issues with it.

    Below is my code
    Code:
    	<bean id="masterTrigger" class="org.springframework.scheduling.support.PeriodicTrigger">
    		<constructor-arg value="10" />
    		<property name="fixedRate" value="true" />
    	</bean>
    
    	<!-- GCA Audit Records File Poller Starts -->
    	<file:inbound-channel-adapter channel="fileIn"
    		directory="/home/tranftp/gca/auditrecords/gca/" filename-regex="(?i)(RTS).*.IDX"
    		prevent-duplicates="false">
    		<int:poller trigger="masterTrigger" />
    	</file:inbound-channel-adapter>
    
    	<int:service-activator input-channel="fileIn" ref="inboundFileProcessor" />
    
    	<bean id="inboundFileProcessor"
    		class="com.test.batch.integration.InboundFileProcessor">
    		<property name="jobLauncher" ref="jobLauncher" />
    		<property name="jobRegistry" ref="jobRegistry" />
    		<property name="fileToJobMap">
    			<map>
    				<entry key="(?i)(RTS).*.IDX">
    					<list>
    						<value>gcaAuditBatchJob</value>
    						<value>/home/tranftp/BatchFiles/gca/</value>
    					</list>
    				</entry>
    			</map>
    		</property>
    	</bean>
    As soon as I copy a file to configured landingZone , the file moves to archived location but do not trigger the job to process the file .Not sure what's happening and I am clueless about where to start .Does the ServiceActivator performs any kind of caching of previous tasks
    Below is the ServiceActivator code .

    Code:
    	@ServiceActivator
        public void onNewFileArrival(
                @Headers Map<String, Object> headers,
                @Payload File file) throws Exception {
    
    		String filePath = file.getAbsolutePath();
    		Date fileLastModified = new Date(file.lastModified());
    		long fileSize = file.length() / 1000;
    		logger.info("A new file has arrived at: " + filePath + ", last modified: " + fileLastModified + ", size: " + fileSize + "KB");
    		String jobName = null;
    		String destPath = null;
    		for(String key:fileToJobMap.keySet()) {
    			if(file.getName().matches(key)) {
    				jobName = fileToJobMap.get(key).get(0);
    				destPath = fileToJobMap.get(key).get(1);
    				break;
    			}
    		}
    		if(jobName != null && destPath != null) {
    	        logger.info("destPath: " + destPath);
    	        // File Monitoring
    			FileMonitoring fileMonitoring = new FileMonitoring();
    			
    		    fileMonitoring.setFileName(filePath);
    		    fileMonitoring.setFileTime(fileLastModified);
    		    fileMonitoring.setFileStatus(FileMonitoring.FILE_STATUS_RECEIVED);
    		    fileMonitoring.setJobName(jobName);
    			destPath = FTPUtil.archiveFile(filePath, destPath, "yyMMddHHmmss", false, true);
    			 fileMonitoring.setDestPath(destPath);
    	        logger.info("Kicking off job: " + jobName + " with file: " + destPath);
                Job job = jobRegistry.getJob(jobName);
                JobParameters jobParameters = new JobParametersBuilder().addDate("schedule.time", DateUtil.getAppDate()).toJobParameters();
                jobParameters = new JobParametersBuilder(jobParameters).addString("fileName", destPath).toJobParameters();
                JobExecution jobExec = jobLauncher.run(job, jobParameters);
    We do not see any exceptions in logs
    Its extremely Urgent , help appreciated .
    Last edited by SaratKumarM; Jan 28th, 2013, 05:06 AM.

  • #2
    Anybody please reply since its an urgent issue.

    Comment


    • #3
      No, there is no caching. I suggest you turn on DEBUG level logging for 'org.springframework.integration' and you should see exactly what's happening.

      Comment


      • #4
        Hi!

        In additions: I recommend to add INFO level logging for org.springframework.batch' too.
        However: how your ServiceActivator behaves, when you travel through DEBUG on it line by line?

        Take care,
        Artem

        Comment

        Working...
        X