Re: reading http endpoint from properties files

2012-01-26 Thread Marco Westermann

Hi

what you need is the properties component. Look here: 
http://camel.apache.org/properties.html


then you can refer your endpoint like this

.to("{{myHttpEndpoint}}")

where you have that defined in your properties like this:

myHttpEndpoint=http://servername.com/test

regards, Marco

Am 26.01.2012 01:00, schrieb anand sridhar:

Hi,
I have a route with the endpoint being a HTTP URL.
It so happens that this URL is in a  properties file.

Could some one help me to understand how I can dynamically load the end
point name from a property file or in general from header, property etc..?

apparently, none of these work

from("jms:q1")
.to("${properties:httpurl}")

or
from("jms:q1")
.to(header("httpurl"));

or

from("jms:q1")
.to(property("httpurl"));

does not resolve even though the httpurl parameter is present in header as
well as property.

Thanks,
Anand





Re: reading http endpoint from properties files

2012-01-26 Thread Claus Ibsen
Hi

See this FAQ
http://camel.apache.org/how-do-i-use-dynamic-uri-in-to.html

Or you can define the endpoint using property placeholders
http://camel.apache.org/using-propertyplaceholder.html
http://camel.apache.org/how-do-i-use-spring-property-placeholder-with-camel-xml.html


On Thu, Jan 26, 2012 at 1:00 AM, anand sridhar  wrote:
> Hi,
> I have a route with the endpoint being a HTTP URL.
> It so happens that this URL is in a  properties file.
>
> Could some one help me to understand how I can dynamically load the end
> point name from a property file or in general from header, property etc..?
>
> apparently, none of these work
>
> from("jms:q1")
> .to("${properties:httpurl}")
>
> or
> from("jms:q1")
> .to(header("httpurl"));
>
> or
>
> from("jms:q1")
> .to(property("httpurl"));
>
> does not resolve even though the httpurl parameter is present in header as
> well as property.
>
> Thanks,
> Anand



-- 
Claus Ibsen
-
FuseSource
Email: cib...@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: Camel sftp endpoint and exception handling.

2012-01-26 Thread Raul
Hello again,

I have relized that I must use a ProcessStrategy instead of PollStrategy.
ProcessStrategy can be used in the uri like pollStrategy

uri = "ftp://..&processStrategy=#myProcessStrategy";;

This parameter is of Camel-File2 and FTP2 inherits it.

I am using the GenericFileRenameProcessStrategy. Now, The route doesn't
thrown the Exception, but I don't control what it's happening because I
don't know how I must design my ProcessStrategy, also I have seen in FTP-2.8
appeared a new "classs
"org.apache.camel.component.file.remote.strategy.*FtpProcessStrategyFactory*"
but I haven't found any example.

Someone has used a custom processStrategy or someone knows how use
FtpProcessStrategyFactory.

Thank you again.




--
View this message in context: 
http://camel.465427.n5.nabble.com/Camel-sftp-endpoint-and-exception-handling-tp5114385p5432298.html
Sent from the Camel - Users mailing list archive at Nabble.com.


Re: Splitting on XML Documents

2012-01-26 Thread Łukasz Dywicki
I think you should not have any problems, the conversion is really simple. 
After split statement you have a Node as body. For XSLT you need a Source. Try 
adding this instead setBody



That should force conversion to document object and I belive fix your problem.

Best regards,
Łukasz Dywicki
--
Code-House
http://code-house.org


Wiadomość napisana przez Chris Geer w dniu 2012-01-26, o godz. 01:36:

> Doug,
> 
> It doesn't make much sense to me either but I do know that with the setBody
> command everything works and without it, it fails. If I run the XSLT
> against the same XML (save the XML to a file from the flow after the split)
> in netbeans it works fine without the  but in camel it fails.
> 
> Could the split be converting the output to a string? That would explain
> the problem.
> 
> Chris
> 
> On Wed, Jan 25, 2012 at 5:03 PM, Doug Douglass wrote:
> 
>> Chris,
>> 
>> I think the xml processing "fix" you've got there is a bit of red-herring.
>> 
>> The xml processing instruction should only be necessary if you are
>> converting the output of the xpath to a String prior to the xslt endpoint,
>> whether directly or indirectly. Without any explicit conversion, the output
>> of the xpath will be a Node object (DeferredElementNSImpl in my test),
>> which is converted to a Source via camel's built-in type conversion.
>> 
>> I just set up a quick unit test with a route very similar to yours and
>> everything worked as I expected. Granted this test was in an existing
>> project using camel 2.7.3 (time to upgrade!).
>> 
>> I suspect you're either running into a namespace problem[1] or your
>> templates XPaths aren't expecting Parcel (from your example) as the root
>> element.
>> 
>> [1]
>> http://camel.apache.org/xpath.html#XPath-Namespaceauditingtoaiddebugging
>> 
>> Let us know more info (example XML and XSLT) if my suspicions are off base.
>> 
>> HTH,
>> Doug
>> 
>> On Wed, Jan 25, 2012 at 3:35 PM, Chris Geer  wrote:
>> 
>>> Sorry, 2.8.3.
>>> 
>>> On Wed, Jan 25, 2012 at 3:29 PM, Babak Vahdat
>>> wrote:
>>> 
 And what about the Camel version you use?
 
 Babak
 
 --
 View this message in context:
 
