Camel without Spring

classic Classic list List threaded Threaded
6 messages Options
Reply | Threaded
Open this post in threaded view
|

Camel without Spring

mumbly
I did a search on the forum, but did not see anything addressing this issue (though it is a bit of an awkward search to make, so I may have missed something).

I'm new to Camel (evaluating it, Spring Integration and Mule for a project) and have been spending a little time trying to get a few different scenarios working. My project doesn't currently use Spring and I'd prefer to avoid additional dependencies if they aren't necessary. That said, I feel like I'm walking upstream trying to use Camel without Spring. It seems like most of the examples use Spring, even those that do routing using the Java DSL. I found it rather ironic that one of the first Spring Integration examples I ran across did not use the Spring framework, yet all of the Camel examples (other than the simple getting started) do.

I'm not anti-Spring (I was typing in the code from the Wrox book before there was a download for the Interface21 code) and I don't want to cut off my nose to spite my face. If Spring + Camel gives me the preferred method of using Camel and it is more functional to use the combination, I'm fine with that. Just want feedback from the users/developers on whether it is worth trying to keep Spring out.

Thanks.

--Tim
Reply | Threaded
Open this post in threaded view
|

Re: Camel without Spring

Willem.Jiang
Administrator
Hi Tim,

Most camel component can run without spring support, unless some
components which have some complex configuration which need Spring to do
the DI work. You can also use Guice[1] to do that part of work.
If you are not a big fan of Spring you can take a look the example that
Camel In Action Chapter one[2] shows.

public static void main(String... args) throws Exception {
CamelContext context = new DefaultCamelContext(); (1)
context.addRoutes(new RouteBuilder() { (2)
public void configure() throws Exception {
from("file://data/inbox").to("file://data/outbox"); (3)
}
context.start(); (4)

...

context.stop(); (6)
}
}

You just need to create a camel context, and add your RouteBuilder (JAVA
DSL), then start the camel context.

[1] http://camel.apache.org/guice.html
[2] http://www.manning.com/ibsen/

Willem


mumbly wrote:

> I did a search on the forum, but did not see anything addressing this issue
> (though it is a bit of an awkward search to make, so I may have missed
> something).
>
> I'm new to Camel (evaluating it, Spring Integration and Mule for a project)
> and have been spending a little time trying to get a few different scenarios
> working. My project doesn't currently use Spring and I'd prefer to avoid
> additional dependencies if they aren't necessary. That said, I feel like I'm
> walking upstream trying to use Camel without Spring. It seems like most of
> the examples use Spring, even those that do routing using the Java DSL. I
> found it rather ironic that one of the first Spring Integration examples I
> ran across did not use the Spring framework, yet all of the Camel examples
> (other than the simple getting started) do.
>
> I'm not anti-Spring (I was typing in the code from the Wrox book before
> there was a download for the Interface21 code) and I don't want to cut off
> my nose to spite my face. If Spring + Camel gives me the preferred method of
> using Camel and it is more functional to use the combination, I'm fine with
> that. Just want feedback from the users/developers on whether it is worth
> trying to keep Spring out.
>
> Thanks.
>
> --Tim

Reply | Threaded
Open this post in threaded view
|

Re: Camel without Spring

Claus Ibsen-2
In reply to this post by mumbly
On Fri, Nov 6, 2009 at 2:20 AM, mumbly <[hidden email]> wrote:

>
> I did a search on the forum, but did not see anything addressing this issue
> (though it is a bit of an awkward search to make, so I may have missed
> something).
>
> I'm new to Camel (evaluating it, Spring Integration and Mule for a project)
> and have been spending a little time trying to get a few different scenarios
> working. My project doesn't currently use Spring and I'd prefer to avoid
> additional dependencies if they aren't necessary. That said, I feel like I'm
> walking upstream trying to use Camel without Spring. It seems like most of
> the examples use Spring, even those that do routing using the Java DSL. I
> found it rather ironic that one of the first Spring Integration examples I
> ran across did not use the Spring framework, yet all of the Camel examples
> (other than the simple getting started) do.
>

