/// <summary> /// The execute method for incoming tuples /// </summary> /// <param name="tuple">The incoming tuple</param> public void Execute(SCPTuple tuple) { try { var values = tuple.GetValues(); foreach (var value in values) { Context.Logger.Info("Creating document: {0} with value: {1}", value, JsonConvert.SerializeObject(value)); var task = documentClient.CreateDocumentAsync(documentCollection.DocumentsLink, value); task.Wait(); Context.Logger.Info("Document creation result status: {0}", task.Result.StatusCode); } //Ack the tuple if enableAck is set to true in TopologyBuilder. //This is mandatory if the downstream bolt or spout expects an ack. if (enableAck) { this.context.Ack(tuple); } } catch (Exception ex) { Context.Logger.Error("An error occured while executing Tuple Id: {0}. Exception Details:\r\n{1}", tuple.GetTupleId(), ex.ToString()); //Fail the tuple if enableAck is set to true in TopologyBuilder so that the tuple is replayed. if (enableAck) { this.context.Fail(tuple); } } }
public void Execute(SCPTuple tuple) { try { if (hubConnection.State != ConnectionState.Connected) { hubConnection.Stop(); StartSignalRHubConnection(); } var values = tuple.GetValues(); hubProxy.Invoke(this.SignalRMethod, values); //Ack the tuple if enableAck is set to true in TopologyBuilder. This is mandatory if the downstream bolt or spout expects an ack. if (enableAck) { this.context.Ack(tuple); } } catch (Exception ex) { Context.Logger.Error("An error occured while executing Tuple Id: {0}. Exception Details:\r\n{1}", tuple.GetTupleId(), ex.ToString()); //Fail the tuple if enableAck is set to true in TopologyBuilder so that the tuple is replayed. if (enableAck) { this.context.Fail(tuple); } } }
public void Execute(SCPTuple tuple) { try { //TODO: Insert or Upsert or Delete depending on your logic //Delete(new List<int>() { 1, 2 }, tuple.GetValues()); //Upsert(new List<int>() { 1, 2 }, tuple.GetValues()); Insert(tuple.GetValues()); //Ack the tuple if enableAck is set to true in TopologyBuilder. This is mandatory if the downstream bolt or spout expects an ack. if (enableAck) { this.context.Ack(tuple); } } catch (Exception ex) { Context.Logger.Error("An error occured while executing Tuple Id: {0}. Exception Details:\r\n{1}", tuple.GetTupleId(), ex.ToString()); //Fail the tuple if enableAck is set to true in TopologyBuilder so that the tuple is replayed. if (enableAck) { this.context.Fail(tuple); } } }
/// <summary> /// The execute method for tuple received /// </summary> /// <param name="tuple"></param> public void Execute(SCPTuple tuple) { try { var values = tuple.GetValues(); var data = string.Empty; if (values.Count == 1) { data = JsonConvert.SerializeObject(values[0]); } else { data = JsonConvert.SerializeObject(values); } eventHubSender.Send(new EventData(Encoding.UTF8.GetBytes(data))); //Ack the tuple if enableAck is set to true in TopologyBuilder. This is mandatory if the downstream bolt or spout expects an ack. if (enableAck) { this.context.Ack(tuple); } } catch (Exception ex) { Context.Logger.Error("An error occured while executing Tuple Id: {0}. Exception Details:\r\n{1}", tuple.GetTupleId(), ex.ToString()); //Fail the tuple if enableAck is set to true in TopologyBuilder so that the tuple is replayed. if (enableAck) { this.context.Fail(tuple); } } }
public void Execute(SCPTuple tuple) { Context.Logger.Info("SqlAzureBolt: Execute enter."); if (Insert(tuple.GetValues())) { Context.Logger.Info("SqlAzureBolt: Tuple inserted."); } else { Context.Logger.Info("SqlAzureBolt: Tuple insert failed."); } Context.Logger.Info("SqlAzureBolt: Execute exit."); }
public void Execute(SCPTuple tuple) { try { count++; var sb = new StringBuilder(); sb.AppendFormat("Received Tuple {0}: ", count); var values = tuple.GetValues(); for (int i = 0; i < values.Count; i++) { if (i > 0) { sb.Append(", "); } sb.AppendFormat("{0} = {1}", i, values[i].ToString()); } Context.Logger.Info(sb.ToString()); Context.Logger.Info("Tuple values as JSON: " + (values.Count == 1 ? JsonConvert.SerializeObject(values[0]) : JsonConvert.SerializeObject(values))); //Ack the tuple if enableAck is set to true in TopologyBuilder. This is mandatory if the downstream bolt or spout expects an ack. if (enableAck) { this.context.Ack(tuple); } } catch (Exception ex) { Context.Logger.Error("An error occured while executing Tuple Id: {0}. Exception Details:\r\n{1}", tuple.GetTupleId(), ex.ToString()); //Fail the tuple if enableAck is set to true in TopologyBuilder so that the tuple is replayed. if (enableAck) { this.context.Fail(tuple); } } }