>>> 
>> http://camel.465427.n5.nabble.com/Splitting-on-XML-Documents-tp5431032p5431531.html
 Sent from the Camel - Users mailing list archive at Nabble.com.
 
>>> 
>> 



Re: Problems implementing a delay in a camel route

2012-01-26 Thread Tom Howe
Hi, can anyone help with this.. specifically computeDelay() method never
appears to be called..

  
  
   
   
 

We are using camel 2.7.1 and found this post which suggests that the above
config should work..

http://camel.465427.n5.nabble.com/Delayer-and-asyncDelayed-how-to-delay-asynchronously-td3252456.html

It seems to work ok using the java DSL eg
from(...).delay().method(instance, "method").to(..)

Thanks, Tom


On Tue, Jan 24, 2012 at 3:42 PM, Mike Spelling wrote:

>
>
>
>
>
>
>
>
>
> I'm using Camel v2.7.1 and trying to configure a route to apply a delay to
> incoming messages before passing them on to another queue. I've read about
> a similar problem at
> http://osdir.com/ml/users-camel-apache/2010-11/msg00134.html but the
> answer did not seem to work for me.
> I don't think I can use  a  in the  block  as
> this would block incoming messages, making new messages have to wait for
> any previous messages to be routed before having another delay applied. The
> attribute asyncDelayed="true" in the  block appeared to use a
> thread per message to ensure the correct delay was applied which will
> quickly use up the maxConcurrentConsumers.
> I therefore wanted to pass the delay block a custom method to calculate
> for correct delay from the JMSHeader Timestamp.
>
>
>
>
>
>
>
>
> My Camel configuration contains:
> 
>
> http://www.springframework.org/schema/beans";
>
>xmlns:xsi="http://www.w3.org/2001/XMLSchema-instance";
>
>   xmlns:camel="http://camel.apache.org/schema/spring";
>
>xsi:schemaLocation="http://www.springframework.org/schema/beans
> http://www.springframework.org/schema/beans/spring-beans-3.0.xsd
>
>http://camel.apache.org/schema/spring
> http://camel.apache.org/schema/spring/camel-spring-2.0-M1.xsd";>
>
>
>
>
>
>
>
>
>
>
>
> uri="activemq:l2vc.pending?transacted=true" />
>
> uri="activemq:l2vc.retrywait" />
>
>
>
>
>
> 
>
>
>
>   
>
>
> 
>
>
>
>
>
>
>
>
>
> 
> My bean is below:
>
>
> package myPackage;
> @Componentpublic class RetryDelayCompute {  final
> static long TOTAL_DELAY_ON_QUEUE = 11000; public long
> computeDelay(@Header("JMSTimestamp") long jmsTimestamp) {
> System.out.println("Calculating delay..."); long now =
> System.currentTimeMillis();  long timeOnQueue = now - jmsTimestamp;
>  return TOTAL_DELAY_ON_QUEUE - timeOnQueue;  }}
> On running tests the method is never called. Although the component is
> instantiated the logs show that the method never runs. Messages are simply
> routed to the correct queue with no delay.
> Any help appreciated!
> Thanks,
> Mike


Component Design - SMSLib

2012-01-26 Thread Alex Anderson
I'm working on a Camel component for SMSLib (http://www.smslib.org).
This is a Java library for communicating with mobile phones and modems
via a serial connection to send and receive SMS messages using the
Hayes (AT) command set.

I have a working prototype - you can see the source at
https://github.com/frontlinesms/camel-smslib

I have some general worries regards best-practice for designing the
Endpoint, Consumer and Producer for this component.  I've not come
across comprehensive documentation for implementing Endpoints etc.,
and it's hard to know which other components would have a similar
model to mine and therefore would be worth delving into the source of.


Notes on serial devices
---
* before starting to send or receive messages through a device it must
be initialised
* initialisation can fail


Endpoint

Each Endpoint will refer to a serial port, with corresponding URIs, e.g.:
* Windows: smslib:COM1
* Linux: smslib:/dev/tty01

When Endpoints are initially created, settings for the port (e.g. baud
rate) are passed to it.  Later we may want to create endpoints for the
same port with different settings, but only if the original endpoint
is no longer in use.


Consumer