SI is build on top of Spring, kinda hard to not use Spring with SI. So
I wonder what kind of example that was.



There are plenty of examples of using Camel without Spring.

A lot of the wiki documentation have either a Java and/or a Spring DSL example.
However most of the time the Java DSL and Spring DSL maps 1:1.

Have you checked out the tutorials, for example this one does not use Spring
http://camel.apache.org/tutorial-example-reportincident.html

And this one
http://camel.apache.org/walk-through-an-example.html

And the loan broker example can run without spring as well AFAIR
http://camel.apache.org/loan-broker-example.html

And people have created blogs and articles using Camel which uses
and/or spring as well
http://camel.apache.org/articles.html

And my book will also have a lot of non spring + spring examples as well
Author of Camel in Action: http://www.manning.com/ibsen/


And the EIP reference card at DZone as well have a Java + a Spring DSL
example for about 10 commonly used EIP patterns
http://refcardz.dzone.com/refcardz/enterprise-integration


> I'm not anti-Spring (I was typing in the code from the Wrox book before
> there was a download for the Interface21 code) and I don't want to cut off
> my nose to spite my face. If Spring + Camel gives me the preferred method of
> using Camel and it is more functional to use the combination, I'm fine with
> that. Just want feedback from the users/developers on whether it is worth
> trying to keep Spring out.
>

The good think about Spring is that you can digest it in pieces at the
pace you like. So you dont have to use all its features and bells and
the DI using annotations and whatnot.



> Thanks.
>
> --Tim
> --
> View this message in context: http://old.nabble.com/Camel-without-Spring-tp26225350p26225350.html
> Sent from the Camel - Users mailing list archive at Nabble.com.
>
>



--
Claus Ibsen
Apache Camel Committer

Author of Camel in Action: http://www.manning.com/ibsen/
Open Source Integration: http://fusesource.com
Blog: http://davsclaus.blogspot.com/
Twitter: http://twitter.com/davsclaus
Reply | Threaded
Open this post in threaded view
|

Re: Camel without Spring

mumbly
So I guess I should have been clearer, but I wasn't talking specifically about using Spring for routing configuration. I know there are examples using Java DSL. But it seems like even those not using Spring for route definition are still using it.

Report Incident does use Spring:

camel-example-reportincident/src/main/resources/META-INF/spring/camel-context.xml
camel-example-reportincident/src/main/resources/camel-config.xml

It looks like you are right about the loan broker example. When I was searching through the examples to see if any didn't use spring, it still had two hits (imports org.apache.camel.spring.Main and uses camel-spring in the pom.xml) and I didn't look further to see if they were really used. But I think it is somewhat telling that Spring creeps in even if it is not necessarily used.

Anyway, I appreciate your comment about being able to use Spring as much or as little as you like. I think I'll consider using it to set up the Camel context and as support if I use the Bean component (again here, it looks like the JNDI method is a workaround for people who want to avoid using Spring).

Thanks for the pointer to your book. I'll certainly check it out if we end up going with Camel. Any chance you can finish it up in the next week so I can use it to help in my evaluation?

--Tim

Claus Ibsen-2 wrote
On Fri, Nov 6, 2009 at 2:20 AM, mumbly <mcnerney@gmail.com> wrote:
>
> I did a search on the forum, but did not see anything addressing this issue
> (though it is a bit of an awkward search to make, so I may have missed
> something).
>
> I'm new to Camel (evaluating it, Spring Integration and Mule for a project)
> and have been spending a little time trying to get a few different scenarios
> working. My project doesn't currently use Spring and I'd prefer to avoid
> additional dependencies if they aren't necessary. That said, I feel like I'm
> walking upstream trying to use Camel without Spring. It seems like most of
> the examples use Spring, even those that do routing using the Java DSL. I
> found it rather ironic that one of the first Spring Integration examples I
> ran across did not use the Spring framework, yet all of the Camel examples
> (other than the simple getting started) do.
>

