Overall, it is a very cool model that does allow for some pretty impressive and standard extension to any compliant Java EE platform. It is, however, incredibly underused. With a few changes to the model, it could be made to support even things like JAX-RS. Let's break it down.
The touchpoints between the Connector and the MDB are the ActivationSpec/ActivationConfig and the MessageListener interface. Using a fictitious "Email" Connector idea, let's see how this looks.
EmailConsumer (MessageListener) interface*
package org.superemail.connector;
// other imports...
public interface EmailConsumer {
public void receiveEmail(Properties headers, String body);
}
EmailAccountInfo (ActivationSpec) class
package org.superemail.connector;
/**
* This class is basically an old-style JavaBean with get/set for each property
*/
public class EmailAccountInfo implements javax.resource.spi.ActivationSpec {
private String address;
public String getAddress() {
return address;
}
public void setAddress(String address) {
this.address = address;
}
public void validate() throws InvalidPropertyException {
}
}
That's it for the Connector (aside from the Connector itself). I have left out a little detail on the
ActivationSpec, we'll cover that later.
Now for the MDB's side of things. The MDB needs to implement the Connector's
EmailConsumer interface and configure the Connector'sEmailAccountInfo JavaBean which is done via the activation-config tag of the ejb-jar.xml or via @ActivationConfigPropertyannotations in the @MessageDriven declaration.@MessageDriven(activationConfig =
{@ActivationConfigProperty(
propertyName = "address",
propertyValue = "dblevins@apache.org")
})
public class EmailBean implements EmailConsumer {
@PostConstruct
public void init() {
}
public void receiveEmail(Properties headers, String body) {
// do your thing!
}
}
Done. Those are the basics. The Connector supplies a
MessageListener interface and an ActivationConfig JavaBean, the MDB implements the interface and configures the JavaBean via the loosely-typed @ActivationConfigProperty.
There are a few things that prevent this model from reaching its true potential:
- Metadata is loosely typed in the bean code
- Only class-level metadata is allowed, not method-level
- Requiring an interface can limit expressiveness
Let's see how life might look if we eliminate the JavaBean and allow the Connector to instead supply an annotation.
package org.superemail.connector;
@Target(TYPE)
@Retention(RUNTIME)
@javax.resource.annotation.ActivationSpec
public @interface EmailAccountInfo {
String address();
}
Side Note: The original javax.resource.spi.ActivationSpec interface has a 'validate()' method on it to validate the JavaBean. A clear update to that part of the API would be to instead use the Bean Validation API.
Which gives us a bean that might look like this:
@MessageDriven
@EmailAccountInfo(address = "dblevins@apache.org")
public static class EmailBean implements EmailConsumer {
@PostConstruct
public void init() {
}
public void receiveEmail(Properties headers, String body) {
// do your thing!
}
}
Now we're getting somewhere!
Ok, let's get rid of that message listener interface and image our Email Connector uses a very JAX-RS inspired API for consuming emails. If you know a little JAX-RS you'll see where I'm going with this.
@MessageDriven
@EmailAccountInfo(address = "dblevins@apache.org")
public static class EmailBean {
@PostConstruct
public void init() {
}
@Deliver @Header("Subject: {subject}")
public void receiveEmail(@HeaderParam("subject") String subject, @Body String body) {
// do your thing!
}
}
Pretty neat, huh?
Side note: For the rare few of you that speak Connector implementation, instead of giving your Resource Adapter a MessageEndpoint that is a proxy that only implements the MessageListener interface and the standard MessageEndpoint interface, the Container would instead give you an @LocalBean proxy that also implements MessageEndpoint. If you're thinking that an API like that would be great to use... imagine with the above changes you could make that API ... and use it in any compliant Java EE platform. Maybe even submit your own JSR if you came up with something great.
Truthfully speaking, it's the Connector who controls the lifecycle of the bean (MDB). The Connector API already allows for the Connector to say to the Container, "create me a bean" and "destroy this bean". So really, we don't need
@MessageDriven anymore. Instead we can do this:import javax.annotation.ManagedBean;
@ManagedBean
@EmailAccountInfo(address = "dblevins@apache.org")
public static class EmailBean {
// ....
}
That's a little more modern and perhaps a bit clearer.
At this point, we have a generic API to hook arbitrary "Connectors" up to arbitrary "Beans" that are managed by a container. Were this the case when JAX-RS was created, they wouldn't have had to put so much effort into duplicating all the services that people who have managed beans expect: injection of resources, lifecycle callbacks, interceptors.
Summary: A few improvements to the expressiveness of the metadata passed between a Bean and its Connector could kick the MDB/Connector model into the mainstream as was the intention of the API from the beginning. New specifications could be created based on this model and be introduced incrementally as they are developed and needed.
The impact of fully opening up the Bean metadata to the Connector is quite deep and wide and likely not something that will scream at you immediately. Ask yourself, could something like the new EJB 3.1
@Schedule API have been done with a Connector/Bean model like this? To some extent probably it could. Certainly there already existed a few Quartz Connectors out there prior to the introduction of @Schedule.
Take a moment to daydream. What kind of Connectors could you create with this model?
UPDATE - Feb 7th, 2013
Save this proposal. Without more voices it will be delayed till Java EE 8. Let's not wait 4 years! Take action and celebrate the Java Community Process openness by showing your support for including this in Java EE 7. Act now.
VOTE AND COMMENT HERE http://java.net/jira/browse/EJB_SPEC-60
459 comments:
«Oldest ‹Older 401 – 459 of 459Great share! Strong data modeling certification course
practices help teams design flexible architectures that scale with evolving needs.
Great read. This aligns with concepts in Data Science or Data Analytics.
Thanks for sharing this. I came across Data Science or Data Analytics which explains a similar concept.
Loved reading this! Makes complex topics much simpler. For a deeper dive, this link is great: Data Science vs Data Analytics.
Really enjoyed this post your writing is clear, engaging, and full of useful insights. The way you break down complex topics makes it easy for readers to follow and learn. Thanks for sharing such thoughtful content!
For anyone looking to build practical tech skills alongside this kind of learning, here’s a helpful Best Full Stack Developer Course worth checking out. Looking forward to more great posts!
This helped me—How to Learn Data Analytics is good.
Loved it—Best Full Stack Developer Course is great too.
Very useful! Explore Digital Marketing Training in Chennai and Data Science Courses in Chennai.
Clear, concise, and very informative content.
How to Learn Data Analytics and Full Stack Developer Course
12. This is very informative. For more details, check Digital Marketing Training in Chennai and Data Science Courses in Chennai.
Really enjoyed this article. This Best Web Design Course for Beginners is a great resource too.
Very informative and easy to understand.
Start with Data Analytics for Beginners and then join Data Analytics Course in Coimbatore.
Thank you for sharing this deep dive into EJB's Connector API and its potential. As an architect looking back, it's fascinating to see how these foundational concepts for messaging and integration have evolved. Understanding the engine under the hood is what separates a coder from an engineer.
To truly harness the power of modern, decoupled systems, mastering today's equivalent integration tools is crucial. For those in Bangalore wanting to get hands-on, exploring a structured program like online DevOps training Electronic City Bangalore can bridge the gap from legacy J2EE patterns to modern CI/CD and container orchestration. It's a journey from theory to in-demand practice.
I found this article to be really helpful. If you want to get a job in quality assurance in Bangalore you should consider the Premium Selenium Course in Electronic City Bangalore 2026. This course is very good because it has a lot of training. You can find out more about it here Premium Selenium Course in Electronic City Bangalore 2026.
I would like to thank you for the efforts you’ve put in penning this site. I really hope to view the same high-grade content by you in the future as well. Denta Biome | Phytomem One | Horsewood | Horsewood
Hi there, after reading this remarkable post i am also glad to share my experience here with friends. Pineal Guardian | Breathe | Renew Dental Support | Dentanol
It makes it much easier for readers like me to grasp the information. Keep up the great work, and I look forward to reading more from you. AquaSculpt | Prostavive | Claritox pro | Titan Flow
I especially appreciate how the author explains complex topics in such a simple and relatable way. Mindoxa | Igenics | Java Burn | Vertigenics
I would like to thank you for the efforts you’ve put in penning this site. I really hope to view the same high-grade content by you in the future as well. ProvaDent | Joint Genesis | FlowForce Max | Yu Sleep
Thank you for every other informative blog. Where else may I get that kind of information written in such a perfect method. MetaboSana | CleanseSana | Cholibrium | Joint Genesis
What’s up, its nice article regarding media print, we all be aware of media is a great source of information. Prosta Peak | PrimeBiome | FemiCore | MetaBurn
Remarkable! It's genuinely awesome site, I have got a much clearer idea from this piece of writing. Axavive | Ketowater | Steel Flow Pro | Flow
Hello there! Would you mind if I share your blog with my twitter group? There’s a lot of people that I think would really appreciate your content. Brain Memory Keeper | Breathizen | Nervovive | MetaFlow
I will be sure to bookmark it and return to read more of your useful information. Thanks for the post. I’ll definitely return. JointVive | AquaSculpt | Venus Factor | 7 Figure Accelerator
I will be sure to bookmark it and return to read more of your useful information. Thanks for the post. I’ll definitely return. AriaLief | ZenSulin | Booster Brew | ProtoFlow
This was a very good post. Finding the time and actual effort to produce a top notch article. Neuro Sharp | GlycoPezil | NerveCalm | Sugar Defender
What’s up, its nice article regarding media print, we all be aware of media is a great source of information. Derma Essential | VisiFlora | TrimX | NeuroSalt
A fascinating discussion is definitely worth comment. I do think that you need to write more about this topic. NeuroPrime | Sharp Vision | Gelatine Sculpt | Mind Vault
After checking out a few of the blog articles on your blog, I honestly appreciate your technique of blogging. VertiGenics | Primal Grow Pro | Protoflow | Synogut
Hello there! Would you mind if I share your blog with my twitter group? There’s a lot of people that I think would really appreciate your content. Synevra | Nitric Boost Ultra | Claritox Pro | Pineal Guardian
After checking out a few of the blog articles on your blog, I honestly appreciate your technique of blogging. MounjaBoost | AlphaFuel Pro | Aizen Power |Gluco Extend
A fascinating discussion is definitely worth comment. I do think that you need to write more about this topic. LeanBliss | SlimSana | Denticore | Cardio Slim Tea
Thank you for every other informative blog. Where else may I get that kind of information written in such a perfect method. Aizen Power | Synevra | SlimLeaf | Vivalis
I especially appreciate how the author explains complex topics in such a simple and relatable way. ZenCortex | ZenCortex | Neuro Serge | Quietum Plus
I enjoyed reading this blog! The content is informative, well-written, and easy to understand. Nerve Fresh | Tonic Greens | Gluco Extend | Neura
It seems too complex and very broad for me. I am looking forward to your next post. I’ll try to get the hang of it! NeuroVera | Prosta Defend | Synaptigen | Nerve Fresh
Remarkable! It's genuinely awesome site, I have got a much clearer idea from this piece of writing. SpartaMax | Metabo Drops | Metabo Drops | ProNail Complex
Thanks for this Fantastic article with brilliant insights! Thank you for sharing such valuable information. I truly appreciate this excellent contribution. AudiFort | Dentolyn | PowerBite | Energy Revolution System
I want to thank you and I'm glad you provided this information. I learned a lot about this site that I didn't know before, and I really appreciate it. GLPro | AudiFort | Black Wood Tea | GlycoMute
This was a very good post. Finding the time and actual effort to produce a top notch article. Dentilock | BloodArmor | DentalPrime | BloodArmor
Thanks for the marvelous posting! I certainly enjoyed reading it, you're a great author. GL-Defend | Levium | Teds Woodworking | Dentavive
I will be sure to bookmark your blog and will come back in the future. I want to encourage you to continue your great posts, have a nice holiday weekend! Glucolean | GL-defend | Cardio Shield | CogniClear
I just want to say, It makes it much easier for readers like me to grasp the information. Keep up the great work, and I look forward to reading more from you. Gluco Ally | NuNerve | Circo2 | Biodentix
Wow, awesome weblog format! How long have you been blogging for? you make blogging look easy. The total glance of your site is excellent, as neatly as the content material! Respilean | Nitric Boost | HerpaFend | Prostadine
Way cool! Some extremely valid points! I appreciate you penning this post plus the rest of the website is also very good. Pineal Guardian | Visium Pro | CircO2 | Nerve Defend
I enjoyed this fascinating discussion, it is definitely worth comment. I do think that you need to write more about this topic. Okinawa Flat Belly Tonic | Thyrafemme Balance | Tonic Greens \ Java Burn
I would like to thank you for the efforts you’ve put in penning this site. I really hope to view the same high-grade content by you in the future as well. Teds Woodworking | Pineal 10x | Quietum Plus | Tonic Greens
Hello there! Would you mind if I share your blog with my twitter group? There’s a lot of people that I think would really appreciate your content. NeuroTest | Prostavive | AlphaCur | Tonic Greens
Thanks for the marvelous posting ! I certainly enjoyed reading it, you’re a great author. BP Zone | Titan Transform | Sumatra Slim Belly Tonic | EndoPeak
This is an excellent post I seen thanks to share it. It is really what I wanted to see hope in future you will continue for sharing such a excellent post. Yu Sleep | Gluco Armor | Joint Genesis | SugarMute
I Like!! Really appreciate you sharing this blog post.Really thank you! Keep writing. Aqua Burn | Finessa | Synaptigen | Gold Align
This is an excellent post I seen thanks to share it. It is really what I wanted to see hope in future you will continue for sharing such a excellent post. MoveWell Daily | MetaboFix | ThyraFemme Balance | Brain C13
I just want to say, It makes it much easier for readers like me to grasp the information. Keep up the great work, and I look forward to reading more from you. Stratos Alpha | DigestiStart | Tinnitrol | Tinnitrol
Hello there! Would you mind if I share your blog with my twitter group? There’s a lot of people that I think would really appreciate your content. LungExpand Pro | Quietum Plus | CogniSurge | DigestiStart
Way cool! Some extremely valid points! I appreciate you penning this post plus the rest of the website is also very good. Pineal Awakening | Nervala | Ignitra | Nerve Alive
Wow, awesome weblog format! How long have you been blogging for? you make blogging look easy. The total glance of your site is excellent, as neatly as the content material! Nitric Boost Ultra | Neuro Surge | Neurozoom | Nerve fresh
I will be sure to bookmark your blog and will come back in the future. I want to encourage you to continue your great posts, have a nice holiday weekend! Prime Biome | Sugar Defender | Menovelle | Kerassentials
Thanks for the marvelous posting! I certainly enjoyed reading it, you're a great author. MetaboFlex | Gluco Berry | Ikaria Juice | Mitolyn
I will be sure to bookmark it and return to read more of your useful information. Thanks for the post. I’ll definitely return. Gluco6 | TotalControl24 | Pyramid Wealth Frequency | Resurge
Post a Comment