Problem with Camel rest in OSGi

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

Problem with Camel rest in OSGi

amjr
Hi!

I'm creating an OSGi bundle which uses blueprint to configure Camel routes. It looks like rest-endpoint doesn't listen to configured port.

In blueprint.xml I have the following:
<bean id="mailRoutes" class="com.demo.MailRouteBuilder"/>
<camelContext id="MailerBotCamelContext" xmlns="http://camel.apache.org/schema/blueprint" threadNamePattern="Mailerbot rest camel-thread #counter#">
    <routeBuilder ref="mailRoutes"/>
 </camelContext>

And MailRouteBuilder java class builds the route:

public class MailRouteBuilder extends RouteBuilder {

    @Override
    public void configure() throws Exception {
        restConfiguration().component("servlet").bindingMode(RestBindingMode.json)
                .dataFormatProperty("prettyPrint", "true")
                .contextPath("/").port(8080);
        rest("/").description("Mail rest service")
                .consumes("application/json").produces("application/json")

                .post("/send").description("Sends mail").outType(Mail.class)
                .to("bean:mailService?method=postMail(${header.id})");
    }
}

Project builds and CamelContext starts when I install the OSGi bundle but port 8080 is not listening. Am I missing something here? Or what is the reason for the port not going into listen-mode.
Reply | Threaded
Open this post in threaded view
|

Re: Problem with Camel rest in OSGi

Claus Ibsen-2
The port is only for human and tooling such as JMX, swagger, etc.

The actual port is configured by the component you use, and as you use
servlet its the HTTP service from OSGi. In Karaf that service uses by
default port 8181.



On Fri, Nov 7, 2014 at 9:47 AM, amjr <[hidden email]> wrote:

> Hi!
>
> I'm creating an OSGi bundle which uses blueprint to configure Camel routes.
> It looks like rest-endpoint doesn't listen to configured port.
>
> In blueprint.xml I have the following:
>
>
> And MailRouteBuilder java class builds the route:
>
>
>
> Project builds and CamelContext starts when I install the OSGi bundle but
> port 8080 is not listening. Am I missing something here? Or what is the
> reason for the port not going into listen-mode.
>
>
>
>
> --
> View this message in context: http://camel.465427.n5.nabble.com/Problem-with-Camel-rest-in-OSGi-tp5758649.html
> Sent from the Camel - Users mailing list archive at Nabble.com.



--
Claus Ibsen
-----------------
Red Hat, Inc.
Email: [hidden email]
Twitter: davsclaus
Blog: http://davsclaus.com
Author of Camel in Action: http://www.manning.com/ibsen
hawtio: http://hawt.io/
fabric8: http://fabric8.io/
Reply | Threaded
Open this post in threaded view
|

Re: Problem with Camel rest in OSGi

Claus Ibsen-2
Hi

I have updated that page to explain that better. And btw its only when
using the servlet component.
https://cwiki.apache.org/confluence/display/CAMEL/Rest+DSL

On Fri, Nov 7, 2014 at 10:07 AM, Claus Ibsen <[hidden email]> wrote:

> The port is only for human and tooling such as JMX, swagger, etc.
>
> The actual port is configured by the component you use, and as you use
> servlet its the HTTP service from OSGi. In Karaf that service uses by
> default port 8181.
>
>
>
> On Fri, Nov 7, 2014 at 9:47 AM, amjr <[hidden email]> wrote:
>> Hi!
>>
>> I'm creating an OSGi bundle which uses blueprint to configure Camel routes.
>> It looks like rest-endpoint doesn't listen to configured port.
>>
>> In blueprint.xml I have the following:
>>
>>
>> And MailRouteBuilder java class builds the route:
>>
>>
>>
>> Project builds and CamelContext starts when I install the OSGi bundle but
>> port 8080 is not listening. Am I missing something here? Or what is the
>> reason for the port not going into listen-mode.
>>
>>
>>
>>
>> --
>> View this message in context: http://camel.465427.n5.nabble.com/Problem-with-Camel-rest-in-OSGi-tp5758649.html
>> Sent from the Camel - Users mailing list archive at Nabble.com.
>
>
>
> --
> Claus Ibsen
> -----------------
> Red Hat, Inc.
> Email: [hidden email]
> Twitter: davsclaus
> Blog: http://davsclaus.com
> Author of Camel in Action: http://www.manning.com/ibsen
> hawtio: http://hawt.io/
> fabric8: http://fabric8.io/



--
Claus Ibsen
-----------------
Red Hat, Inc.
Email: [hidden email]
Twitter: davsclaus
Blog: http://davsclaus.com
Author of Camel in Action: http://www.manning.com/ibsen
hawtio: http://hawt.io/
fabric8: http://fabric8.io/
Reply | Threaded
Open this post in threaded view
|

Re: Problem with Camel rest in OSGi

Asgeir Frimannsson
There is however a small (1 character) bug in 2.14 where endpointProperties
are ignored:

In org.apache.camel.component.servlet.ServletComponent:createConsumer (and
similar for other REST-aware endpoints):

        String url = "servlet:///%s?httpMethodRestrict=%s";
        if (!query.isEmpty()) {
            url = url + *"?"* + query;
        }
...which would cause multiple '?' arguments in the url. Fixed by replacing
'?' with '&'...

cheers,
asgeir


On Fri, Nov 7, 2014 at 10:10 AM, Claus Ibsen <[hidden email]> wrote:

> Hi
>
> I have updated that page to explain that better. And btw its only when
> using the servlet component.
> https://cwiki.apache.org/confluence/display/CAMEL/Rest+DSL
>
> On Fri, Nov 7, 2014 at 10:07 AM, Claus Ibsen <[hidden email]>
> wrote:
> > The port is only for human and tooling such as JMX, swagger, etc.
> >
> > The actual port is configured by the component you use, and as you use
> > servlet its the HTTP service from OSGi. In Karaf that service uses by
> > default port 8181.
> >
> >
> >
> > On Fri, Nov 7, 2014 at 9:47 AM, amjr <[hidden email]> wrote:
> >> Hi!
> >>
> >> I'm creating an OSGi bundle which uses blueprint to configure Camel
> routes.
> >> It looks like rest-endpoint doesn't listen to configured port.
> >>
> >> In blueprint.xml I have the following:
> >>
> >>
> >> And MailRouteBuilder java class builds the route:
> >>
> >>
> >>
> >> Project builds and CamelContext starts when I install the OSGi bundle
> but
> >> port 8080 is not listening. Am I missing something here? Or what is the
> >> reason for the port not going into listen-mode.
> >>
> >>
> >>
> >>
> >> --
> >> View this message in context:
> http://camel.465427.n5.nabble.com/Problem-with-Camel-rest-in-OSGi-tp5758649.html
> >> Sent from the Camel - Users mailing list archive at Nabble.com.
> >
> >
> >
> > --
> > Claus Ibsen
> > -----------------
> > Red Hat, Inc.
> > Email: [hidden email]
> > Twitter: davsclaus
> > Blog: http://davsclaus.com
> > Author of Camel in Action: http://www.manning.com/ibsen
> > hawtio: http://hawt.io/
> > fabric8: http://fabric8.io/
>
>
>
> --
> Claus Ibsen
> -----------------
> Red Hat, Inc.
> Email: [hidden email]
> Twitter: davsclaus
> Blog: http://davsclaus.com
> Author of Camel in Action: http://www.manning.com/ibsen
> hawtio: http://hawt.io/
> fabric8: http://fabric8.io/
>