Need clarification on JMS vs ActiveMQ bean/resource configuration

此生再无相见时 提交于 2019-11-29 11:01:28

Yes, every application server does things a bit differently. More importantly, they do it differently not on how you configure it - that part is simple, but on the runtime behavior when you expect from the JMS server an SLA such as ordered message processing - even in the case of failure.

For example, if you have a business critical process wheren Message 2 can only be processed after Message 1. And your message 1 fails, and you want to be retried, but you also have configured a redelivery delay of 200 ms. Some application servers, will by default think: message 1 failed, I retry it in 200 ms, jumpt to next message ... And kabum, business process is dead because your expecation of ordered message consumption was just violated.

Normally, good JMS servers offer the ability to configure it in such a way that you can meet your required SLA ... but it is tricky.

As a rule, you should configured on your MDB through annotations, any property that is cross cutingly working accross multiple application servers. Normally, the JNDI naming can work - but it is tricky, because the JNDI is highly container dependent. Properties such as: - Activation Propertu: destinationType = javax.jms.Topic

This is quite quite standard, so you can just put it through annotation.

But then when you come to the tricky aspects, such as specifying the connection factory to connect to the destination. Or should you allow the JMS server to batch read N messages at once, or do you want to force it one-at a time, etc... This is highly dependent on your container, and you will want to configure this not through annotation by by the ejb deployment descriptor.

For example, in weblogic, you would want to use: weblogic-ejb-jar.xml To fine tune thing such as JNDI name to access the queue, max-beans-in-free-pool etc...

In Wildfly, where ActiveMQ is used, you would want ot use the: jboss-ejb3.xml

Deployment descriptor to do this.

So, through annotations - you should the greates common denominator of cross cutingly equivalent metadata across container. In the deployment descriptor, you enrich the configuration with the lacking metadata.

The good application servers, will always be doing a merge process where they combine the Metadata on the MDB with the metadata on the deployment descriptor. And when there is a collision, they take over the configuration on the deployment descriptor.

And so on.

So somethings, you really need to adjust pert container in the container supported deployment descriptor. In your java code, you should only keep the metadata that is cross cutingly compatible.

And finally, getting the exact JMS behavior for message handling accross different application servers that use different JMS server implementations ... is quite quite tricky.

Unless you have the basic scneario that does not care about ordered processing, you have multiple MDBs running in parallel on a queue because there is not happens before relationship... then it is trivial to get a slopy configuration to work.

It appears that all servers do it a little differently.

易学教程内所有资源均来自网络或用户发布的内容,如有违反法律规定的内容欢迎反馈
该文章没有解决你所遇到的问题?点击提问,说说你的问题,让更多的人一起探讨吧!