Calling Camel route from service via Java interface

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

Calling Camel route from service via Java interface

sobkowiak
Hi

I'd like to call a Camel route from a Spring bean. One method is using
the ProducerTemplate like in this demo [1]

In Camel 2.x it was possibly to define a Java interface and use it to
call the route (CamelProxy). I can't find it in actual documentation.
Was this functionality removed from in Camel 3?

Best regards

Krzysztof


[1]
https://github.com/camelinaction/camelinaction2/blob/master/chapter7/springboot-rest-camel/src/main/java/camelinaction/HelloRestController.java


Reply | Threaded
Open this post in threaded view
|

Re: Calling Camel route from service via Java interface

Andres
We do it like this on Camel 3:

@Component
public class SfdcClient {

    @Autowired private CamelContext camelContext;

    public void sendMessage(params...) {
        try (ProducerTemplate template =
camelContext.createProducerTemplate()) {
            CreateSObjectResult result =
template.requestBody("salesforce:createSObject", params,
CreateSObjectResult.class);
            // handle result
        }
    }
}

El vie., 6 de mar. de 2020 a la(s) 08:50, Sobkowiak, Krzysztof (
[hidden email]) escribió:

> Hi
>
> I'd like to call a Camel route from a Spring bean. One method is using
> the ProducerTemplate like in this demo [1]
>
> In Camel 2.x it was possibly to define a Java interface and use it to
> call the route (CamelProxy). I can't find it in actual documentation.
> Was this functionality removed from in Camel 3?
>
> Best regards
>
> Krzysztof
>
>
> [1]
>
> https://github.com/camelinaction/camelinaction2/blob/master/chapter7/springboot-rest-camel/src/main/java/camelinaction/HelloRestController.java
>
>
>
Reply | Threaded
Open this post in threaded view
|

Re: Calling Camel route from service via Java interface

Claus Ibsen-2
In reply to this post by sobkowiak
Hi

You should still be able to do this.

On Fri, Mar 6, 2020 at 12:50 PM Sobkowiak, Krzysztof
<[hidden email]> wrote:

>
> Hi
>
> I'd like to call a Camel route from a Spring bean. One method is using
> the ProducerTemplate like in this demo [1]
>
> In Camel 2.x it was possibly to define a Java interface and use it to
> call the route (CamelProxy). I can't find it in actual documentation.
> Was this functionality removed from in Camel 3?
>
> Best regards
>
> Krzysztof
>
>
> [1]
> https://github.com/camelinaction/camelinaction2/blob/master/chapter7/springboot-rest-camel/src/main/java/camelinaction/HelloRestController.java
>
>


--
Claus Ibsen
-----------------
http://davsclaus.com @davsclaus
Camel in Action 2: https://www.manning.com/ibsen2
Reply | Threaded
Open this post in threaded view
|

Re: Calling Camel route from service via Java interface

Claus Ibsen-2
Its the old spring remoting that has been removed (eg remote method
invocation over network).

But hiding Camel via an interface, and inject that via spring bean
injection or other ways is still there.

On Fri, Mar 6, 2020 at 1:22 PM Claus Ibsen <[hidden email]> wrote:

>
> Hi
>
> You should still be able to do this.
>
> On Fri, Mar 6, 2020 at 12:50 PM Sobkowiak, Krzysztof
> <[hidden email]> wrote:
> >
> > Hi
> >
> > I'd like to call a Camel route from a Spring bean. One method is using
> > the ProducerTemplate like in this demo [1]
> >
> > In Camel 2.x it was possibly to define a Java interface and use it to
> > call the route (CamelProxy). I can't find it in actual documentation.
> > Was this functionality removed from in Camel 3?
> >
> > Best regards
> >
> > Krzysztof
> >
> >
> > [1]
> > https://github.com/camelinaction/camelinaction2/blob/master/chapter7/springboot-rest-camel/src/main/java/camelinaction/HelloRestController.java
> >
> >
>
>
> --
> Claus Ibsen
> -----------------
> http://davsclaus.com @davsclaus
> Camel in Action 2: https://www.manning.com/ibsen2



--
Claus Ibsen
-----------------
http://davsclaus.com @davsclaus
Camel in Action 2: https://www.manning.com/ibsen2
Reply | Threaded
Open this post in threaded view
|

Re: Calling Camel route from service via Java interface

sobkowiak
Thanks, I'll check it

On Fri, 2020-03-06 at 13:23 +0100, Claus Ibsen wrote:

> Its the old spring remoting that has been removed (eg remote method
> invocation over network).
>
> But hiding Camel via an interface, and inject that via spring bean
> injection or other ways is still there.
>
> On Fri, Mar 6, 2020 at 1:22 PM Claus Ibsen <[hidden email]> wrote:
> > Hi
> >
> > You should still be able to do this.
> >
> > On Fri, Mar 6, 2020 at 12:50 PM Sobkowiak, Krzysztof
> > <[hidden email]> wrote:
> > > Hi
> > >
> > > I'd like to call a Camel route from a Spring bean. One method is using
> > > the ProducerTemplate like in this demo [1]
> > >
> > > In Camel 2.x it was possibly to define a Java interface and use it to
> > > call the route (CamelProxy). I can't find it in actual documentation.
> > > Was this functionality removed from in Camel 3?
> > >
> > > Best regards
> > >
> > > Krzysztof
> > >
> > >
> > > [1]
> > > https://github.com/camelinaction/camelinaction2/blob/master/chapter7/springboot-rest-camel/src/main/java/camelinaction/HelloRestController.java
> > >
> > >
> >
> > --
> > Claus Ibsen
> > -----------------
> > http://davsclaus.com @davsclaus
> > Camel in Action 2: https://www.manning.com/ibsen2
>
>
--
Krzysztof Sobkowiak

JEE & OSS Architect, Integration Architect
Apache Software Foundation Member (http://apache.org/)
Apache ServiceMix Committer & PMC Member (http://servicemix.apache.org/)
Apache OpenWhisk PMC Member (https://openwhisk.apache.org/)
Apache Incubator PMC Member (https://incubator.apache.org/)
Senior Solution Architect @ Capgemini SSC (http://www.capgeminisoftware.pl/)