You are viewing a plain text version of this content. The canonical link for it is here.
Posted to users@camel.apache.org by Ron Smith <ro...@gmail.com> on 2010/07/19 20:06:10 UTC

JMS Component WITHOUT Spring

Where I work, Spring has been declared "evil" so I am attempting to use
camel without any of the Spring JARs but I can't find any examples of how to
setup a JMS component without a Spring dependency. I am using Tibco as the
JMS provider and it is providing JNDI.

Here is a sample code snippet which shows the JNDI and JMS setup that I need
for the component:

final CamelContext context = new DefaultCamelContext();
final Hashtable env = new Hashtable();
env.put(Context.INITIAL_CONTEXT_FACTORY,
"com.tibco.tibjms.naming.TibjmsInitialContextFactory");
env.put(Context.PROVIDER_URL, Constants.TOPIC_PROVIDER_URL));
env.put(Context.SECURITY_PRINCIPAL, Constants.TOPIC_SECURITY_PRINCIPAL));
env.put(Context.SECURITY_CREDENTIALS,
Constants.TOPIC_SECURITY_CREDENTIALS));
final Context jndiContext = new InitialContext(env);
final TopicConnectionFactory topicConnectionFactory =
(TopicConnectionFactory)
jndiContext.lookup(Constants.TOPIC_CONNECTION_FACTORY));

context.addComponent("tibco",
JmsComponent.jmsComponentAutoAcknowledge(topicConnectionFactory));


This compiles without any Spring JARs but, when I run it I get the following
exception thrown by the last line of code:


Caused by: java.lang.ClassNotFoundException:
org.springframework.context.ApplicationContextAware



NOTE: I am currently looking into the possibility that this is actually an
issue with the DefaultCamelContext being dependent on Spring rather that it
being a JMS or component issue. In any case, I would appreciate any advice
or guidance on this.

Re: JMS Component WITHOUT Spring

Posted by James Strachan <ja...@gmail.com>.
On 20 July 2010 16:38, Ron Smith <ro...@valkyresoftware.com> wrote:
> Unfortunately, all those cool features (especially pooling and reconnect)
> are exactly why I was wanting to use something like camel. This isn't the
> first time that this companies unreasonable biases have limited my choices
> of tools. I'm not a fan of spring or maven but I understand their value.
>
> I might actually take a stab at a non-spring jms component for camel because
> I am really liking the way camel works.

Yay - go Ron! :)

FWIW the Camel Component is designed as a natural place to lazily
create & own the JMS connection; the Endpoint as a natural place to
hold the Destination.  Then each Camel Producer/Consumer would just
create & own a JMS Session and MessageProducer / MessageConsumer.

So it shouldn't be too hard to get something reasonable going fairly
quickly. Though camel-jms has ended up being quite complex code due to
lots of complex requirements (e.g. supporting InOut with a ton of
different configuration options). Dealing with transactions and
reconnection is going to be the hardest and most complex bit though.


-- 
James
-------
http://macstrac.blogspot.com/

Open Source Integration
http://fusesource.com/

Re: JMS Component WITHOUT Spring

Posted by Ron Smith <ro...@valkyresoftware.com>.
Unfortunately, all those cool features (especially pooling and reconnect)
are exactly why I was wanting to use something like camel. This isn't the
first time that this companies unreasonable biases have limited my choices
of tools. I'm not a fan of spring or maven but I understand their value.

I might actually take a stab at a non-spring jms component for camel because
I am really liking the way camel works.

On Tue, Jul 20, 2010 at 10:17 AM, James Strachan
<ja...@gmail.com>wrote:

> On 19 July 2010 22:12, Ron Smith <ro...@gmail.com> wrote:
> > I'm with you, Jim. I think that is part of why others at my company
> consider
> > spring to be "evil" -- for a "light-weight" framework, there sure are a
> lot
> > of pieces you have to include and they seem to be growing and becoming
> more
> > intertwined with each new release.
>
> FWIW in the old days, you'd just depend on "spring.jar". The problem
> appears worse now that each spring jar is highly modular.
>
>
> > Like you, I'm not griping, it just seems
> > like everything in the java open-source world is starting to depend on
> > everything else in the java open-source world.
>
> If you really don't want to depend on spring and your JMS requirements
> are quite simple (e.g. you don't want pooling of
> producers/sessions/connections, you don't want transactions,
> reconnection/retry, concurrent consuming and are happy to work on,
> say, JMS 1.1 only) it would be quite easy to create a JMS component &
> endpoint which just used the JMS API and did not use Spring at all.
>
> I agree the Spring JMS stuff looks like it has quite a lot of
> dependencies (though part of that is due to its been decoupled into
> many jars) - all of which is out of our control. But until someone
> comes along with a leaner & meaner library which offers similar
> features I don't see much alternative.
>
> Unless someone (Ron? Jim?) fancies volunteering to write a lean & mean
> alternative folks can use if they want to use JMS but not reuse the
> spring jars.
>
> Another alternative Ron/Jim - use uberjar to slap all the spring-jms /
> camel-jms / camel stuff together so you only have "camel-all.jar" to
> worry about :)
>
> --
> James
> -------
> http://macstrac.blogspot.com/
>
> Open Source Integration
> http://fusesource.com/
>