SI is build on top of Spring, kinda hard to not use Spring with SI. So
I wonder what kind of example that was.



There are plenty of examples of using Camel without Spring.

A lot of the wiki documentation have either a Java and/or a Spring DSL example.
However most of the time the Java DSL and Spring DSL maps 1:1.

Have you checked out the tutorials, for example this one does not use Spring
http://camel.apache.org/tutorial-example-reportincident.html

And this one
http://camel.apache.org/walk-through-an-example.html

And the loan broker example can run without spring as well AFAIR
http://camel.apache.org/loan-broker-example.html

And people have created blogs and articles using Camel which uses
and/or spring as well
http://camel.apache.org/articles.html

And my book will also have a lot of non spring + spring examples as well
Author of Camel in Action: http://www.manning.com/ibsen/


And the EIP reference card at DZone as well have a Java + a Spring DSL
example for about 10 commonly used EIP patterns
http://refcardz.dzone.com/refcardz/enterprise-integration


> I'm not anti-Spring (I was typing in the code from the Wrox book before
> there was a download for the Interface21 code) and I don't want to cut off
> my nose to spite my face. If Spring + Camel gives me the preferred method of
> using Camel and it is more functional to use the combination, I'm fine with
> that. Just want feedback from the users/developers on whether it is worth
> trying to keep Spring out.
>

The good think about Spring is that you can digest it in pieces at the
pace you like. So you dont have to use all its features and bells and
the DI using annotations and whatnot.



> Thanks.
>
> --Tim
> --
> View this message in context: http://old.nabble.com/Camel-without-Spring-tp26225350p26225350.html
> Sent from the Camel - Users mailing list archive at Nabble.com.
>
>



--
Claus Ibsen
Apache Camel Committer

Author of Camel in Action: http://www.manning.com/ibsen/
Open Source Integration: http://fusesource.com
Blog: http://davsclaus.blogspot.com/
Twitter: http://twitter.com/davsclaus
Reply | Threaded
Open this post in threaded view
|

Re: Camel without Spring

Claus Ibsen-2
On Fri, Nov 6, 2009 at 5:52 PM, mumbly <[hidden email]> wrote:

>
> So I guess I should have been clearer, but I wasn't talking specifically
> about using Spring for routing configuration. I know there are examples
> using Java DSL. But it seems like even those not using Spring for route
> definition are still using it.
>
> Report Incident does use Spring:
>
> camel-example-reportincident/src/main/resources/META-INF/spring/camel-context.xml
> camel-example-reportincident/src/main/resources/camel-config.xml
>

Yeah that is because the tutorial evolves and over time we add more
and more Camel features.
And it uses CXF which uses Spring to setup the CXF stuff. You can
probably configure CXF without doing it the spring way.

And the code in the distribution is the code based when the tutorial
is at the end.

You could go read the tutorial.


> It looks like you are right about the loan broker example. When I was
> searching through the examples to see if any didn't use spring, it still had
> two hits (imports org.apache.camel.spring.Main and uses camel-spring in the
> pom.xml) and I didn't look further to see if they were really used. But I
> think it is somewhat telling that Spring creeps in even if it is not
> necessarily used.
>
> Anyway, I appreciate your comment about being able to use Spring as much or
> as little as you like. I think I'll consider using it to set up the Camel
> context and as support if I use the Bean component (again here, it looks
> like the JNDI method is a workaround for people who want to avoid using
> Spring).
>

In 2.1 there is a SimpleRegistry that is not JNDI based so that is even easier.


> Thanks for the pointer to your book. I'll certainly check it out if we end
> up going with Camel. Any chance you can finish it up in the next week so I
> can use it to help in my evaluation?
>

:) you can buy the MEAP and you have access to the chapters as we
write them. There are 4 chapters online now.




