MassTransit声明我们应该使用接口来进行消息合同:
强烈建议根据多年来不同开发人员经验水平的经验,使用接口进行消息合同.MassTransit将为消息创建动态接口实现,确保消息合同与消费者的清晰分离.
来源:文档»使用MassTransit» 创建消息合同
使用POCO DTO而不是接口有什么缺点,在使用MassTransit进行消息传递的上下文中,接口与类之间的明显优势是什么?
另一方面,NServiceBus适用于POCO,确保不使用域对象等内部类是有意义的,见下文.
创建消息时,应遵循以下准则:
- 消息应该是简单的POCO对象.
- 消息应尽可能小.
- 消息应满足单一责任原则.
- 用于其他目的的类(例如域对象,数据访问对象和UI绑定对象)不应用作消息.
我在使用EventBus阅读GWT中的这个很酷的事件处理,到目前为止,我非常喜欢它.但是我什么时候应该使用它并没有真正掌握这个概念.每时每刻?我可以过度使用吗?我应该将它用于与事件相关的所有事情吗?(比如在MVP中的视图和演示者层之间进行通信?或者我可以将它与onMouseMove事件一起使用吗?它的重量级是多少?)
所以在一个问题中:EventBus在GWT中的作用究竟是什么?
几年来,我们org.bushe.swing.event.EventBus主要使用swing桌面应用程序.API非常一致且易于使用.但是现在新的要求已经得到了遏制,并且它需要一些EventSubscribers应该优先于其他的,因为它们是同步通知的.因此,这些订户需要某种优先级因素.
扩展EventBus以优先使用EventSubscribers不应该是一个很大的问题,但由于org.bushe.swing.event.EventBus已经过时,我不确定,如果更改EventBus实现可能更好.
org.bushe.swing.event.EventBus本身推荐GWT的GWT Eventbus等项目.我不确定,如果这也是摆动应用的好方法.您经常使用哪种EventBus实现?您是否知道支持订户优先级的简单实施?
在全球事件总线上使用Flux有什么优势?我认为调度员就是所需要的:
我在这里错过了什么,我不能没有Flux?
我试图取消注册时,在我的一个类中遇到以下错误.
java.lang.IllegalArgumentException:缺少带注释方法的事件处理程序.[DerivedClass]是否已在com.google.common.eventbus.EventBus.unregister(EventBus.java:227)注册?"
类调用unregister(this)具有公共@Subscribe注释方法.
我正在寻找Spring Boot和Reactor如何使用在独立容器中运行的一个公共/共享EventBus的多个应用程序(每个应用程序在自己的Spring Boot容器上运行).它是一个具有多个应用程序的微服务环境,每个应用程序都是专用的,应该在一系列事件中调用.
所以,我发现了Green Robots的eventbus模块.按照此页面上的说明尝试使其正常工作:http: //greenrobot.org/eventbus/documentation/how-to-get-started/
看起来很简单.
我输入了相应的代码,但是当在设备上运行时我遇到了崩溃:
org.greenrobot.eventbus.EventBusException: Subscriber class com.crowdlab.activities.LoadingActivity and its super classes have no public methods with the @Subscribe annotation.
Run Code Online (Sandbox Code Playgroud)
我班的前几行看起来像这样:
public class LoadingActivity extends BaseActivity implements AlertDialogButtonListener {
AlertDialog mDialog = null;
AlertDialog mPushDialog = null;
@Subscribe
public void onMessageEvent(MessageEvent event){
Toast.makeText(this, "From Loading "+event.message, Toast.LENGTH_SHORT).show();
}
@Override
public void onStart() {
super.onStart();
EventBus.getDefault().register(this);
}
@Override
public void onStop() {
EventBus.getDefault().unregister(this);
super.onStop();
}
.
.
.
Run Code Online (Sandbox Code Playgroud)
它/似乎/注释在那里.编译发生时没有发出警告.我正在使用gradle文件中指定的3.0.0版本...
那可能是什么错?(RTFM感激地接受了,只是告诉调频与相关文章的位置.)
谢谢!
-Ken
Android Studio 3.2 Canary 8
com.squareup:otto:1.3.8
io.reactivex:rxjava:1.3.7
kotlin 1.2.31
Run Code Online (Sandbox Code Playgroud)
我正在尝试使用otto EventBus将事件发送回我的活动.
但是,我正在使用RxJava执行一些后台工作,并且需要在第一个完成后发送事件.然而,在发布事件后.活动永远不会收到它.
此事件必须在主线程上执行此操作.RxJava位于IO线程上.我不确定最好的方法是什么:
这是我执行RxJava和EventBus帖子的交互器的代码
class Interactors(private val eventBus: Bus) {
fun transmitMessage(): Completable {
return insertTransmission()
.andThen(onTransmissionChanged()) /* Send event to the activity */
.andThen(requestTransmission())
}
private fun insertTransmission(): Completable {
return Completable.fromCallable {
Thread.sleep(4000)
System.out.println("insertTransmission doing some long operation")
}
}
private fun requestTransmission(): Completable {
return Completable.fromCallable {
Thread.sleep(2000)
System.out.println("requestTransmission doing some long operation")
}
}
/* Need to send this event back to the activity/fragment */
private …Run Code Online (Sandbox Code Playgroud) 如何从客户端应用程序(例如 NodeJS 应用程序、Angular 客户端或移动客户端应用程序)订阅 AWS Event Bus 事件?
2020 年 12 月,来自 AWS 营销部门的一封电子邮件介绍了使用事件驱动架构的优势。按照文档和教程,很快我就陷入了无法找到从客户端应用程序订阅此事件的方法的困境。
该电子邮件指出:
关注事件驱动架构的 4 个理由
您是否希望在没有延迟和依赖性的情况下扩展和构建强大的应用程序?我们详细介绍了事件驱动架构的基础知识、它们的工作原理,并向您展示了入门方法。了解事件驱动架构如何帮助您:
令人失望的是,没有任何库示例可以集成到客户端代码中来订阅这些事件。谷歌搜索不会返回任何重要结果,节点当前唯一的库:@aws-sdk/client-eventbridge-node仅公开发送和销毁方法。
我有点混淆的使用onEvent,onEventMainThread,onEventBackgroundThread和onEventAsync在Greenrobot的EventBus 3.0
从我在文档中看到的:
onEvent与ThreadMode.POSTING(默认)一起使用onEventMainThread 与...一起使用 ThreadMode.MAINonEventBackgroundThread 与...一起使用 ThreadMode.BackgroundThreadonEventAsync 与...一起使用 ThreadMode.ASYNC但是在事件从后台线程发布的情况下:
@Subscribe(threadMode = ThreadMode.MAIN)
public void onEventMainThread(MyEvent event) {
// some UI manipulation
}
Run Code Online (Sandbox Code Playgroud)
具有与以下完全相同的行为:
@Subscribe(threadMode = ThreadMode.MAIN)
public void onEvent(MyEvent event) {
// some UI manipulation
}
Run Code Online (Sandbox Code Playgroud)
和:
@Subscribe
public void onEventMainThread(MyEvent event) {
// some UI manipulation
}
Run Code Online (Sandbox Code Playgroud)
抛出,CalledFromWrongThreadException: Only the original thread that created a view hierarchy can touch …
java android event-bus greenrobot-eventbus greenrobot-eventbus-3.0
event-bus ×10
android ×3
java ×3
annotations ×1
aws-sdk ×1
c# ×1
flux ×1
guava ×1
gwt ×1
javascript ×1
kotlin ×1
masstransit ×1
reactjs ×1
reactjs-flux ×1
rx-java ×1
spring ×1
swing ×1