There should be a maximum of 1 consumer per endpoint.  The serial port
must be polled to check for incoming SMS.  Rather than storing the SMS
within the Smslib service, I would like to pass them immediately
upstream to the Consumer's Processor.


Producer

For my usage, I would like a single Producer per endpoint.  This is
primarily because when there are no active producers or consumers for
an endpoint, the serial connection can be closed to allow its use by
other programs.  It may be reasonable for other uses to have multiple
Producers for the same endpoint.


Current status
--
The endpoint has a Thread (implemented in a class SmslibService) which
controls the receiving from the serial connection - every 30 seconds
the thread wakes and checks the modem for new incoming messages.  This
SmslibService keeps a reference to a Producer and a Consumer, and
should shut down the serial connection when both Consumer and Producer
are stopped.

Trying to create more than one Producer or Consumer for an Endpoint
will cause an Exception to be thrown.

This causes problems when the settings used to create an endpoint
initially are bad - there will be an Exception thrown in
SmslibProducer.doStart()


My Questions

* are there any good resources for writing Endpoints that I should be reading?
* does anyone know of any similarly-modelled components whose source
might provide guidance?
* are there any patterns or base classes that I should obviously be
using for my Component, Endpoint, Consumer or Producer
implementations?
* is there anyone else interested in this component who could cast an
eye over the code?


Bindy - Setting the property of the field with @DataField using getter methods

2012-01-26 Thread Aida
Hi,

I wanted to know if there's a way to use @DataField annotation not in the
class properties but in the getters of the class. The thing is that I need
to extend the domain class (auto-generated), and from the extended class use
bindy annotations. 

I have already implemented an example with bindy (with a standard POJO) that
works, but now I need something similar to what I said above.

I tried this (using @DataField annotation in the getters) but I have an
error like "IllegalArgumentException: No position N defined for the field:
, line: 1 must be specified" so I suppose it's not possible, but maybe
there are other ways ...

Thanks in advance.



--
View this message in context: 
http://camel.465427.n5.nabble.com/Bindy-Setting-the-property-of-the-field-with-DataField-using-getter-methods-tp5432980p5432980.html
Sent from the Camel - Users mailing list archive at Nabble.com.


Re: Splitting on XML Documents

2012-01-26 Thread Doug Douglass
Excellent suggestion Łukasz!

Chris, have a look at
http://camel.apache.org/xslt.html#XSLT-NotesonusingXSLTandJavaVersions,
perhaps that will resolve your issue. For my quick unit test I'm using
openjdk 1.6.0_22 (ArchLinux-6.b22_1.10.5-1-x86_64) and xalan 2.6.0 was
already in my projects dependencies/classpath.

Doug


2012/1/26 Łukasz Dywicki 

> I think you should not have any problems, the conversion is really simple.
> After split statement you have a Node as body. For XSLT you need a Source.
> Try adding this instead setBody
>
> 
>
> That should force conversion to document object and I belive fix your
> problem.
>
> Best regards,
> Łukasz Dywicki
> --
> Code-House
> http://code-house.org
>
>
> Wiadomość napisana przez Chris Geer w dniu 2012-01-26, o godz. 01:36:
>
> > Doug,
> >
> > It doesn't make much sense to me either but I do know that with the
> setBody
> > command everything works and without it, it fails. If I run the XSLT
> > against the same XML (save the XML to a file from the flow after the
> split)
> > in netbeans it works fine without the  but in camel it fails.
> >
> > Could the split be converting the output to a string? That would explain
> > the problem.
> >
> > Chris
> >
> > On Wed, Jan 25, 2012 at 5:03 PM, Doug Douglass  >wrote:
> >
> >> Chris,
> >>
> >> I think the xml processing "fix" you've got there is a bit of
> red-herring.
> >>
> >> The xml processing instruction should only be necessary if you are
> >> converting the output of the xpath to a String prior to the xslt
> endpoint,
> >> whether directly or indirectly. Without any explicit conversion, the
> output
> >> of the xpath will be a Node object (DeferredElementNSImpl in my test),
> >> which is converted to a Source via camel's built-in type conversion.
> >>
> >> I just set up a quick unit test with a route very similar to yours and
> >> everything worked as I expected. Granted this test was in an existing
> >> project using camel 2.7.3 (time to upgrade!).
> >>
> >> I suspect you're either running into a namespace problem[1] or your
> >> templates XPaths aren't expecting Parcel (from your example) as the root
> >> element.
> >>
> >> [1]
> >>
> http://camel.apache.org/xpath.html#XPath-Namespaceauditingtoaiddebugging
> >>
> >> Let us know more info (example XML and XSLT) if my suspicions are off
> base.
> >>
> >> HTH,
> >> Doug
> >>
> >> On Wed, Jan 25, 2012 at 3:35 PM, Chris Geer 
> wrote:
> >>
> >>> Sorry, 2.8.3.
> >>>
> >>> On Wed, Jan 25, 2012 at 3:29 PM, Babak Vahdat
> >>> wrote:
> >>>
>  And what about the Camel version you use?
> 
>  Babak
> 
>  --
>  View this message in context:
> 
> >>>
> >>
> http://camel.465427.n5.nabble.com/Splitting-on-XML-Documents-tp5431032p5431531.html
>  Sent from the Camel - Users mailing list archive at Nabble.com.
> 
> >>>
> >>
>
>