Re: JMS Component WITHOUT Spring

Posted by Claus Ibsen <cl...@gmail.com>.
On Tue, Jul 20, 2010 at 5:17 PM, James Strachan
<ja...@gmail.com> wrote:
> On 19 July 2010 22:12, Ron Smith <ro...@gmail.com> wrote:
>> I'm with you, Jim. I think that is part of why others at my company consider
>> spring to be "evil" -- for a "light-weight" framework, there sure are a lot
>> of pieces you have to include and they seem to be growing and becoming more
>> intertwined with each new release.
>
> FWIW in the old days, you'd just depend on "spring.jar". The problem
> appears worse now that each spring jar is highly modular.
>

Unfortunately spring 3.0.x no longer ships an uber jar in maven repos.
So we can't just include spring-3.0.3.jar in the release kit.

>
>> Like you, I'm not griping, it just seems
>> like everything in the java open-source world is starting to depend on
>> everything else in the java open-source world.
>
> If you really don't want to depend on spring and your JMS requirements
> are quite simple (e.g. you don't want pooling of
> producers/sessions/connections, you don't want transactions,
> reconnection/retry, concurrent consuming and are happy to work on,
> say, JMS 1.1 only) it would be quite easy to create a JMS component &
> endpoint which just used the JMS API and did not use Spring at all.
>
> I agree the Spring JMS stuff looks like it has quite a lot of
> dependencies (though part of that is due to its been decoupled into
> many jars) - all of which is out of our control. But until someone
> comes along with a leaner & meaner library which offers similar
> features I don't see much alternative.
>
> Unless someone (Ron? Jim?) fancies volunteering to write a lean & mean
> alternative folks can use if they want to use JMS but not reuse the
> spring jars.
>
> Another alternative Ron/Jim - use uberjar to slap all the spring-jms /
> camel-jms / camel stuff together so you only have "camel-all.jar" to
> worry about :)
>
> --
> James
> -------
> http://macstrac.blogspot.com/
>
> Open Source Integration
> http://fusesource.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

Re: JMS Component WITHOUT Spring

Posted by James Strachan <ja...@gmail.com>.
On 19 July 2010 22:12, Ron Smith <ro...@gmail.com> wrote:
> I'm with you, Jim. I think that is part of why others at my company consider
> spring to be "evil" -- for a "light-weight" framework, there sure are a lot
> of pieces you have to include and they seem to be growing and becoming more
> intertwined with each new release.

FWIW in the old days, you'd just depend on "spring.jar". The problem
appears worse now that each spring jar is highly modular.


> Like you, I'm not griping, it just seems
> like everything in the java open-source world is starting to depend on
> everything else in the java open-source world.

If you really don't want to depend on spring and your JMS requirements
are quite simple (e.g. you don't want pooling of
producers/sessions/connections, you don't want transactions,
reconnection/retry, concurrent consuming and are happy to work on,
say, JMS 1.1 only) it would be quite easy to create a JMS component &
endpoint which just used the JMS API and did not use Spring at all.

I agree the Spring JMS stuff looks like it has quite a lot of
dependencies (though part of that is due to its been decoupled into
many jars) - all of which is out of our control. But until someone
comes along with a leaner & meaner library which offers similar
features I don't see much alternative.

Unless someone (Ron? Jim?) fancies volunteering to write a lean & mean
alternative folks can use if they want to use JMS but not reuse the
spring jars.

Another alternative Ron/Jim - use uberjar to slap all the spring-jms /
camel-jms / camel stuff together so you only have "camel-all.jar" to
worry about :)

-- 
James
-------
http://macstrac.blogspot.com/

Open Source Integration
http://fusesource.com/

Re: JMS Component WITHOUT Spring

