Commit 0f302dad39b52961b57e3e5728e94c7a7cc458df
1 parent
3850fbd3
1.加入kafka传电子路单至数据中台
Showing
3 changed files
with
18 additions
and
5 deletions
src/main/java/com/bsth/entity/ScheduleRealInfoVo.java
| ... | ... | @@ -154,12 +154,10 @@ public class ScheduleRealInfoVo implements Serializable{ |
| 154 | 154 | /** 关联的公司名称 */ |
| 155 | 155 | private String gsName; |
| 156 | 156 | /** 关联的公司编码 */ |
| 157 | - @JsonIgnore | |
| 158 | 157 | private String gsBm; |
| 159 | 158 | /** 关联的分公司名称 */ |
| 160 | 159 | private String fgsName; |
| 161 | 160 | /** 关联的分公司编码 */ |
| 162 | - @JsonIgnore | |
| 163 | 161 | private String fgsBm; |
| 164 | 162 | /** 出场顺序号 */ |
| 165 | 163 | @JsonIgnore | ... | ... |
src/main/java/com/bsth/server_rs/schedule/real/ScheduleRealService.java
| ... | ... | @@ -33,8 +33,11 @@ import org.springframework.beans.BeanUtils; |
| 33 | 33 | import org.springframework.beans.factory.InitializingBean; |
| 34 | 34 | import org.springframework.beans.factory.annotation.Autowired; |
| 35 | 35 | import org.springframework.kafka.core.KafkaTemplate; |
| 36 | +import org.springframework.kafka.support.SendResult; | |
| 36 | 37 | import org.springframework.messaging.Message; |
| 37 | 38 | import org.springframework.stereotype.Component; |
| 39 | +import org.springframework.util.concurrent.ListenableFuture; | |
| 40 | +import org.springframework.util.concurrent.ListenableFutureCallback; | |
| 38 | 41 | |
| 39 | 42 | import javax.ws.rs.*; |
| 40 | 43 | import javax.ws.rs.core.MediaType; |
| ... | ... | @@ -331,12 +334,24 @@ public class ScheduleRealService implements InitializingBean { |
| 331 | 334 | ObjectMapper mapper = new ObjectMapper(); |
| 332 | 335 | String json = mapper.writeValueAsString(data); |
| 333 | 336 | logger.info(json); |
| 334 | - kafkaTemplate.send("PDGJ_JQDD", json); | |
| 337 | + ListenableFuture<SendResult<String, String>> future = kafkaTemplate.send("PDGJ_JQDD", json); | |
| 338 | + future.addCallback(new ListenableFutureCallback<SendResult<String, String>>() { | |
| 339 | + | |
| 340 | + @Override | |
| 341 | + public void onSuccess(SendResult<String, String> result) { | |
| 342 | + | |
| 343 | + } | |
| 344 | + | |
| 345 | + @Override | |
| 346 | + public void onFailure(Throwable ex) { | |
| 347 | + logger.error("kafka发送电子路单异常", ex); | |
| 348 | + } | |
| 349 | + }); | |
| 335 | 350 | } |
| 336 | 351 | } catch (Exception e) { |
| 337 | 352 | logger.error("kafka发电子路单调度异常", e); |
| 338 | 353 | } |
| 339 | 354 | } |
| 340 | - }, 1, 4, TimeUnit.MINUTES); | |
| 355 | + }, 30, 240, TimeUnit.SECONDS); | |
| 341 | 356 | } |
| 342 | 357 | } | ... | ... |
src/main/resources/application-prod.properties
| ... | ... | @@ -30,7 +30,7 @@ spring.redis.password=bsth_control_001 |
| 30 | 30 | spring.redis.port=28008 |
| 31 | 31 | |
| 32 | 32 | #kafka |
| 33 | -spring.kafka.bootstrap-servers=106.54.221.120:9092 | |
| 33 | +spring.kafka.bootstrap-servers=47.102.42.244:9092 | |
| 34 | 34 | spring.kafka.producer.key-serializer=org.apache.kafka.common.serialization.StringSerializer |
| 35 | 35 | spring.kafka.producer.value-serializer=org.apache.kafka.common.serialization.StringSerializer |
| 36 | 36 | spring.kafka.producer.buffer-memory=33554432 | ... | ... |