Return-Path: X-Original-To: archive-asf-public-internal@cust-asf2.ponee.io Delivered-To: archive-asf-public-internal@cust-asf2.ponee.io Received: from cust-asf.ponee.io (cust-asf.ponee.io [163.172.22.183]) by cust-asf2.ponee.io (Postfix) with ESMTP id 0C005200C8C for ; Tue, 6 Jun 2017 16:56:06 +0200 (CEST) Received: by cust-asf.ponee.io (Postfix) id 0ABB9160BC6; Tue, 6 Jun 2017 14:56:06 +0000 (UTC) Delivered-To: archive-asf-public@cust-asf.ponee.io Received: from mail.apache.org (hermes.apache.org [140.211.11.3]) by cust-asf.ponee.io (Postfix) with SMTP id 50A6C160BC3 for ; Tue, 6 Jun 2017 16:56:05 +0200 (CEST) Received: (qmail 13063 invoked by uid 500); 6 Jun 2017 14:56:02 -0000 Mailing-List: contact users-help@camel.apache.org; run by ezmlm Precedence: bulk List-Help: List-Unsubscribe: List-Post: List-Id: Reply-To: users@camel.apache.org Delivered-To: mailing list users@camel.apache.org Received: (qmail 13045 invoked by uid 99); 6 Jun 2017 14:56:02 -0000 Received: from pnap-us-west-generic-nat.apache.org (HELO spamd4-us-west.apache.org) (209.188.14.142) by apache.org (qpsmtpd/0.29) with ESMTP; Tue, 06 Jun 2017 14:56:02 +0000 Received: from localhost (localhost [127.0.0.1]) by spamd4-us-west.apache.org (ASF Mail Server at spamd4-us-west.apache.org) with ESMTP id EB17CC1380 for ; Tue, 6 Jun 2017 14:56:01 +0000 (UTC) X-Virus-Scanned: Debian amavisd-new at spamd4-us-west.apache.org X-Spam-Flag: NO X-Spam-Score: 1.694 X-Spam-Level: * X-Spam-Status: No, score=1.694 tagged_above=-999 required=6.31 tests=[DKIM_SIGNED=0.1, DKIM_VALID=-0.1, DKIM_VALID_AU=-0.1, RCVD_IN_DNSWL_NONE=-0.0001, RCVD_IN_MSPIKE_H3=-0.01, RCVD_IN_MSPIKE_WL=-0.01, RCVD_IN_SORBS_SPAM=0.5, URIBL_BLOCKED=0.001, URI_HEX=1.313] autolearn=disabled Authentication-Results: spamd4-us-west.apache.org (amavisd-new); dkim=pass (1024-bit key) header.d=regvart.com Received: from mx1-lw-us.apache.org ([10.40.0.8]) by localhost (spamd4-us-west.apache.org [10.40.0.11]) (amavisd-new, port 10024) with ESMTP id hAHNRk8KNrHz for ; Tue, 6 Jun 2017 14:56:01 +0000 (UTC) Received: from mail-ot0-f177.google.com (mail-ot0-f177.google.com [74.125.82.177]) by mx1-lw-us.apache.org (ASF Mail Server at mx1-lw-us.apache.org) with ESMTPS id DF1F45FDE2 for ; Tue, 6 Jun 2017 14:56:00 +0000 (UTC) Received: by mail-ot0-f177.google.com with SMTP id k4so17016349otd.0 for ; Tue, 06 Jun 2017 07:56:00 -0700 (PDT) DKIM-Signature: v=1; a=rsa-sha256; c=relaxed/relaxed; d=regvart.com; s=google; h=mime-version:in-reply-to:references:from:date:message-id:subject:to; bh=C5gCy+/ttlMYMZV/LeVYvdx+A+i2ROZA2vM86OdWxDw=; b=cyWdHfSNlGZuEcIii2001n9VbaUGjkIGlv7tZj0QOp1Iqt5bxtD83ZLSdmHh6Q0ulV qKPe4X+k99znQbq4KMErJXt/RaSLTvEzp0wZG7o9G0J8WoaTX9S9IkmAif6gidKMbjxw UyCamLX/Wkp8owBuxkZWJ3n+ZQKdZJL4uiZec= X-Google-DKIM-Signature: v=1; a=rsa-sha256; c=relaxed/relaxed; d=1e100.net; s=20161025; h=x-gm-message-state:mime-version:in-reply-to:references:from:date :message-id:subject:to; bh=C5gCy+/ttlMYMZV/LeVYvdx+A+i2ROZA2vM86OdWxDw=; b=ALc2ZMqMGZgjC+sB9EELOjfd5VwIu0iC36pGmg8TtOjspXf0YP1Z/0IWEJAp4X14T8 KBZm0AKGVk5Vo64I+rXOoGEX+E8f+i3TQixk8MLG117oULJ5svkPPnnb0tzi5YuDX9I8 elANkPT7gs/WLRt3rznuXSbILWyNYoNjiQw6G8Vd8NrVv1aqlUjpANFevRNJepatmhZS BFl8s/hfCHYeG8ZC6FYZk9yq/sTnjdUZiXa+T0E+0l3rZ6UBRIa7saQeiOTMU46UBKPN iozCTBdR/T3qaWcsa8LK1OVE4JnhGcQMiFZU96G8PjC2dG+MYrJXDF25g6KqdMEKHnk3 Z2gw== X-Gm-Message-State: AKS2vOyAjcPfmKiGGFMzAPOkQWkERzo0snjv64k9e63vgx64SLv8LZHd TpLHYeQvZ8mMMqenAwx/8REwA/1hjHmffw4N0w== X-Received: by 10.157.34.197 with SMTP id y63mr11654343ota.218.1496760960140; Tue, 06 Jun 2017 07:56:00 -0700 (PDT) MIME-Version: 1.0 Received: by 10.74.134.73 with HTTP; Tue, 6 Jun 2017 07:55:39 -0700 (PDT) In-Reply-To: <1496751643480-5801958.post@n5.nabble.com> References: <1496751643480-5801958.post@n5.nabble.com> From: Zoran Regvart Date: Tue, 6 Jun 2017 16:55:39 +0200 Message-ID: Subject: Re: How to Extract json key, value from MQTT payload To: users@camel.apache.org Content-Type: text/plain; charset="UTF-8" archived-at: Tue, 06 Jun 2017 14:56:06 -0000 Hi, so typically you would use message headers and named parameters in your SQL, something like .setBody("INSERT INTO MY_TABLE (ID, NAME) VALUES (:?id, :?name)") .to("jdbc:myDataSource") and your processor would need to set those `id` and `name` headers on the incoming message. You could also use JSONPath support to set those headers, of the top of my head, something like: .setHeader('id', new JsonPathExpression("$.id")) .setHeader('name', new JsonPathExpression("$.name")) .setBody("INSERT INTO MY_TABLE (ID, NAME) VALUES (:?id, :?name)") .to("jdbc:myDataSource") zoran On Tue, Jun 6, 2017 at 2:20 PM, solomon wrote: > Hi, > > I have created a camel route of mqtt -> jdbc which pushes the data in json > format into MQTT topic, now I want to extract the json key and value so that > I can insert it into jdbc database. > > sample json payload : { "id": 1, "name": "Test" } > > My Camel route looks like this : > > from("mqtt:bar?subscribeTopicName=test&host=tcp://localhost:1883") > .process(new MyProcessor()) // Extract json data here > .to("jdbc:myDataSource?resetAutoCommit=false"); > > Can any one help me on how to get the values. > > Thanks > > > > -- > View this message in context: http://camel.465427.n5.nabble.com/How-to-Extract-json-key-value-from-MQTT-payload-tp5801958.html > Sent from the Camel - Users mailing list archive at Nabble.com. -- Zoran Regvart