Spring

Is there a way to limit the maximum number of processing records in a Job of Spring Batch?

十年热恋 提交于 2021-02-10 14:32:24
问题 Is there a way to limit the maximum number of processing records in a job of Spring Batch? I need to have a configuration by which I could control the maximum number of records that can be processed by a job. The job is reading from Database using a Stored Procedure, I could limit the maximum number of fetched rows in the Procedure itself, but I am looking for any features provided in Spring Batch for that and I am not able to find it yet. 回答1: Write a custom ItemReader holds record count and

Is there a way to limit the maximum number of processing records in a Job of Spring Batch?

拈花ヽ惹草 提交于 2021-02-10 14:30:09
问题 Is there a way to limit the maximum number of processing records in a job of Spring Batch? I need to have a configuration by which I could control the maximum number of records that can be processed by a job. The job is reading from Database using a Stored Procedure, I could limit the maximum number of fetched rows in the Procedure itself, but I am looking for any features provided in Spring Batch for that and I am not able to find it yet. 回答1: Write a custom ItemReader holds record count and

How to get Step Name and Step Execution ID in ItemReadListener?

和自甴很熟 提交于 2021-02-10 14:14:24
问题 My Spring Batch job uses a FlatFileItemReader to read .csv files. To implement error handling, I created a custom ItemReadListener and provided an overridden onReadError implementation. Here, I'd like access to the StepName and StepExecutionId from which the error was thrown (i.e. at the reader level). Can I access the StepExecution in the my custom listener? When I try to inject it into any method or constructor, I get a "No beans of type StepExecution found" error. Thanks. 回答1: Try with the

Spring Boot Maven multi module project with profile - packages from other module not found

情到浓时终转凉″ 提交于 2021-02-10 13:26:48
问题 I'm currently try to structure my Spring Boot Maven application with multiple pom files. I have two applications which needs to share a lot of classes. I have the following structure: . ├── application1 | |── src │ └── pom.xml |── application2 | |── src │ └── pom.xml |── shared | └── src | └── pom.xml | └── pom.xml The pom in the root directory looks like this: <?xml version="1.0" encoding="UTF-8"?> <project xmlns="http://maven.apache.org/POM/4.0.0" xmlns:xsi="http://www.w3.org/2001/XMLSchema

“科班出身”的程序员和“培训出身”的程序员的大型辩论(甩锅)现场

左心房为你撑大大i 提交于 2021-02-10 13:25:42
每天早上七点三十,准时推送干货 前几天阿粉说阿粉最近换了公司,而且入职之后干掉了公司里面的测试数据库的事情,而接下来的事就比较有意思了,来自“科班出身”的哥们和来自“培训出身”的我的大型辩论(SIBI)现场,也不能说是通俗的甩锅,但是确实有那么点意味。 现场一 “科班程序员”:这功能很好实现呀,直接写几个嵌套for循环,在里面判断一下就行了,直接返回数据就行了,为啥你这写的这么墨迹呢? “培训程序员”:内心OS:嵌套for?再加上几个if,你确定你的数据超过1w条,没有明显的延迟么?于是,只能告诉他,兄弟,这么写肯定是没什么问题,但是你不想一下后期怎么维护么?你这才一两万的数据我都能感觉出明显的延迟了,为啥不能优化一下呢? 说实话,说到这个问题的时候,也避免不了被大家diss,觉得这不是科班出身的程序员能写出来的代码,而事实情况确实是这个样子的,也可能是工作经验不太足,所以很多代码写的不是很给力,也可能是之前的公司做过几次 CodeReview,所以每次在写完代码之后都习惯性的去考虑一下这个代码还能不能优化的更加简单一点,所以考虑的时间要稍微长一点。 于是,兄弟就开始和我较真了,阿粉的策略一直很简单,兄弟,你自己写个三个for循环,然后去看看你执行完这个循环的时间,然后想想如果在循环中加入查询数据库的所有的操作,你再想想怎么处理,就比如说

Spring Cloud Stream topic per message for different consumers

為{幸葍}努か 提交于 2021-02-10 12:49:13
问题 The topology I am looking for is So far I have not seen a way to define the topic per message in Cloud Stream. I understand that the consumers will be bound to specific topic but how does the producer sets the topic per message before sending the message to the exchange? source.output().send(MessageBuilder.withPayload(myMessage).build()); Does not provide any way to set the topic for the exchange to route to the proper consumer. Or maybe I don't understand something correctly? UPDATE I would

Spring Cloud Stream topic per message for different consumers

99封情书 提交于 2021-02-10 12:49:11
问题 The topology I am looking for is So far I have not seen a way to define the topic per message in Cloud Stream. I understand that the consumers will be bound to specific topic but how does the producer sets the topic per message before sending the message to the exchange? source.output().send(MessageBuilder.withPayload(myMessage).build()); Does not provide any way to set the topic for the exchange to route to the proper consumer. Or maybe I don't understand something correctly? UPDATE I would

Spring boot with H2 Database auto create

假装没事ソ 提交于 2021-02-10 12:43:03
问题 I am using embeded H2 in my java application via spring boot. Currently, it creates(overrides) my tables in the DB. But once I push it to production I do not want my tables to be wiped off and recreated, so I wont lose the previous datas in the tables. But I am not sure how to accomplish this. Not sure what to put on the line spring.jpa.hibernate.ddl-auto=create . I tried validate and other options but did not work out. Here is my application.properties. Thanks spring.jpa.generate-ddl=true

Spring boot with H2 Database auto create

余生颓废 提交于 2021-02-10 12:42:35
问题 I am using embeded H2 in my java application via spring boot. Currently, it creates(overrides) my tables in the DB. But once I push it to production I do not want my tables to be wiped off and recreated, so I wont lose the previous datas in the tables. But I am not sure how to accomplish this. Not sure what to put on the line spring.jpa.hibernate.ddl-auto=create . I tried validate and other options but did not work out. Here is my application.properties. Thanks spring.jpa.generate-ddl=true

Can we use Web-Sockets for Communication between Microservices?

穿精又带淫゛_ 提交于 2021-02-10 12:33:06
问题 We have a use case where we have two microservices, Microservice A pushes a long-running task to Microservice B . Microservice B starts processing the task and keeps updating the status of the task. Now Microservice A has to constantly poll Microservice B for an update on the status of the task. We don't have queues in our current setup. So, We thought of creating a web socket between Microservice A and Microservice B so that Microservice B can push the status updates to Microservice A .