Posted by Ron Smith <ro...@gmail.com>.
I'm with you, Jim. I think that is part of why others at my company consider
spring to be "evil" -- for a "light-weight" framework, there sure are a lot
of pieces you have to include and they seem to be growing and becoming more
intertwined with each new release. Like you, I'm not griping, it just seems
like everything in the java open-source world is starting to depend on
everything else in the java open-source world.

On Mon, Jul 19, 2010 at 3:57 PM, Jim Newsham <jn...@referentia.com>wrote:

>  On 7/19/2010 8:13 AM, Claus Ibsen wrote:
>
>> Hi
>>
>>
>> On Mon, Jul 19, 2010 at 8:06 PM, Ron Smith<ro...@gmail.com>  wrote:
>>
>>> Where I work, Spring has been declared "evil" so I am attempting to use
>>> camel without any of the Spring JARs but I can't find any examples of how
>>> to
>>> setup a JMS component without a Spring dependency. I am using Tibco as
>>> the
>>> JMS provider and it is providing JNDI.
>>>
>>>  It must be a touch workplace when a general considered standard
>> framework is considered evil?
>>
>> The camel-jms component leverages spring-jms for sending and receiving
>> JMS messages and therefore
>> you cannot use it without spring-jms.
>>
>> You can use plain JMS API if you want to avoid Spring and build a JMS
>> consumer.
>> For examples see the ActiveMQ in Action which shows that. And I am
>> sure you may find other examples by googling as well.
>>
>> To send the message to Camel is very easy from Java code. For example
>> just use the ProducerTemplate API.
>>
>
> We're also looking into using Camel + JMS (ActiveMQ in particular).  We
> don't use spring and have no intention to do so currently (no discussion
> about whether it's evil or not; it just doesn't suit our purposes at the
> moment).
>
> I was disappointed to discover that I needed to add the following jars in
> addition to camel-core, camel-jms, and activemq-all before it would run:
>  activemq-pool, commons-logging, commons-management, commons-pool,
> spring-aop, spring-beans, spring-context, spring-core, spring-jms,
> spring-tx.  Particularly for a project which claims to have minimal
> dependencies, this seems a little excessive.  I'm not griping -- if we
> choose to use Camel (which seems likely) then we'll happily (yet
> reluctantly) add these extra jars.  It just would be nice if such an
> internal dependency did not exist, for developers who do not use spring.
>
> Regards,
> Jim
>
>
>
>
>
>
>

Re: JMS Component WITHOUT Spring

Posted by Claus Ibsen <cl...@gmail.com>.
On Mon, Jul 19, 2010 at 10:57 PM, Jim Newsham <jn...@referentia.com> wrote:
>  On 7/19/2010 8:13 AM, Claus Ibsen wrote:
>>
>> Hi
>>
>>
>> On Mon, Jul 19, 2010 at 8:06 PM, Ron Smith<ro...@gmail.com>  wrote:
>>>
>>> Where I work, Spring has been declared "evil" so I am attempting to use
>>> camel without any of the Spring JARs but I can't find any examples of how
>>> to
>>> setup a JMS component without a Spring dependency. I am using Tibco as
>>> the
>>> JMS provider and it is providing JNDI.
>>>
>> It must be a touch workplace when a general considered standard
>> framework is considered evil?
>>
>> The camel-jms component leverages spring-jms for sending and receiving
>> JMS messages and therefore
>> you cannot use it without spring-jms.
>>
>> You can use plain JMS API if you want to avoid Spring and build a JMS
>> consumer.
>> For examples see the ActiveMQ in Action which shows that. And I am
>> sure you may find other examples by googling as well.
>>
>> To send the message to Camel is very easy from Java code. For example
>> just use the ProducerTemplate API.
>
> We're also looking into using Camel + JMS (ActiveMQ in particular).  We
> don't use spring and have no intention to do so currently (no discussion
> about whether it's evil or not; it just doesn't suit our purposes at the
> moment).
>
> I was disappointed to discover that I needed to add the following jars in
> addition to camel-core, camel-jms, and activemq-all before it would run:
>  activemq-pool, commons-logging, commons-management, commons-pool,
> spring-aop, spring-beans, spring-context, spring-core, spring-jms,
> spring-tx.  Particularly for a project which claims to have minimal
> dependencies, this seems a little excessive.  I'm not griping -- if we
> choose to use Camel (which seems likely) then we'll happily (yet
> reluctantly) add these extra jars.  It just would be nice if such an
> internal dependency did not exist, for developers who do not use spring.
>

