简体   繁体   English

在某些类型的消息中使用MDB池的最佳实践

[英]Best practices to use MDB pool with some types of message

将MDB与几种类型的消息一起使用,对多个消息使用多个队列,对一个类型的消息使用一个队列,或对具有不同激活规范选择器的所有类型使用一个队列并键入消息头的最佳实践是什么?

I think there are (as with anything) some trade-offs to think about: 我认为(和其他任何东西一样)需要考虑一些折衷:

Having a queue perform a single, well-defined function promotes good encapsulation, and allows your application to be as flexible and well encapsulated as possible. 让队列执行一个单一的,定义明确的功能可促进良好的封装,并使您的应用程序尽可能灵活且封装得好。 This would raise possibilities such as queue-specific thread pooling, so you can dedicate more resources to one message type, or ensure that long-running requests of once type don't block more urgent requests of another type. 这将增加诸如特定于队列的线程池之类的可能性,因此您可以将更多资源专用于一种消息类型,或者确保长期运行一次的请求不会阻塞另一种紧急的请求。

On the other hand, adding a queue uses system resources, so having too many queues may be inefficient (although you'd need a lot before this is noticeable), or confusing if it makes it difficult to identify the correct queue for a particular message type. 另一方面,添加队列会占用系统资源,因此队列过多可能会导致效率低下(尽管在此之前您需要大量资源才能引起注意),或者如果难以识别特定消息的正确队列,则会造成混乱类型。

One EIP which is worth considering is the command pattern - this uses a single queue to perform multiple actions. 一个值得考虑的EIP是命令模式 -它使用一个队列执行多个操作。 It's also worth bearing in mind the facade pattern - even if your application is internally using a number of different queues, you might prefer to use a facade to present this from client systems. 值得牢记的是Facade模式 -即使您的应用程序内部使用了许多不同的队列,您也可能更喜欢使用Facade从客户端系统中呈现出来。

声明:本站的技术帖子网页,遵循CC BY-SA 4.0协议,如果您需要转载,请注明本站网址或者原文地址。任何问题请咨询:yoyou2525@163.com.

 
粤ICP备18138465号  © 2020-2024 STACKOOM.COM