Re: Component Design - SMSLib

2012-01-26 Thread deckerego
My advice would be to read over the source for the file endpoint first - it's
fairly bare-bones and makes it easy to comprehend how things work (for
example, how endpoints receive parameters and then pass those along to
consumers and producers). From there it's helpful to go through the mock
endpoint and get a new point of view for how things are constructed largely
in-memory. To get a better idea of how asynchronous production works, the
source for the HTTP component is a good place to start.

You'll see a common thread amongst the file/HTTP/mock components on common
design patterns, including:
- Start out with separate Component/Endpoint/Producer/Consumer/Message and
unit test them out the wazoo individually
- Use Camel's thread pool strategy when creating new thread pools
- Use helper methods such as DefaultComponent.setProperties to set options
from the URI onto your endpoint
-
DefaultAsyncProducer/DefaultConsumer/DefaultEndpoint/DefaultComponent/DefaultMessege
should be the base classes you need


Alex Anderson wrote
> 
> * are there any good resources for writing Endpoints that I should be
> reading?
> * does anyone know of any similarly-modelled components whose source
> might provide guidance?
> * are there any patterns or base classes that I should obviously be
> using for my Component, Endpoint, Consumer or Producer
> implementations?
> * is there anyone else interested in this component who could cast an
> eye over the code?
> 


--
View this message in context: 
http://camel.465427.n5.nabble.com/Component-Design-SMSLib-tp5432954p5433557.html
Sent from the Camel - Users mailing list archive at Nabble.com.


Re: Component Design - SMSLib

2012-01-26 Thread Hadrian Zbarcea
Alex, smslib is distributed under ALv2, which is great. I didn't check 
yet if it's OSGi ready, we're looking for that too. All our components 
are now OSGi ready. If smslib isn't we'll try to work with them to make 
it OSGi ready or find another solution.


The question I have for you is how to you envision the unit testing for 
this component? Is there a way to have a mock service provider? We 
obviously cannot afford using a real service for the unit tests.


Cheers,
Hadrian

On 01/26/2012 09:21 AM, Alex Anderson wrote:

I'm working on a Camel component for SMSLib (http://www.smslib.org).
This is a Java library for communicating with mobile phones and modems
via a serial connection to send and receive SMS messages using the
Hayes (AT) command set.

I have a working prototype - you can see the source at
https://github.com/frontlinesms/camel-smslib

I have some general worries regards best-practice for designing the
Endpoint, Consumer and Producer for this component.  I've not come
across comprehensive documentation for implementing Endpoints etc.,
and it's hard to know which other components would have a similar
model to mine and therefore would be worth delving into the source of.


Notes on serial devices
---
* before starting to send or receive messages through a device it must
be initialised
* initialisation can fail


Endpoint

Each Endpoint will refer to a serial port, with corresponding URIs, e.g.:
* Windows: smslib:COM1
* Linux: smslib:/dev/tty01

When Endpoints are initially created, settings for the port (e.g. baud
rate) are passed to it.  Later we may want to create endpoints for the
same port with different settings, but only if the original endpoint
is no longer in use.


Consumer

There should be a maximum of 1 consumer per endpoint.  The serial port
must be polled to check for incoming SMS.  Rather than storing the SMS
within the Smslib service, I would like to pass them immediately
upstream to the Consumer's Processor.


Producer

For my usage, I would like a single Producer per endpoint.  This is
primarily because when there are no active producers or consumers for
an endpoint, the serial connection can be closed to allow its use by
other programs.  It may be reasonable for other uses to have multiple
Producers for the same endpoint.


Current status
--
The endpoint has a Thread (implemented in a class SmslibService) which
controls the receiving from the serial connection - every 30 seconds
the thread wakes and checks the modem for new incoming messages.  This
SmslibService keeps a reference to a Producer and a Consumer, and
should shut down the serial connection when both Consumer and Producer
are stopped.

Trying to create more than one Producer or Consumer for an Endpoint
will cause an Exception to be thrown.

This causes problems when the settings used to create an endpoint
initially are bad - there will be an Exception thrown in
SmslibProducer.doStart()


My Questions

* are there any good resources for writing Endpoints that I should be reading?
* does anyone know of any similarly-modelled components whose source
might provide guidance?
* are there any patterns or base classes that I should obviously be
using for my Component, Endpoint, Consumer or Producer
implementations?
* is there anyone else interested in this component who could cast an
eye over the code?


