public static Map<?, ?> getItem(CamelContext camelctx) { HashMap<String, AttributeValue> key = new HashMap<>(); key.put("Id", new AttributeValue().withN("103")); Exchange exchange = new ExchangeBuilder(camelctx) .withHeader(DdbConstants.OPERATION, DdbOperations.GetItem) .withHeader(DdbConstants.KEY, key).build(); ProducerTemplate producer = camelctx.createProducerTemplate(); producer.send("direct:start", exchange); Assert.assertNull(exchange.getException()); return exchange.getIn().getHeader(DdbConstants.ATTRIBUTES, Map.class); }
private void onInternalMessageArrived(final String deviceId, final String appTopic, final KuraPayload message, final int qos, final boolean retain, final boolean control) { this.log.debug("Received message with deviceId {}, application topic {}.", deviceId, appTopic); final Exchange exchange = anExchange(getEndpoint().getCamelContext()) // .withBody(message) // .withHeader(CAMEL_KURA_CLOUD_TOPIC, appTopic) // .withHeader(CAMEL_KURA_CLOUD_DEVICEID, deviceId) // .withHeader(CAMEL_KURA_CLOUD_QOS, qos) // .withHeader(CAMEL_KURA_CLOUD_CONTROL, control) // .withHeader(CAMEL_KURA_CLOUD_RETAIN, retain) // .build(); exchange.setFromEndpoint(getEndpoint()); try { getProcessor().process(exchange); } catch (final Exception e) { handleException("Error while processing an incoming message:", e); } }
public static Map<?, ?> getItem(CamelContext camelctx) { HashMap<String, AttributeValue> key = new HashMap<>(); key.put("Id", new AttributeValue().withN("103")); Exchange exchange = new ExchangeBuilder(camelctx) .withHeader(DdbConstants.OPERATION, DdbOperations.GetItem) .withHeader(DdbConstants.KEY, key).build(); ProducerTemplate producer = camelctx.createProducerTemplate(); producer.send("direct:start", exchange); Assert.assertNull(exchange.getException()); return exchange.getIn().getHeader(DdbConstants.ATTRIBUTES, Map.class); }
public static void putItem(CamelContext camelctx, String title) { HashMap<String, AttributeValue> putItem = new HashMap<>(); putItem.put("Id", new AttributeValue().withN("103")); putItem.put("Title", new AttributeValue().withS(title)); Exchange exchange = new ExchangeBuilder(camelctx) .withHeader(DdbConstants.OPERATION, DdbOperations.PutItem) .withHeader(DdbConstants.ITEM, putItem).build(); ProducerTemplate producer = camelctx.createProducerTemplate(); producer.send("direct:start", exchange); }
public static void putItem(CamelContext camelctx, String title) { HashMap<String, AttributeValue> putItem = new HashMap<>(); putItem.put("Id", new AttributeValue().withN("103")); putItem.put("Title", new AttributeValue().withS(title)); Exchange exchange = new ExchangeBuilder(camelctx) .withHeader(DdbConstants.OPERATION, DdbOperations.PutItem) .withHeader(DdbConstants.ITEM, putItem).build(); ProducerTemplate producer = camelctx.createProducerTemplate(); producer.send("direct:start", exchange); }
public static void updItem(CamelContext camelctx, String title) { HashMap<String, AttributeValue> key = new HashMap<>(); key.put("Id", new AttributeValue().withN("103")); HashMap<String, AttributeValueUpdate> updItem = new HashMap<>(); AttributeValueUpdate updValue = new AttributeValueUpdate(); updValue.setValue(new AttributeValue().withS(title)); updItem.put("Title", updValue); Exchange exchange = new ExchangeBuilder(camelctx) .withHeader(DdbConstants.OPERATION, DdbOperations.UpdateItem) .withHeader(DdbConstants.KEY, key) .withHeader(DdbConstants.UPDATE_VALUES, updItem).build(); ProducerTemplate producer = camelctx.createProducerTemplate(); producer.send("direct:start", exchange); Assert.assertNull(exchange.getException()); }
public static void updItem(CamelContext camelctx, String title) { HashMap<String, AttributeValue> key = new HashMap<>(); key.put("Id", new AttributeValue().withN("103")); HashMap<String, AttributeValueUpdate> updItem = new HashMap<>(); AttributeValueUpdate updValue = new AttributeValueUpdate(); updValue.setValue(new AttributeValue().withS(title)); updItem.put("Title", updValue); Exchange exchange = new ExchangeBuilder(camelctx) .withHeader(DdbConstants.OPERATION, DdbOperations.UpdateItem) .withHeader(DdbConstants.KEY, key) .withHeader(DdbConstants.UPDATE_VALUES, updItem).build(); ProducerTemplate producer = camelctx.createProducerTemplate(); producer.send("direct:start", exchange); Assert.assertNull(exchange.getException()); }
/** * Process the TPVObject, all params required. * * @param tpv The time-position-velocity object to process * @param processor Processor that handles the exchange. * @param endpoint GpsdEndpoint receiving the exchange. */ public static void consumeTPVObject(TPVObject tpv, Processor processor, GpsdEndpoint endpoint, ExceptionHandler exceptionHandler) { // Simplify logging when https://github.com/taimos/GPSd4Java/pull/19 is merged into upstream. LOG.debug("About to consume TPV object {},{} from {}", tpv.getLatitude(), tpv.getLongitude(), endpoint); Validate.notNull(tpv); Validate.notNull(processor); Validate.notNull(endpoint); GpsCoordinates coordinates = gpsCoordinates(new Date(new Double(tpv.getTimestamp()).longValue()), tpv.getLatitude(), tpv.getLongitude()); Exchange exchange = anExchange(endpoint.getCamelContext()).withPattern(OutOnly). withHeader(TPV_HEADER, tpv).withBody(coordinates).build(); try { processor.process(exchange); } catch (Exception e) { exceptionHandler.handleException(e); } } }