{{ !articles[0].partner.isSponsoringArticle ? "Platinum" : "Portal" }} Partner
java,enterprise-integration,integration,tips and tricks,apache camel,mongodb

Apache Camel - Connection Beans Without Spring

While writing some tests for an Apache Camel project, I just spent rather longer than I'd have liked trying to work out how to configure a connection bean for Mongo without using Spring.

Since I hide my embarrassments in public I thought I'd best share with anyone else with brain freeze.
public class SomeTest extends CamelTestSupport {

    protected RouteBuilder createRouteBuilder() throws Exception {
        return new RouteBuilder() {
            public void configure() throws Exception {


    protected JndiRegistry createRegistry() throws Exception {
        JndiRegistry reg = new JndiRegistry(createJndiContext());
        Mongo connectionBean = new Mongo("localhost", 27017);
        reg.bind("myConnectionBean", connectionBean);
        return reg;

    public void testSomething() throws InterruptedException {
        // test something here

Don't forget you need the camel-mongodb artifact in your pom.xml file. Good luck fellow travellers.

Published at DZone with permission of {{ articles[0].authors[0].realName }}, DZone MVB. (source)

Opinions expressed by DZone contributors are their own.

{{ tag }}, {{tag}},

{{ parent.title || parent.header.title}}

{{ parent.tldr }}

{{ parent.urlSource.name }}
{{ parent.authors[0].realName || parent.author}}

{{ parent.authors[0].tagline || parent.tagline }}

{{ parent.views }} ViewsClicks