--
Hadrian Zbarcea
Principal Software Architect
Talend, Inc
http://coders.talend.com/
http://camelbot.blogspot.com/


Re: Splitting on XML Documents

2012-01-26 Thread Chris Geer
Thank you guys. I added the converyBodyTo command instead of my crazy
setBody command and it seemed to work. I did have to change the attribute
to type vs javaType though.

I wish I could explain why that was needed though. It seems odd that split
would change the data into something not compatible with xslt. I even tried
setting the resultType attribute on the split/xpath to org.w3c.dom.Document
and it didn't help.

Chris

On Thu, Jan 26, 2012 at 8:12 AM, Doug Douglass wrote:

> Excellent suggestion Łukasz!
>
> Chris, have a look at
> http://camel.apache.org/xslt.html#XSLT-NotesonusingXSLTandJavaVersions,
> perhaps that will resolve your issue. For my quick unit test I'm using
> openjdk 1.6.0_22 (ArchLinux-6.b22_1.10.5-1-x86_64) and xalan 2.6.0 was
> already in my projects dependencies/classpath.
>
> Doug
>
>
> 2012/1/26 Łukasz Dywicki 
>
> > I think you should not have any problems, the conversion is really
> simple.
> > After split statement you have a Node as body. For XSLT you need a
> Source.
> > Try adding this instead setBody
> >
> > 
> >
> > That should force conversion to document object and I belive fix your
> > problem.
> >
> > Best regards,
> > Łukasz Dywicki
> > --
> > Code-House
> > http://code-house.org
> >
> >
> > Wiadomość napisana przez Chris Geer w dniu 2012-01-26, o godz. 01:36:
> >
> > > Doug,
> > >
> > > It doesn't make much sense to me either but I do know that with the
> > setBody
> > > command everything works and without it, it fails. If I run the XSLT
> > > against the same XML (save the XML to a file from the flow after the
> > split)
> > > in netbeans it works fine without the  but in camel it fails.
> > >
> > > Could the split be converting the output to a string? That would
> explain
> > > the problem.
> > >
> > > Chris
> > >
> > > On Wed, Jan 25, 2012 at 5:03 PM, Doug Douglass <
> douglass.d...@gmail.com
> > >wrote:
> > >
> > >> Chris,
> > >>
> > >> I think the xml processing "fix" you've got there is a bit of
> > red-herring.
> > >>
> > >> The xml processing instruction should only be necessary if you are
> > >> converting the output of the xpath to a String prior to the xslt
> > endpoint,
> > >> whether directly or indirectly. Without any explicit conversion, the
> > output
> > >> of the xpath will be a Node object (DeferredElementNSImpl in my test),
> > >> which is converted to a Source via camel's built-in type conversion.
> > >>
> > >> I just set up a quick unit test with a route very similar to yours and
> > >> everything worked as I expected. Granted this test was in an existing
> > >> project using camel 2.7.3 (time to upgrade!).
> > >>
> > >> I suspect you're either running into a namespace problem[1] or your
> > >> templates XPaths aren't expecting Parcel (from your example) as the
> root
> > >> element.
> > >>
> > >> [1]
> > >>
> > http://camel.apache.org/xpath.html#XPath-Namespaceauditingtoaiddebugging
> > >>
> > >> Let us know more info (example XML and XSLT) if my suspicions are off
> > base.
> > >>
> > >> HTH,
> > >> Doug
> > >>
> > >> On Wed, Jan 25, 2012 at 3:35 PM, Chris Geer 
> > wrote:
> > >>
> > >>> Sorry, 2.8.3.
> > >>>
> > >>> On Wed, Jan 25, 2012 at 3:29 PM, Babak Vahdat
> > >>> wrote:
> > >>>
> >  And what about the Camel version you use?
> > 
> >  Babak
> > 
> >  --
> >  View this message in context:
> > 
> > >>>
> > >>
> >
> http://camel.465427.n5.nabble.com/Splitting-on-XML-Documents-tp5431032p5431531.html
> >  Sent from the Camel - Users mailing list archive at Nabble.com.
> > 
> > >>>
> > >>
> >
> >
>


help with log DSL

2012-01-26 Thread honghebox
I'm trying to log message body using something like:

from ("jms:mytestqueue").
setBody().simple("Say Hello").
.log(LoggingLevel.DEBUG, "Message body: ${body}")
..

In my log file, instead of seeing "Message body: Say Hello" I got "Message
body: ${body}", any extra configuration I need to do get the ${body} place
holder work?

Thanks in advance.




--
View this message in context: 
http://camel.465427.n5.nabble.com/help-with-log-DSL-tp5433969p5433969.html
Sent from the Camel - Users mailing list archive at Nabble.com.


Re: help with log DSL

