Cloud Defense Logo

Products

Solutions

Company

Book A Live Demo

Top 10 Examples of "camunda-external-task-client-js in functional component" in JavaScript

Dive into secure and efficient coding practices with our curated list of the top 10 examples showcasing 'camunda-external-task-client-js' in functional components in JavaScript. Our advanced machine learning engine meticulously scans each line of code, cross-referencing millions of open source libraries to ensure your implementation is not just functional, but also robust and secure. Elevate your React applications to new heights by mastering the art of handling side effects, API calls, and asynchronous operations with confidence and precision.

const {
  Client,
  logger,
  Variables
} = require("camunda-external-task-client-js");

// configuration for the Client:
//  - 'baseUrl': url to the Workflow Engine
//  - 'logger': utility to automatically log important events
const config = {
  baseUrl: "http://localhost:8080/engine-rest",
  use: logger
};

// create a Client instance with custom configuration
const client = new Client(config);

// create a handler for the task
const handler = async ({ task, taskService }) => {
  // get task variable 'defaultScore'
  const defaultScore = task.variables.get("defaultScore");

  // set process variable 'creditScores'
  const creditScores = [defaultScore, 9, 1, 4, 10];
  const processVariables = new Variables()
    .set("creditScores", creditScores)
    .set("bar", new Date());

  // complete the task
  try {
    await taskService.complete(task, processVariables);
    console.log("I completed my task successfully!!");
const handler = async ({ task, taskService }) => {
  // get task variable 'defaultScore'
  const defaultScore = task.variables.get("defaultScore");

  // set process variable 'creditScores'
  const creditScores = [defaultScore, 9, 1, 4, 10];
  const processVariables = new Variables()
    .set("creditScores", creditScores)
    .set("bar", new Date());

  // complete the task
  try {
    await taskService.complete(task, processVariables);
    console.log("I completed my task successfully!!");
  } catch (e) {
    console.error(`Failed completing my task, ${e}`);
  }
};
Client,
  logger,
  Variables,
  File
} = require("camunda-external-task-client-js");

// configuration for the Client:
//  - 'baseUrl': url to the Workflow Engine
//  - 'logger': utility to automatically log important events
const config = {
  baseUrl: "http://localhost:8080/engine-rest",
  use: logger
};

// create a Client instance with custom configuration
const client = new Client(config);

// susbscribe to the topic: 'invoiceCreator'
client.subscribe("invoiceCreator", async function({ task, taskService }) {
  // Put your business logic
  // complete the task
  const date = new Date();
  const invoice = await new File({ localPath: "./assets/invoice.txt" }).load();
  const minute = date.getMinutes();
  const variables = new Variables().setAll({ invoice, date });

  // check if minute is even
  if (minute % 2 === 0) {
    // for even minutes, store variables in the process scope
    await taskService.complete(task, variables);
  } else {
    // for odd minutes, store variables in the task local scope
client.subscribe("invoiceCreator", async function({ task, taskService }) {
  // Put your business logic
  // complete the task
  const date = new Date();
  const invoice = await new File({ localPath: "./assets/invoice.txt" }).load();
  const minute = date.getMinutes();
  const variables = new Variables().setAll({ invoice, date });

  // check if minute is even
  if (minute % 2 === 0) {
    // for even minutes, store variables in the process scope
    await taskService.complete(task, variables);
  } else {
    // for odd minutes, store variables in the task local scope
    await taskService.complete(task, null, variables);
  }
});
public static defaultInterceptors() {
    const interceptors: any = [];
    try {
      const basicOauth = IoC.get(SERVICE_IDENTIFIER.camunda_oauth_info);
      interceptors.push(new BasicAuthInterceptor(basicOauth));
    } catch (error) {
      //
    }
    // add default timeout for polling
    interceptors.push(config => {
      config.timeout = GLOBAL_TIMEOUT_PULL;
      return config;
    });
    return interceptors;
  }
  public static getLogger() {
client.subscribe("invoiceCreator", async function({ task, taskService }) {
  // Put your business logic
  // complete the task
  const date = new Date();
  const invoice = await new File({ localPath: "./assets/invoice.txt" }).load();
  const minute = date.getMinutes();
  const variables = new Variables().setAll({ invoice, date });

  // check if minute is even
  if (minute % 2 === 0) {
    // for even minutes, store variables in the process scope
    await taskService.complete(task, variables);
  } else {
    // for odd minutes, store variables in the task local scope
    await taskService.complete(task, null, variables);
  }
});
var request = require('request');
const { Client, Variables } = require("camunda-external-task-client-js");

const config = { baseUrl: "http://localhost:8100/rest/engine/default", interval: 50, asyncResponseTimeout: 10000};
const client = new Client(config);

client.subscribe("customer-credit", async function({ task, taskService }) {
  var remainingAmount = 0;
  if (Math.random() > 0.3) {
    remainingAmount = 15;   
  }

  const processVariables = new Variables();
  processVariables.set("remainingAmount", remainingAmount);

  console.log('[%s] done for process instance %s with remainingAmount=%s', task.topicName, task.processInstanceId, remainingAmount);
  await taskService.complete(task, processVariables);
});

client.subscribe("customer-credit-refund", async function({ task, taskService }) {
  console.log('[%s] done for process instance %s', task.topicName, task.processInstanceId);
var request = require('request');
const { Client, Variables } = require("camunda-external-task-client-js");

const config = { baseUrl: "http://localhost:8080/engine-rest/engine/default/", interval: 50};
const client = new Client(config);

client.subscribe("customer-credit", async function({ task, taskService }) {
  var remainingAmount = 0;
  if (Math.random() > 0.3) {
    remainingAmount = 15;   
  }

  const processVariables = new Variables();
  processVariables.set("remainingAmount", remainingAmount);

  console.log('[%s] done for process instance %s with remainingAmount=%s', task.topicName, task.processInstanceId, remainingAmount);
  await taskService.complete(task, processVariables);
});

client.subscribe("customer-credit-refund", async function({ task, taskService }) {
  console.log('[%s] done for process instance %s', task.topicName, task.processInstanceId);
client.subscribe("customer-credit", async function({ task, taskService }) {
  var remainingAmount = 0;
  if (Math.random() > 0.3) {
    remainingAmount = 15;   
  }

  const processVariables = new Variables();
  processVariables.set("remainingAmount", remainingAmount);

  console.log('[%s] done for process instance %s with remainingAmount=%s', task.topicName, task.processInstanceId, remainingAmount);
  await taskService.complete(task, processVariables);
});
client.subscribe("customer-credit", async function({ task, taskService }) {
  var remainingAmount = 0;
  if (Math.random() > 0.3) {
    remainingAmount = 15;   
  }

  const processVariables = new Variables();
  processVariables.set("remainingAmount", remainingAmount);

  console.log('[%s] done for process instance %s with remainingAmount=%s', task.topicName, task.processInstanceId, remainingAmount);
  await taskService.complete(task, processVariables);
});

Is your System Free of Underlying Vulnerabilities?
Find Out Now