If you are NOT using AMQ then you dont need any AMQ jars at all.


The camel-core has a minimal dependency set.
- commons-logging
- commons-management

If you want to use JMX with Camel then we leverage spring-jmx annotations.
And therefore you need to drop in a couple of Spring jars to use JMX.

The native JMX API in the JDK is a terrible API that is painful to
use. Spring JMX makes it easy to annotation your beans and that's it.
In fact SUN should have created a standard set of JMX annotations,
which is a perfect fit for a good use-case for annotations.
Unfortunately they never did. If they do we would sure leverage it
instead of using the Spring @ManagedResource annotations.

And on JDK 1.5 you need a little extra for XML parsers and Attachments support.
But those are as said provided out of the box in JDK 1.6 onwards.



Of course the many Camel components requires the set of jars that
those 3rd party libraries are using.
For example camel-ftp requires what the Apache Commons Net project need etc.

For camel-jms as its leveraging spring-jms, requires what spring-jms
needs. And it need about 6-10 jars.



Camel does not suffer from NIH syndrome and it would be madness to go
out and implement our own JMS component from scratch.
Spring has been battle tested, its mature and been around for a long
time, and it has a professional company behind with very talented
people who maintain a high quality framework.

camel-jms can be used without end users seeing Spring at all. You do
not need to use Spring XML files and its bean container etc. Just
think of the spring jars as the API for the JMS stuff.




> Regards,
> Jim
>
>
>
>
>
>
>



-- 
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

Re: JMS Component WITHOUT Spring

Posted by Jim Newsham <jn...@referentia.com>.
  On 7/19/2010 8:13 AM, Claus Ibsen wrote:
> Hi
>
>
> On Mon, Jul 19, 2010 at 8:06 PM, Ron Smith<ro...@gmail.com>  wrote:
>> Where I work, Spring has been declared "evil" so I am attempting to use
>> camel without any of the Spring JARs but I can't find any examples of how to
>> setup a JMS component without a Spring dependency. I am using Tibco as the
>> JMS provider and it is providing JNDI.
>>
> It must be a touch workplace when a general considered standard
> framework is considered evil?
>
> The camel-jms component leverages spring-jms for sending and receiving
> JMS messages and therefore
> you cannot use it without spring-jms.
>
> You can use plain JMS API if you want to avoid Spring and build a JMS consumer.
> For examples see the ActiveMQ in Action which shows that. And I am
> sure you may find other examples by googling as well.
>
> To send the message to Camel is very easy from Java code. For example
> just use the ProducerTemplate API.

We're also looking into using Camel + JMS (ActiveMQ in particular).  We 
don't use spring and have no intention to do so currently (no discussion 
about whether it's evil or not; it just doesn't suit our purposes at the 
moment).

I was disappointed to discover that I needed to add the following jars 
in addition to camel-core, camel-jms, and activemq-all before it would 
run:  activemq-pool, commons-logging, commons-management, commons-pool, 
spring-aop, spring-beans, spring-context, spring-core, spring-jms, 
spring-tx.  Particularly for a project which claims to have minimal 
dependencies, this seems a little excessive.  I'm not griping -- if we 
choose to use Camel (which seems likely) then we'll happily (yet 
reluctantly) add these extra jars.  It just would be nice if such an 
internal dependency did not exist, for developers who do not use spring.

Regards,
Jim







Re: JMS Component WITHOUT Spring

Posted by Ron Smith <ro...@gmail.com>.
So I am guessing that if I build my own JMS connection with the
ProducerTemplate, than I lose all of the nice features of the camel jms
component (like the reconnect logic, etc.) because the camel-jms is just a
wrapper around the spring-jms. I would have to rebuild all of that myself
without using Spring.

James may be right -- it might be time to find a new job :-)

On Mon, Jul 19, 2010 at 1:13 PM, Claus Ibsen <cl...@gmail.com> wrote:

> Hi
>
>
> On Mon, Jul 19, 2010 at 8:06 PM, Ron Smith <ro...@gmail.com> wrote:
> > Where I work, Spring has been declared "evil" so I am attempting to use
> > camel without any of the Spring JARs but I can't find any examples of how
> to
> > setup a JMS component without a Spring dependency. I am using Tibco as
> the
> > JMS provider and it is providing JNDI.
> >
>
> It must be a touch workplace when a general considered standard
> framework is considered evil?
>
> The camel-jms component leverages spring-jms for sending and receiving
> JMS messages and therefore
> you cannot use it without spring-jms.
>
> You can use plain JMS API if you want to avoid Spring and build a JMS
> consumer.
> For examples see the ActiveMQ in Action which shows that. And I am
> sure you may find other examples by googling as well.
>
> To send the message to Camel is very easy from Java code. For example
> just use the ProducerTemplate API.
>
>
>
> > Here is a sample code snippet which shows the JNDI and JMS setup that I
> need
> > for the component:
> >
> > final CamelContext context = new DefaultCamelContext();
> > final Hashtable env = new Hashtable();
> > env.put(Context.INITIAL_CONTEXT_FACTORY,
> > "com.tibco.tibjms.naming.TibjmsInitialContextFactory");
> > env.put(Context.PROVIDER_URL, Constants.TOPIC_PROVIDER_URL));
> > env.put(Context.SECURITY_PRINCIPAL, Constants.TOPIC_SECURITY_PRINCIPAL));
> > env.put(Context.SECURITY_CREDENTIALS,
> > Constants.TOPIC_SECURITY_CREDENTIALS));
> > final Context jndiContext = new InitialContext(env);
> > final TopicConnectionFactory topicConnectionFactory =
> > (TopicConnectionFactory)
> > jndiContext.lookup(Constants.TOPIC_CONNECTION_FACTORY));
> >
> > context.addComponent("tibco",
> > JmsComponent.jmsComponentAutoAcknowledge(topicConnectionFactory));
> >
> >
> > This compiles without any Spring JARs but, when I run it I get the
> following
> > exception thrown by the last line of code:
> >
> >
> > Caused by: java.lang.ClassNotFoundException:
> > org.springframework.context.ApplicationContextAware
> >
> >
> >
> > NOTE: I am currently looking into the possibility that this is actually
> an
> > issue with the DefaultCamelContext being dependent on Spring rather that
> it
> > being a JMS or component issue. In any case, I would appreciate any
> advice
> > or guidance on this.
> >
>
>
>
> --
> 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
>

Re: JMS Component WITHOUT Spring

Posted by Claus Ibsen <cl...@gmail.com>.
Hi


On Mon, Jul 19, 2010 at 8:06 PM, Ron Smith <ro...@gmail.com> wrote:
> Where I work, Spring has been declared "evil" so I am attempting to use
> camel without any of the Spring JARs but I can't find any examples of how to
> setup a JMS component without a Spring dependency. I am using Tibco as the
> JMS provider and it is providing JNDI.
>

It must be a touch workplace when a general considered standard
framework is considered evil?

The camel-jms component leverages spring-jms for sending and receiving
JMS messages and therefore
you cannot use it without spring-jms.

You can use plain JMS API if you want to avoid Spring and build a JMS consumer.
For examples see the ActiveMQ in Action which shows that. And I am
sure you may find other examples by googling as well.

To send the message to Camel is very easy from Java code. For example
just use the ProducerTemplate API.



> Here is a sample code snippet which shows the JNDI and JMS setup that I need
> for the component:
>
> final CamelContext context = new DefaultCamelContext();
> final Hashtable env = new Hashtable();
> env.put(Context.INITIAL_CONTEXT_FACTORY,
> "com.tibco.tibjms.naming.TibjmsInitialContextFactory");
> env.put(Context.PROVIDER_URL, Constants.TOPIC_PROVIDER_URL));
> env.put(Context.SECURITY_PRINCIPAL, Constants.TOPIC_SECURITY_PRINCIPAL));
> env.put(Context.SECURITY_CREDENTIALS,
> Constants.TOPIC_SECURITY_CREDENTIALS));
> final Context jndiContext = new InitialContext(env);
> final TopicConnectionFactory topicConnectionFactory =
> (TopicConnectionFactory)
> jndiContext.lookup(Constants.TOPIC_CONNECTION_FACTORY));
>
> context.addComponent("tibco",
> JmsComponent.jmsComponentAutoAcknowledge(topicConnectionFactory));
>
>
> This compiles without any Spring JARs but, when I run it I get the following
> exception thrown by the last line of code:
>
>
> Caused by: java.lang.ClassNotFoundException:
> org.springframework.context.ApplicationContextAware
>
>
>
> NOTE: I am currently looking into the possibility that this is actually an
> issue with the DefaultCamelContext being dependent on Spring rather that it
> being a JMS or component issue. In any case, I would appreciate any advice
> or guidance on this.
>



-- 
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