2012-01-26 Thread Chris Odom
Looks like you have Quotations around the ${body} making it literal, try
"Message body: "+${body} instead

Hope this helps


On Thu, 26 Jan 2012 13:00:25 -0800 (PST), honghebox 
wrote:
> I'm trying to log message body using something like:
> 
> from ("jms:mytestqueue").
> setBody().simple("Say Hello").
> .log(LoggingLevel.DEBUG, "Message body: ${body}")
> ..
> 
> In my log file, instead of seeing "Message body: Say Hello" I got
"Message
> body: ${body}", any extra configuration I need to do get the ${body}
place
> holder work?
> 
> Thanks in advance.
> 
> 
> 
> 
> --
> View this message in context:
>
http://camel.465427.n5.nabble.com/help-with-log-DSL-tp5433969p5433969.html
> Sent from the Camel - Users mailing list archive at Nabble.com.

-- 
Thanks,
Chris Odom
512:799-0270


Re: help with log DSL

2012-01-26 Thread honghebox
No, without quotations around ${body}, you code even won't compile.

--
View this message in context: 
http://camel.465427.n5.nabble.com/help-with-log-DSL-tp5433969p5433989.html
Sent from the Camel - Users mailing list archive at Nabble.com.


BindException with Embedded Jetty for camel web app

2012-01-26 Thread lavanya
Hi,

I have a web application based on spring, camel and  activemq. The war file
works fine when I deploy in tomcat. I am trying to use the embedded Jetty
instead of Tomcat as described 
http://internna.blogspot.com/2011/08/step-by-step-executable-war-files.html
here 

I am always getting the below exception:

java.io.IOException: Failed to bind to server socket: tcp://localhost:61616
due to: java.net.BindException: Address already in use: JVM_Bind
caused by
java.net.BindException: Address already in use: JVM_Bind
at java.net.PlainSocketImpl.socketBind(Native Method)
at java.net.PlainSocketImpl.bind(Unknown Source)
at java.net.ServerSocket.bind(Unknown Source)
at java.net.ServerSocket.(Unknown Source)
at javax.net.DefaultServerSocketFactory.createServerSocket(Unknown
Source)
at
org.apache.activemq.transport.tcp.TcpTransportServer.bind(TcpTransportServer.java:135)
at
org.apache.activemq.transport.tcp.TcpTransportFactory.doBind(TcpTransportFactory.java:60)
at
org.apache.activemq.transport.TransportFactory.bind(TransportFactory.java:131)
at
org.apache.activemq.broker.TransportConnector.createTransportServer(TransportConnector.java:319)

I have also tried to different port, getting the same exception again.

When I do netstat -a, I am not seeing any process listening to this port.

I am not sure what is going on, could you please help resolving this issue.

FYI:  I am using Jetty version 7, activemq 5.5, camel 2.8.2,spring
3.0.x,geronimo-servlet 1.2

Thanks for your response.



--
View this message in context: 
http://camel.465427.n5.nabble.com/BindException-with-Embedded-Jetty-for-camel-web-app-tp5433991p5433991.html
Sent from the Camel - Users mailing list archive at Nabble.com.


Re: BindException with Embedded Jetty for camel web app

2012-01-26 Thread Chris Odom
The below exception means that some other application is using
tcp://localhost:61616...
java.net.BindException: Address already in use: JVM_Bind

verify with command:
Windows - netstat -an |find /i "listening"
Linux - netstat -anp }grep 61616

If you try to run tomcat and jetty at the same time you would run into
this. 
Try changing the activemq-broker.xml configuration file to use a different
port or don't run both containers at the same time.

-- 
Thanks,
Chris Odom
512:799-0270


Re: BindException with Embedded Jetty for camel web app

2012-01-26 Thread lavanya
Thanks for the response.
I am not running tomcat and jetty at the same time. And also the results of
netstat command doesn't list this port.
I tried changing to different ports like 61617 / 616701, but it doesn't
help.

--
View this message in context: 
http://camel.465427.n5.nabble.com/BindException-with-Embedded-Jetty-for-camel-web-app-tp5433991p5434053.html
Sent from the Camel - Users mailing list archive at Nabble.com.


Re: help with log DSL

2012-01-26 Thread Chris Odom
Sorry was thinking Spring/Blueprint not Java DSL.

you cant not really do a .log() in Java DSL you need to use a .to()

go look at http://camel.apache.org/log.html

try .to("log:PACKAGE?level=DEBUG&showBody=true")

where PACKAGE is the java package space for logging. ex:
log:com.national?...

-- 
Thanks,
Chris Odom
512:799-0270


Re: help with log DSL