> --Tim
>
>
> Claus Ibsen-2 wrote:
>>
>> On Fri, Nov 6, 2009 at 2:20 AM, mumbly <[hidden email]> wrote:
>>>
>>> I did a search on the forum, but did not see anything addressing this
>>> issue
>>> (though it is a bit of an awkward search to make, so I may have missed
>>> something).
>>>
>>> I'm new to Camel (evaluating it, Spring Integration and Mule for a
>>> project)
>>> and have been spending a little time trying to get a few different
>>> scenarios
>>> working. My project doesn't currently use Spring and I'd prefer to avoid
>>> additional dependencies if they aren't necessary. That said, I feel like
>>> I'm
>>> walking upstream trying to use Camel without Spring. It seems like most
>>> of
>>> the examples use Spring, even those that do routing using the Java DSL. I
>>> found it rather ironic that one of the first Spring Integration examples
>>> I
>>> ran across did not use the Spring framework, yet all of the Camel
>>> examples
>>> (other than the simple getting started) do.
>>>
>>
>> SI is build on top of Spring, kinda hard to not use Spring with SI. So
>> I wonder what kind of example that was.
>>
>>
>>
>> There are plenty of examples of using Camel without Spring.
>>
>> A lot of the wiki documentation have either a Java and/or a Spring DSL
>> example.
>> However most of the time the Java DSL and Spring DSL maps 1:1.
>>
>> Have you checked out the tutorials, for example this one does not use
>> Spring
>> http://camel.apache.org/tutorial-example-reportincident.html
>>
>> And this one
>> http://camel.apache.org/walk-through-an-example.html
>>
>> And the loan broker example can run without spring as well AFAIR
>> http://camel.apache.org/loan-broker-example.html
>>
>> And people have created blogs and articles using Camel which uses
>> and/or spring as well
>> http://camel.apache.org/articles.html
>>
>> And my book will also have a lot of non spring + spring examples as well
>> Author of Camel in Action: http://www.manning.com/ibsen/
>>
>>
>> And the EIP reference card at DZone as well have a Java + a Spring DSL
>> example for about 10 commonly used EIP patterns
>> http://refcardz.dzone.com/refcardz/enterprise-integration
>>
>>
>>> I'm not anti-Spring (I was typing in the code from the Wrox book before
>>> there was a download for the Interface21 code) and I don't want to cut
>>> off
>>> my nose to spite my face. If Spring + Camel gives me the preferred method
>>> of
>>> using Camel and it is more functional to use the combination, I'm fine
>>> with
>>> that. Just want feedback from the users/developers on whether it is worth
>>> trying to keep Spring out.
>>>
>>
>> The good think about Spring is that you can digest it in pieces at the
>> pace you like. So you dont have to use all its features and bells and
>> the DI using annotations and whatnot.
>>
>>
>>
>>> Thanks.
>>>
>>> --Tim
>>> --
>>> View this message in context:
>>> http://old.nabble.com/Camel-without-Spring-tp26225350p26225350.html
>>> Sent from the Camel - Users mailing list archive at Nabble.com.
>>>
>>>
>>
>>
>>
>> --
>> Claus Ibsen
>> Apache Camel Committer
>>
>> Author of Camel in Action: http://www.manning.com/ibsen/
>> Open Source Integration: http://fusesource.com
>> Blog: http://davsclaus.blogspot.com/
>> Twitter: http://twitter.com/davsclaus
>>
>>
>
> --
> View this message in context: http://old.nabble.com/Camel-without-Spring-tp26225350p26230826.html
> Sent from the Camel - Users mailing list archive at Nabble.com.
>
>



--
Claus Ibsen
Apache Camel Committer

Author of Camel in Action: http://www.manning.com/ibsen/
Open Source Integration: http://fusesource.com
Blog: http://davsclaus.blogspot.com/
Twitter: http://twitter.com/davsclaus
Reply | Threaded
Open this post in threaded view
|

Re: Camel without Spring

mumbly
I will take a look at SimpleRegistry. I'll also check out the MEAP. We'll see where I land with Spring.

--Tim