You are viewing a plain text version of this content. The canonical link for it is here.
Posted to dev@camel.apache.org by ghepardo <e....@hotmail.com> on 2011/07/21 11:09:02 UTC
Developing Oracle Coherence 3.7 Camel Component
Hi,
I am starting developing an Oracle Coherence Camel Component (that I am
intentioned to donate), that will support Topics and Queues.
I would like to ask you some advices, if there is some component more than
other to look at.
Thanks a lot to everyone answering,
Emanuele.
--
View this message in context: http://camel.465427.n5.nabble.com/Developing-Oracle-Coherence-3-7-Camel-Component-tp4618649p4618649.html
Sent from the Camel Development mailing list archive at Nabble.com.
Re: Developing Oracle Coherence 3.7 Camel Component - License
problems
Posted by "E.Gherardini" <e....@hotmail.com>.
Hi,
I finished the component and shared my code on google code.
http://code.google.com/p/oracle-coherence-camel-component/
--
View this message in context: http://camel.465427.n5.nabble.com/Developing-Oracle-Coherence-3-7-Camel-Component-tp4618649p4662068.html
Sent from the Camel Development mailing list archive at Nabble.com.
Re: Developing Oracle Coherence 3.7 Camel Component - License problems
Posted by Richard Kettelerij <ri...@gmail.com>.
Not an answer but we discussed this topic (and your component) here:
http://camel.465427.n5.nabble.com/DISCUSS-Components-relying-on-commercial-software-td4621208.html
On Thu, Jul 28, 2011 at 12:36 PM, E.Gherardini <e....@hotmail.com>wrote:
> Hi all,
> I almost finished writing the component.
>
> I need to write some more complete test (for which suggestions are welcome
> ;) ) and exposing some coherence-related parameters.
>
> My main concerns now regards licences.
>
> Oracle Coherence is not a free product, but we knew it.
>
> My code is based on the Coherence Messaging Pattern from Oracle Coherence
> Incubator:
> http://coherence.oracle.com/display/INC10/coherence-incubator-examples
>
> The code here is free to download (and includes sources) but each class has
> an Oracle terms-of-use statement, mainly stating that the code is property
> of Oracle.
>
> How can I release this component to the community ?
>
> --
> View this message in context:
> http://camel.465427.n5.nabble.com/Developing-Oracle-Coherence-3-7-Camel-Component-tp4618649p4642077.html
> Sent from the Camel Development mailing list archive at Nabble.com.
>
Re: Developing Oracle Coherence 3.7 Camel Component - License
problems
Posted by "E.Gherardini" <e....@hotmail.com>.
Hi all,
I almost finished writing the component.
I need to write some more complete test (for which suggestions are welcome
;) ) and exposing some coherence-related parameters.
My main concerns now regards licences.
Oracle Coherence is not a free product, but we knew it.
My code is based on the Coherence Messaging Pattern from Oracle Coherence
Incubator:
http://coherence.oracle.com/display/INC10/coherence-incubator-examples
The code here is free to download (and includes sources) but each class has
an Oracle terms-of-use statement, mainly stating that the code is property
of Oracle.
How can I release this component to the community ?
--
View this message in context: http://camel.465427.n5.nabble.com/Developing-Oracle-Coherence-3-7-Camel-Component-tp4618649p4642077.html
Sent from the Camel Development mailing list archive at Nabble.com.
Re: Developing Oracle Coherence 3.7 Camel Component
Posted by ghepardo <e....@hotmail.com>.
Hi!
Thanks for answering!
I didn't choose the simplest component indeed ;)
But the harder the better: I will learn more, thanks also to your patience
and help ;)
I will for sure come with new questions as they arise in my mind: I want to
contribute in the best way possible.
--
View this message in context: http://camel.465427.n5.nabble.com/Developing-Oracle-Coherence-3-7-Camel-Component-tp4618649p4635823.html
Sent from the Camel Development mailing list archive at Nabble.com.
Re: Developing Oracle Coherence 3.7 Camel Component
Posted by Christian Müller <ch...@gmail.com>.
Hello Emanuele!
It looks like you didn't choose a simple component as you first one... ;-)
Don't hesitate to come back with further questions, if you have some. I
think the SedaConsumer is a good starting point to look into [1].
[1]
https://svn.apache.org/repos/asf/camel/trunk/camel-core/src/main/java/org/apache/camel/component/seda/SedaConsumer.java
Best,
Christian
Re: Developing Oracle Coherence 3.7 Camel Component
Posted by Claus Ibsen <cl...@gmail.com>.
On Tue, Jul 26, 2011 at 5:22 PM, ghepardo <e....@hotmail.com> wrote:
> Hi,
> thanks for answering.
>
> My main concern is this:
> in coherence, to listen for a message, I have a blocking call
> (subscription.getMessage()).
>
> I cannot invoke this call inside the overridden doStart() or start()
> methods, because, to my knowledge, these would block camel.
>
> The only way I found is to start a new thread and let it perform this
> blocking call.
>
>
> Is this the correct way to deal with blocking calls inside a Consumer ?
>
Yeah that is correct.
Mind that if you use a blocking call to coherence, then you may block
for a long time.
And when you shutdown your application, that blocking call has to be
interrupted. So you may have to handle this in a gentle way when
shutting down / stopping.
In the Camel seda consumer we use a timeout, to have a more gentle way
of knowing if we are stopping.
And mind that in the runnable, if you exit the runnable (such as a
throwable exception was thrown etc.) then the thread terminates. And
the consumer will not pickup new messages. So you have to deal with
that as well.
> Thanks.
>
> --
> View this message in context: http://camel.465427.n5.nabble.com/Developing-Oracle-Coherence-3-7-Camel-Component-tp4618649p4635220.html
> Sent from the Camel Development mailing list archive at Nabble.com.
>
--
Claus Ibsen
-----------------
FuseSource
Email: cibsen@fusesource.com
Web: http://fusesource.com
Twitter: davsclaus, fusenews
Blog: http://davsclaus.blogspot.com/
Author of Camel in Action: http://www.manning.com/ibsen/
Re: Developing Oracle Coherence 3.7 Camel Component
Posted by ghepardo <e....@hotmail.com>.
Hi,
thanks for answering.
My main concern is this:
in coherence, to listen for a message, I have a blocking call
(subscription.getMessage()).
I cannot invoke this call inside the overridden doStart() or start()
methods, because, to my knowledge, these would block camel.
The only way I found is to start a new thread and let it perform this
blocking call.
Is this the correct way to deal with blocking calls inside a Consumer ?
Thanks.
--
View this message in context: http://camel.465427.n5.nabble.com/Developing-Oracle-Coherence-3-7-Camel-Component-tp4618649p4635220.html
Sent from the Camel Development mailing list archive at Nabble.com.
Re: Developing Oracle Coherence 3.7 Camel Component
Posted by Claus Ibsen <cl...@gmail.com>.
On Tue, Jul 26, 2011 at 2:59 PM, Richard Kettelerij
<ri...@gmail.com> wrote:
> Hi ghepardo,
>
> It's advisable to use the ExecuterServiceStrategy instead of starting your
> own thread, see http://camel.apache.org/threading-model.html. That way your
> component is ready for containers that don't support unmanaged threads (like
> AppEngine or something like Websphere).
>
As Richard said the ExecutorServiceStrategy allows end users to better
control and plugin 3rd party thread pool providers.
Likewise when using that Camel will ensures thread is given a
consistent an unique name, so they are easier to spot in the logs. End
users can as well configure the pattern for the name syntax Camel
uses.
Also when Camel shutdown, it ensures all thread pools is shutdown as
well, to ensure no hanging resources etc. That is important when you
run in containers and when doing hot deploys etc.
> Futhermore since your keeping state is Subscriber thread-safe?
>
> Regards,
> Richard
>
> On Tue, Jul 26, 2011 at 2:32 PM, ghepardo <e....@hotmail.com> wrote:
>
>> Hi,
>> thanks for answering. I already went throught that pages. I will make my
>> question more specific.
>>
>> Here is the code of my simple consumer:
>> "
>> public class CoherenceQueueConsumer extends DefaultConsumer implements
>> Runnable {
>>
>> private final CoherenceQueueEndpoint queueEndpoint;
>> private Subscriber subscription;
>>
>> public CoherenceQueueConsumer(CoherenceQueueEndpoint endpoint,
>> Processor
>> processor) {
>> super(endpoint, processor);
>> this.queueEndpoint = endpoint;
>> log.info("CoherenceQueueConsumer succesfully created: " +
>> this);
>> }
>>
>>
>> @Override
>> protected void doStart() throws Exception {
>> super.doStart();
>> MessagingSession session =
>> this.queueEndpoint.getMessagingSession();
>> this.subscription =
>> session.subscribe(this.queueEndpoint.getQueueIdentifier());
>> this.subscription.setAutoCommit(false);
>> new Thread(this).start();
>> log.info("Consumer ["+this+"] started");
>> }
>>
>>
>> @Override
>> protected void doStop() throws Exception {
>> this.subscription.unsubscribe();
>> log.info("Consumer ["+this+"] unsubscribed.");
>> super.doStop();
>> }
>>
>> public void run() {
>> this.consumeMessages();
>> }
>>
>>
>> private void consumeMessages() {
>>
>> log.info("Consumer ["+this+"] is consuming messages...");
>>
>> while(isRunAllowed()) {
>>
>> Object rawMessage = subscription.getMessage();
>> log.info("Received Message: [" +rawMessage+"]");
>>
>> Exchange ex = getEndpoint().createExchange();
>> ex.getIn().setBody(rawMessage);
>>
>> try {
>> getProcessor().process(ex);
>> this.subscription.commit();
>> } catch (Exception e) {
>> log.error("Exeception occurred consuming
>> message", e);
>> this.subscription.rollback();
>> }
>> }
>>
>> }
>>
>>
>> @Override
>> public String toString() {
>> return "CoherenceQueueConsumer [queueEndpoint=" +
>> queueEndpoint + "]";
>> }
>>
>>
>> }
>> "
>>
>> As you can see, to start effectively receiving messages from the Oracle
>> Coherence Queue, I start a new thread that calls the blocking method
>> "subscription.getMessage()".
>>
>> My question is: is this approach correct ? Am I allowed to "rawly" create a
>> new thread for each consumer or should I use the
>> org.apache.camel.util.concurrent.ExecutorServiceHelper ?
>>
>> Thanks a lot.
>>
>> p.s. I am a volounter too, so I also don't have so much time ;)
>>
>> --
>> View this message in context:
>> http://camel.465427.n5.nabble.com/Developing-Oracle-Coherence-3-7-Camel-Component-tp4618649p4634601.html
>> Sent from the Camel Development mailing list archive at Nabble.com.
>>
>
--
Claus Ibsen
-----------------
FuseSource
Email: cibsen@fusesource.com
Web: http://fusesource.com
Twitter: davsclaus, fusenews
Blog: http://davsclaus.blogspot.com/
Author of Camel in Action: http://www.manning.com/ibsen/
Re: Developing Oracle Coherence 3.7 Camel Component
Posted by Richard Kettelerij <ri...@gmail.com>.
Hi ghepardo,
It's advisable to use the ExecuterServiceStrategy instead of starting your
own thread, see http://camel.apache.org/threading-model.html. That way your
component is ready for containers that don't support unmanaged threads (like
AppEngine or something like Websphere).
Futhermore since your keeping state is Subscriber thread-safe?
Regards,
Richard
On Tue, Jul 26, 2011 at 2:32 PM, ghepardo <e....@hotmail.com> wrote:
> Hi,
> thanks for answering. I already went throught that pages. I will make my
> question more specific.
>
> Here is the code of my simple consumer:
> "
> public class CoherenceQueueConsumer extends DefaultConsumer implements
> Runnable {
>
> private final CoherenceQueueEndpoint queueEndpoint;
> private Subscriber subscription;
>
> public CoherenceQueueConsumer(CoherenceQueueEndpoint endpoint,
> Processor
> processor) {
> super(endpoint, processor);
> this.queueEndpoint = endpoint;
> log.info("CoherenceQueueConsumer succesfully created: " +
> this);
> }
>
>
> @Override
> protected void doStart() throws Exception {
> super.doStart();
> MessagingSession session =
> this.queueEndpoint.getMessagingSession();
> this.subscription =
> session.subscribe(this.queueEndpoint.getQueueIdentifier());
> this.subscription.setAutoCommit(false);
> new Thread(this).start();
> log.info("Consumer ["+this+"] started");
> }
>
>
> @Override
> protected void doStop() throws Exception {
> this.subscription.unsubscribe();
> log.info("Consumer ["+this+"] unsubscribed.");
> super.doStop();
> }
>
> public void run() {
> this.consumeMessages();
> }
>
>
> private void consumeMessages() {
>
> log.info("Consumer ["+this+"] is consuming messages...");
>
> while(isRunAllowed()) {
>
> Object rawMessage = subscription.getMessage();
> log.info("Received Message: [" +rawMessage+"]");
>
> Exchange ex = getEndpoint().createExchange();
> ex.getIn().setBody(rawMessage);
>
> try {
> getProcessor().process(ex);
> this.subscription.commit();
> } catch (Exception e) {
> log.error("Exeception occurred consuming
> message", e);
> this.subscription.rollback();
> }
> }
>
> }
>
>
> @Override
> public String toString() {
> return "CoherenceQueueConsumer [queueEndpoint=" +
> queueEndpoint + "]";
> }
>
>
> }
> "
>
> As you can see, to start effectively receiving messages from the Oracle
> Coherence Queue, I start a new thread that calls the blocking method
> "subscription.getMessage()".
>
> My question is: is this approach correct ? Am I allowed to "rawly" create a
> new thread for each consumer or should I use the
> org.apache.camel.util.concurrent.ExecutorServiceHelper ?
>
> Thanks a lot.
>
> p.s. I am a volounter too, so I also don't have so much time ;)
>
> --
> View this message in context:
> http://camel.465427.n5.nabble.com/Developing-Oracle-Coherence-3-7-Camel-Component-tp4618649p4634601.html
> Sent from the Camel Development mailing list archive at Nabble.com.
>
Re: Developing Oracle Coherence 3.7 Camel Component
Posted by ghepardo <e....@hotmail.com>.
Hi,
thanks for answering. I already went throught that pages. I will make my
question more specific.
Here is the code of my simple consumer:
"
public class CoherenceQueueConsumer extends DefaultConsumer implements
Runnable {
private final CoherenceQueueEndpoint queueEndpoint;
private Subscriber subscription;
public CoherenceQueueConsumer(CoherenceQueueEndpoint endpoint, Processor
processor) {
super(endpoint, processor);
this.queueEndpoint = endpoint;
log.info("CoherenceQueueConsumer succesfully created: " + this);
}
@Override
protected void doStart() throws Exception {
super.doStart();
MessagingSession session = this.queueEndpoint.getMessagingSession();
this.subscription =
session.subscribe(this.queueEndpoint.getQueueIdentifier());
this.subscription.setAutoCommit(false);
new Thread(this).start();
log.info("Consumer ["+this+"] started");
}
@Override
protected void doStop() throws Exception {
this.subscription.unsubscribe();
log.info("Consumer ["+this+"] unsubscribed.");
super.doStop();
}
public void run() {
this.consumeMessages();
}
private void consumeMessages() {
log.info("Consumer ["+this+"] is consuming messages...");
while(isRunAllowed()) {
Object rawMessage = subscription.getMessage();
log.info("Received Message: [" +rawMessage+"]");
Exchange ex = getEndpoint().createExchange();
ex.getIn().setBody(rawMessage);
try {
getProcessor().process(ex);
this.subscription.commit();
} catch (Exception e) {
log.error("Exeception occurred consuming message", e);
this.subscription.rollback();
}
}
}
@Override
public String toString() {
return "CoherenceQueueConsumer [queueEndpoint=" + queueEndpoint + "]";
}
}
"
As you can see, to start effectively receiving messages from the Oracle
Coherence Queue, I start a new thread that calls the blocking method
"subscription.getMessage()".
My question is: is this approach correct ? Am I allowed to "rawly" create a
new thread for each consumer or should I use the
org.apache.camel.util.concurrent.ExecutorServiceHelper ?
Thanks a lot.
p.s. I am a volounter too, so I also don't have so much time ;)
--
View this message in context: http://camel.465427.n5.nabble.com/Developing-Oracle-Coherence-3-7-Camel-Component-tp4618649p4634601.html
Sent from the Camel Development mailing list archive at Nabble.com.
Re: Developing Oracle Coherence 3.7 Camel Component
Posted by Christian Müller <ch...@gmail.com>.
Hello Emanuele!
We have a page which covers the Apache Camel architecture and the life cycle
[1]. This page also contains links to other useful pages.
As Claus already mentioned, we have a page with guides you to the process of
adding a new component [2].
If you have concrete questions how you should implement a functionality,
have a look into similar components Camel already provides [3]. If you
cannot find a similar component (or doesn't understand the code of the
existing ones), come back to the list and ask the people here. It's helpfull
for us to understand what you try to do (please explain what you try to do).
If you could add your current code, it would also be helpful.
And may be it takes a few days until you will receive a response (especially
if it's not so easy to answer or when we have to study your code first),
because some of us working as volunteer on this project... (I'm currently in
vacation and have a bit more time.. :-) )
[1] http://camel.apache.org/lifecycle.html
[2] http://camel.apache.org/add-new-component-guide.html
[3] http://camel.apache.org/components
Best,
Christian
RE: Developing Oracle Coherence 3.7 Camel Component
Posted by ghepardo <e....@hotmail.com>.
Hi again,I am going through the development (going slow since these days I don't have so much time). I have 2 questions:1) are there any "guidelines" / "best practices" in writing components? (i.e. in my current embryo, a queue consume starts a new thread (in the doStart() method) to start effectively consuming messages: is this a good way to do it or should I use some Camel service ?). 2) is there any detailed documentation new-developer-oriented to get insights about the camel architecture/lifecycle ? All of this questions arise to me since, reading the "seda-component" source code, I can't figure out who is calling starting the consumer thread, since the SedaConsumer implements Runnable. I am sorry if these sounds too "stupid" or "newbye" questions, but this is my first (but not last ;) ) OpenSource project I contribute. Thanks,
Emanuele Gherardini
Date: Thu, 21 Jul 2011 05:56:48 -0700
From: ml-node+4619310-2043751961-233052@n5.nabble.com
To: e.gherardini@hotmail.com
Subject: Re: Developing Oracle Coherence 3.7 Camel Component
Correction: I meant camel-cache (not camel-ehcache).
On Thu, Jul 21, 2011 at 2:54 PM, Richard Kettelerij <
[hidden email]> wrote:
> Hi,
>
> You may want to take a look at camel-ehcache, since Coherence shares many
> similarities with EHCache. Otherwise just take a look at a few components to
> get a feeling how these are organized (classes like endpoint, producer,
> consumer, configuration, etc).
>
> Regards,
> Richard
>
>
> On Thu, Jul 21, 2011 at 2:44 PM, ghepardo <[hidden email]>wrote:
>
>> Thanks a lot for answering Claus.
>>
>> I meant, and if you have time to suggest, is there any component I should
>> particularry take as example, to avoid doing common mistakes ?
>>
>> Thanks again,
>>
>> Emanuele
>>
>> --
>> View this message in context:
>> http://camel.465427.n5.nabble.com/Developing-Oracle-Coherence-3-7-Camel-Component-tp4618649p4619260.html
>> Sent from the Camel Development mailing list archive at Nabble.com.
>>
>
>
If you reply to this email, your message will be added to the discussion below:
http://camel.465427.n5.nabble.com/Developing-Oracle-Coherence-3-7-Camel-Component-tp4618649p4619310.html
To unsubscribe from Developing Oracle Coherence 3.7 Camel Component, click here.
--
View this message in context: http://camel.465427.n5.nabble.com/Developing-Oracle-Coherence-3-7-Camel-Component-tp4618649p4632613.html
Sent from the Camel Development mailing list archive at Nabble.com.
Re: Developing Oracle Coherence 3.7 Camel Component
Posted by Richard Kettelerij <ri...@gmail.com>.
Correction: I meant camel-cache (not camel-ehcache).
On Thu, Jul 21, 2011 at 2:54 PM, Richard Kettelerij <
richardkettelerij@gmail.com> wrote:
> Hi,
>
> You may want to take a look at camel-ehcache, since Coherence shares many
> similarities with EHCache. Otherwise just take a look at a few components to
> get a feeling how these are organized (classes like endpoint, producer,
> consumer, configuration, etc).
>
> Regards,
> Richard
>
>
> On Thu, Jul 21, 2011 at 2:44 PM, ghepardo <e....@hotmail.com>wrote:
>
>> Thanks a lot for answering Claus.
>>
>> I meant, and if you have time to suggest, is there any component I should
>> particularry take as example, to avoid doing common mistakes ?
>>
>> Thanks again,
>>
>> Emanuele
>>
>> --
>> View this message in context:
>> http://camel.465427.n5.nabble.com/Developing-Oracle-Coherence-3-7-Camel-Component-tp4618649p4619260.html
>> Sent from the Camel Development mailing list archive at Nabble.com.
>>
>
>
Re: Developing Oracle Coherence 3.7 Camel Component
Posted by Richard Kettelerij <ri...@gmail.com>.
Hi,
You may want to take a look at camel-ehcache, since Coherence shares many
similarities with EHCache. Otherwise just take a look at a few components to
get a feeling how these are organized (classes like endpoint, producer,
consumer, configuration, etc).
Regards,
Richard
On Thu, Jul 21, 2011 at 2:44 PM, ghepardo <e....@hotmail.com> wrote:
> Thanks a lot for answering Claus.
>
> I meant, and if you have time to suggest, is there any component I should
> particularry take as example, to avoid doing common mistakes ?
>
> Thanks again,
>
> Emanuele
>
> --
> View this message in context:
> http://camel.465427.n5.nabble.com/Developing-Oracle-Coherence-3-7-Camel-Component-tp4618649p4619260.html
> Sent from the Camel Development mailing list archive at Nabble.com.
>
Re: Developing Oracle Coherence 3.7 Camel Component
Posted by ghepardo <e....@hotmail.com>.
Thanks a lot for answering Claus.
I meant, and if you have time to suggest, is there any component I should
particularry take as example, to avoid doing common mistakes ?
Thanks again,
Emanuele
--
View this message in context: http://camel.465427.n5.nabble.com/Developing-Oracle-Coherence-3-7-Camel-Component-tp4618649p4619260.html
Sent from the Camel Development mailing list archive at Nabble.com.
Re: Developing Oracle Coherence 3.7 Camel Component
Posted by Claus Ibsen <cl...@gmail.com>.
Hi
On Thu, Jul 21, 2011 at 11:09 AM, ghepardo <e....@hotmail.com> wrote:
> Hi,
> I am starting developing an Oracle Coherence Camel Component (that I am
> intentioned to donate), that will support Topics and Queues.
>
Ah cool.
> I would like to ask you some advices, if there is some component more than
> other to look at.
>
There is a guide how to build a new component here
http://camel.apache.org/add-new-component-guide.html
You may find inspiration in some of the existing components, how to develop.
http://camel.apache.org/components
The source code is here
http://camel.apache.org/source.html
If you have the Camel in Action book, then chapter 11 talks about
creating a custom component.
But its really easy, and hence why there is so many components.
> Thanks a lot to everyone answering,
>
> Emanuele.
>
> --
> View this message in context: http://camel.465427.n5.nabble.com/Developing-Oracle-Coherence-3-7-Camel-Component-tp4618649p4618649.html
> Sent from the Camel Development mailing list archive at Nabble.com.
>
--
Claus Ibsen
-----------------
FuseSource
Email: cibsen@fusesource.com
Web: http://fusesource.com
Twitter: davsclaus, fusenews
Blog: http://davsclaus.blogspot.com/
Author of Camel in Action: http://www.manning.com/ibsen/