2012-01-26 Thread Rich Newcomb
You can use the .log in your routes, via the log EIP (
http://camel.apache.org/logeip.html).

I tested the route segment supplied in the original message (via
Camel 2.6.0-fuse-01-09) ::

   .setBody().simple("Say Hello")

   .log(LoggingLevel.DEBUG, "Message body: ${body}")

.. and it works as expected.   Original poster  -- I think there must be
some trivial problem with your code -- such as a '(' used instead of a '}'.

Please copy & paste the code snippet directly from your IDE if you can not
find the problem.


On Thu, Jan 26, 2012 at 1:41 PM, Chris Odom wrote:

> Sorry was thinking Spring/Blueprint not Java DSL.
>
> you cant not really do a .log() in Java DSL you need to use a .to()
>
> go look at http://camel.apache.org/log.html
>
> try .to("log:PACKAGE?level=DEBUG&showBody=true")
>
> where PACKAGE is the java package space for logging. ex:
> log:com.national?...
>
> --
> Thanks,
> Chris Odom
> 512:799-0270
>


camelContext.suspend() and JmsComponent

2012-01-26 Thread Jason Dillon
Will suspending the context that a JmsComponent has active endpoints in, cause 
the JMS connection.stop() to be called?

I'm looking for the best/right method to quickly disable message flow inside of 
Camel using JMS components.

Anyone know off hand if camelContext.suspend() will do the right thing here for 
JmsComponent?

--jason

Re: camelContext.suspend() and JmsComponent

2012-01-26 Thread Jason Dillon
It doesn't appear that camelContext.suspend() even attempts to suspend() its 
components... is that expected?

--jason

On Jan 26, 2012, at 2:13 PM, Jason Dillon wrote:

> Will suspending the context that a JmsComponent has active endpoints in, 
> cause the JMS connection.stop() to be called?
> 
> I'm looking for the best/right method to quickly disable message flow inside 
> of Camel using JMS components.
> 
> Anyone know off hand if camelContext.suspend() will do the right thing here 
> for JmsComponent?
> 
> --jason



Re: BindException with Embedded Jetty for camel web app

2012-01-26 Thread Willem Jiang
The error is caused by ActiveMQ JMS Broker try to bind the port of 
61616.

Can you check if you start the ActiveMQ Broker twice ?
Or you already start the broker somewhere.

On Fri Jan 27 05:33:53 2012, lavanya wrote:

Thanks for the response.
I am not running tomcat and jetty at the same time. And also the results of
netstat command doesn't list this port.
I tried changing to different ports like 61617 / 616701, but it doesn't
help.

--
View this message in context: 
http://camel.465427.n5.nabble.com/BindException-with-Embedded-Jetty-for-camel-web-app-tp5433991p5434053.html
Sent from the Camel - Users mailing list archive at Nabble.com.





--
Willem
--
FuseSource
Web: http://www.fusesource.com
Blog:http://willemjiang.blogspot.com (English)
http://jnn.javaeye.com (Chinese)
Twitter: willemjiang 
Weibo: willemjiang 



Re: camelContext.suspend() and JmsComponent

2012-01-26 Thread Claus Ibsen
On Thu, Jan 26, 2012 at 11:46 PM, Jason Dillon  wrote:
> It doesn't appear that camelContext.suspend() even attempts to suspend() its 
> components... is that expected?
>

Yes, suspend() is for suspending route *consumers only*.
So the routes does not intake new messages, but all the other route
services are still "hot".



> --jason
>
> On Jan 26, 2012, at 2:13 PM, Jason Dillon wrote:
>
>> Will suspending the context that a JmsComponent has active endpoints in, 
>> cause the JMS connection.stop() to be called?
>>
>> I'm looking for the best/right method to quickly disable message flow inside 
>> of Camel using JMS components.
>>
>> Anyone know off hand if camelContext.suspend() will do the right thing here 
>> for JmsComponent?
>>
>> --jason
>



-- 
Claus Ibsen
-
FuseSource
Email: cib...@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: Component Design - SMSLib

2012-01-26 Thread Alex Anderson
Hi, thank you for the clear advice - I'll go through your recommended
components today and see if they help me get a better grip on things.

I definitely intend to unit test the wazoo out of everything, but it's
a little tricky right now as I'm not entirely sure where
responsibilities should lie in a Camel component.  Again, hopefully
this should be clearer after reviewing file, mock and HTTP.

Cheers,

Alex


On 26 January 2012 20:50, deckerego  wrote:
> My advice would be to read over the source for the file endpoint first - it's
> fairly bare-bones and makes it easy to comprehend how things work (for
> example, how endpoints receive parameters and then pass those along to
> consumers and producers). From there it's helpful to go through the mock
> endpoint and get a new point of view for how things are constructed largely
> in-memory. To get a better idea of how asynchronous production works, the
> source for the HTTP component is a good place to start.
>
> You'll see a common thread amongst the file/HTTP/mock components on common
> design patterns, including:
> - Start out with separate Component/Endpoint/Producer/Consumer/Message and
> unit test them out the wazoo individually
> - Use Camel's thread pool strategy when creating new thread pools
> - Use helper methods such as DefaultComponent.setProperties to set options
> from the URI onto your endpoint
> -
> DefaultAsyncProducer/DefaultConsumer/DefaultEndpoint/DefaultComponent/DefaultMessege
> should be the base classes you need
>
>
> Alex Anderson wrote
>>
>> * are there any good resources for writing Endpoints that I should be
>> reading?
>> * does anyone know of any similarly-modelled components whose source
>> might provide guidance?
>> * are there any patterns or base classes that I should obviously be
>> using for my Component, Endpoint, Consumer or Producer
>> implementations?
>> * is there anyone else interested in this component who could cast an
>> eye over the code?
>>
>
>
> --
> View this message in context: 
> http://camel.465427.n5.nabble.com/Component-Design-SMSLib-tp5432954p5433557.html
> Sent from the Camel - Users mailing list archive at Nabble.com.


Re: Component Design - SMSLib

2012-01-26 Thread Alex Anderson
Hi Hadrian,

I made a mock implementation of the Java serial API specifically for
unit testing: https://github.com/frontlinesms/mock-serial

Do you have any practical advice for developing components, or
resources I should be reading?

Thanks,

Alex


On 26 January 2012 21:22, Hadrian Zbarcea  wrote:
> Alex, smslib is distributed under ALv2, which is great. I didn't check yet
> if it's OSGi ready, we're looking for that too. All our components are now
> OSGi ready. If smslib isn't we'll try to work with them to make it OSGi
> ready or find another solution.
>
> The question I have for you is how to you envision the unit testing for this
> component? Is there a way to have a mock service provider? We obviously
> cannot afford using a real service for the unit tests.
>
> Cheers,
> Hadrian
>
>
> On 01/26/2012 09:21 AM, Alex Anderson wrote:
>>
>> I'm working on a Camel component for SMSLib (http://www.smslib.org).
>> This is a Java library for communicating with mobile phones and modems
>> via a serial connection to send and receive SMS messages using the
>> Hayes (AT) command set.
>>
>> I have a working prototype - you can see the source at
>> https://github.com/frontlinesms/camel-smslib
>>
>> I have some general worries regards best-practice for designing the
>> Endpoint, Consumer and Producer for this component.  I've not come
>> across comprehensive documentation for implementing Endpoints etc.,
>> and it's hard to know which other components would have a similar
>> model to mine and therefore would be worth delving into the source of.
>>
>>
>> Notes on serial devices
>> ---
>> * before starting to send or receive messages through a device it must
>> be initialised
>> * initialisation can fail
>>
>>
>> Endpoint
>> 
>> Each Endpoint will refer to a serial port, with corresponding URIs, e.g.:
>> * Windows: smslib:COM1
>> * Linux: smslib:/dev/tty01
>>
>> When Endpoints are initially created, settings for the port (e.g. baud
>> rate) are passed to it.  Later we may want to create endpoints for the
>> same port with different settings, but only if the original endpoint
>> is no longer in use.
>>
>>
>> Consumer
>> 
>> There should be a maximum of 1 consumer per endpoint.  The serial port
>> must be polled to check for incoming SMS.  Rather than storing the SMS
>> within the Smslib service, I would like to pass them immediately
>> upstream to the Consumer's Processor.
>>
>>
>> Producer
>> 
>> For my usage, I would like a single Producer per endpoint.  This is
>> primarily because when there are no active producers or consumers for
>> an endpoint, the serial connection can be closed to allow its use by
>> other programs.  It may be reasonable for other uses to have multiple
>> Producers for the same endpoint.
>>
>>
>> Current status
>> --
>> The endpoint has a Thread (implemented in a class SmslibService) which
>> controls the receiving from the serial connection - every 30 seconds
>> the thread wakes and checks the modem for new incoming messages.  This
>> SmslibService keeps a reference to a Producer and a Consumer, and
>> should shut down the serial connection when both Consumer and Producer
>> are stopped.
>>
>> Trying to create more than one Producer or Consumer for an Endpoint
>> will cause an Exception to be thrown.
>>
>> This causes problems when the settings used to create an endpoint
>> initially are bad - there will be an Exception thrown in
>> SmslibProducer.doStart()
>>
>>
>> My Questions
>> 
>> * are there any good resources for writing Endpoints that I should be
>> reading?
>> * does anyone know of any similarly-modelled components whose source
>> might provide guidance?
>> * are there any patterns or base classes that I should obviously be
>> using for my Component, Endpoint, Consumer or Producer
>> implementations?
>> * is there anyone else interested in this component who could cast an
>> eye over the code?
>
>
> --
> Hadrian Zbarcea
> Principal Software Architect
> Talend, Inc
> http://coders.talend.com/
> http://camelbot.blogspot.com/