Hi,

First of all you create a class foo.bar.impl.MyProcessor implements Processor 
somewhere in your project. You can instantiate this in your blueprint with a
<bean id="myProcessor" class="foo.bar.impl.MyProcessor"/>

Beans like this are also available in the blueprint registry, so if you 
instantiate or reference the sqsClient this way, you can use it without 
explicitly instantiating a registry.

Best regards
Stephan

-----Original Message-----
From: Muhzin [mailto:rmuh...@gmail.com] 
Sent: Freitag, 17. Januar 2014 10:25
To: users@camel.apache.org
Subject: Re: Camel main class in osgi bundle

Thanks for the reply. I'm trying to convert my camel configuration from
java DSL to blueprint and come across some hurdles.

My route config looks something like
SimpleRegistry registry = new SimpleRegistry();
registry.put("sqsClient", sqsClient);

CamelContext context = new DefaultCamelContext(registry);
context.addRoutes(new RouteBuilder() {
    @Override
    public void configure() throws Exception {
        from("aws-sqs://
sqs.ap-southeast-2.amazonaws.com/122343553/profile-data?amazonSQSClient=#sqsClient
")
                .process(new Processor() {
                    @Override
                    public void process(Exchange exchange) throws Exception
{

                        String rawMessage =
exchange.getIn().getBody(String.class);
                        Gson gson = new GsonBuilder().create();
                        Message message = gson.fromJson(rawMessage,
Message.class);
                        DynamoDBStorage dynamoStorage = new
DynamoDBStorage(dynamoDBClient);

                        if (message.getAction().equals("createProfile")) {
                            User user =
dynamoStorage.getUserDetails(message.getId());
                            MysqlStorage mysqlStorage = new MysqlStorage();
                            mysqlStorage.insertNewUser(user);
                        } else {
                            System.out.println(message.getAction());
                        }
                    }
                });
    }
});


When converting it into blueprint,
#) How can I create a custom processor like above?
#) How can I get my objects like sqsClient to blueprint?
#) How can I make objects like 'gson'  shown above in my route?
#) How can I make the routing like if else shown above?


Is there some detailed tutorial on how to write camel-blueprint? The one i
could find was http://camel.apache.org/using-osgi-blueprint-with-camel.htmlwhich
only cover the basics.


On Fri, Jan 17, 2014 at 1:10 PM, Claus Ibsen <claus.ib...@gmail.com> wrote:

> Hi
>
> Using a spring or blueprint xml file to bootstrap Camel is often much
> easier, as it does all the OSGi lifecycle and other pieces you
> otherwise must do yourself.
>
> If you dont want to do that, then you need to use an osgi activator to
> call some code, that creates a OsgiCamelContext and setup a bunch of
> stuff to make it run in OSGi. And as well stop and cleanup these
> services again when the bundle stops.
>
> Though much easier to just have a little
> OSGI-INF/blueprint/somenamehere.xml blueprint xml file that embeds a
> <camelContext> and you have Camel running.
>
>
>
> On Fri, Jan 17, 2014 at 4:48 AM, Muhzin <rmuh...@gmail.com> wrote:
> > Hi all,
> > I am trying to run camel application in karaf. I new to programming for
> > osgi. How can I make my camel routes run in it? Can i put it in a normal
> > main() class and run it?
> >
> > --
> > BR
> > Muhsin
>
>
>
> --
> Claus Ibsen
> -----------------
> Red Hat, Inc.
> Email: cib...@redhat.com
> Twitter: davsclaus
> Blog: http://davsclaus.com
> Author of Camel in Action: http://www.manning.com/ibsen
> Make your Camel applications look hawt, try: http://hawt.io
>



-- 
BR
Muhsin

Reply via email to