小编Eik*_*nds的帖子

Spring-Kafka vs. Spring-Cloud-Stream(Kafka)

使用Kafka作为微服务架构中的消息传递系统,使用spring-kafka与spring-cloud-stream + spring-cloud-starter-stream-kafka有什么好处?

Spring云流框架支持更多的消息传递系统,因此具有更多的模块化设计.但功能呢?spring-kafka和spring-cloud-stream + spring-cloud-starter-stream-kafka的功能之间是否存在差距?哪个API设计得更好?

期待阅读您的意见

spring spring-integration spring-cloud-stream spring-kafka

16
推荐指数
2
解决办法
4403
查看次数

Spring Kafka中的事务同步

我想将kafka事务与存储库事务同步:

@Transactional
public void syncTransaction(){
  myRepository.save(someObject)
  kafkaTemplate.send(someEvent)
}
Run Code Online (Sandbox Code Playgroud)

由于合并(https://github.com/spring-projects/spring-kafka/issues/373)和根据文档,这是可能的。但是,我在理解和实现该功能时遇到了问题。查看https://docs.spring.io/spring-kafka/reference/htmlsingle/#_transaction_synchronization中的示例,我必须创建一个MessageListenerContainer来侦听我自己的事件。我还需要使用KafkaTemplate发送事件吗?MessageListenerContainer是否禁止发送到代理?

如果我正确理解kafkaTemplate和kafkaTransactionManager必须使用同一生产者工厂,则必须在其中启用Transaction设置transactionIdPrefix。在我的示例中,我必须将messageListenerContainer的TransactionManager设置为DataSourceTransactionManager。那是对的吗?

从我的角度来看,我通过kafkaTemplate发送事件,听我自己的事件并再次使用kafkaTemplate转发事件看起来很奇怪。

如果我能得到一个简单的示例,说明如何将kafka事务与存储库事务进行同步,并提供解释,我将为我提供帮助。

spring-transactions spring-kafka

7
推荐指数
2
解决办法
8220
查看次数

模型驱动/反应表单:从模型到FormGroup的自动映射?

有没有办法从模型中自动创建FormGroup?如果我有一个具有多个属性的模型:

型号:人

firstName: string,
lastName: string,
street: string
country: string
....
Run Code Online (Sandbox Code Playgroud)

我想从中创建一个简单的FormGroup:

表格:FormGroup

firstName: FormControl,
lastName: FormControl,
street: FormControl,
country: FormControl
....
Run Code Online (Sandbox Code Playgroud)

对我来说似乎是"脏"的,为模型中的每个属性明确定义FormControl/FormGroup/FormArray:

formBuilder.group({
  firstName: person.firstName,
  lastName: person.lastName,
  street: person.street,
  country: person.country,
  ...
});
Run Code Online (Sandbox Code Playgroud)

每次来自后端的API发生变化时,我都要调整模型和表单映射.是否有某种生成器可以帮助我自动映射/创建FormGroup?

validation typescript angular2-forms angular2-template angular

5
推荐指数
1
解决办法
1452
查看次数

Angular 2:是否可以使用具有不同子组件的相同父组件?

我想知道是否可以定义父组件而不指定使用哪个子组件?

通常我会创建一个父组件并在html文件中使用子组件的选择器

母体组分-1.HTML:

//some logic
<child-component-1-selector></child-component-1-selector>
//some logic
Run Code Online (Sandbox Code Playgroud)

如果我遵循这种方法,我必须定义我想使用哪种子组件.但是,如果我想多次使用父组件与不同的子组件,我必须复制逻辑部分并创建单独的父组件:

母体组分-1.HTML:

//some logic
<child-component-1-selector></child-component-1-selector>
//some logic
Run Code Online (Sandbox Code Playgroud)

母体组分-2.HTML:

//some logic (same as above)
<child-component-2-selector></child-component-2-selector>
//some logic (same as above)
Run Code Online (Sandbox Code Playgroud)

我不喜欢这种方法,因为我会生成代码重复.有没有办法定义父组件而不指定要呈现的子组件,只是将子组件"传递"为参数?

当前方法,grand-parent-component.html:

<parent-component-1></parent-component-1>
<parent-component-2></parent-component-2>
Run Code Online (Sandbox Code Playgroud)

建议的方法,grand-parent-component.html:

<parent-component-selector [childcomponent] = "child-component-1"></parent-component-selector>
<parent-component-selector [childcomponent] = "child-component-2"></parent-component-selector>
Run Code Online (Sandbox Code Playgroud)

我希望我已经清楚地了解了我的"问题".也许你们可以帮助我并就最佳实践提出建议

angularjs angular

3
推荐指数
1
解决办法
700
查看次数