存储密钥值对以供WSO2 ESB代理服务中的参考

时间:2015-11-20 04:54:48

标签: proxy wso2 wso2esb esb

我使用以下格式的peopleHr连接器获取json数据,其中包含约500个员工详细信息:

{
  "Result": [
    {
      "EmployeeId": {
        "DisplayValue": "UK20900"
      },
      "Title": {
        "DisplayValue": "",
        "FieldHistory": []
      },
      "FirstName": {
        "DisplayValue": "Riyafa",
        "FieldHistory": []
      },
      "LastName": {
        "DisplayValue": "Abdul Hameed",
        "FieldHistory": []
      },
      "OtherName": {
        "DisplayValue": "",
        "FieldHistory": []
      },
      "KnownAs": {
        "DisplayValue": "",
        "FieldHistory": []
      },
      "EmailId": {
        "DisplayValue": "riyafa@rocketmail.com",
        "FieldHistory": []
      },
      "StartDate": {
        "DisplayValue": "2015-11-18",
        "FieldHistory": []
      },
      "DateOfBirth": {
        "DisplayValue": "",
        "FieldHistory": []
      },
      "JobRole": {
        "DisplayValue": "",
        "FieldHistoryForJobRole": [
          {
            "JobRole": null,
            "EffectiveDate": "2015-11-18",
            "ChangedOn": "2015-11-18",
            "ReasonForChange": "New Starter"
          }
        ]
      }
    },
    {
      "EmployeeId": {
        "DisplayValue": "LK500200",
        "FieldHistory": [
          {
            "OldValue": "LK",
            "NewValue": "LK500200",
            "ChangedOn": "2015-11-18",
            "ReasonForChange": "We choose our own employee ids"
          },
          {
            "OldValue": "PW2",
            "NewValue": "LK",
            "ChangedOn": "2015-11-18",
            "ReasonForChange": "Because we have a specific format for our employee ids"
          }
        ]
      },
      "Title": {
        "DisplayValue": "",
        "FieldHistory": []
      },
      "FirstName": {
        "DisplayValue": "Kalani",
        "FieldHistory": []
      },
      "LastName": {
        "DisplayValue": "Gayathri",
        "FieldHistory": []
      },
      "OtherName": {
        "DisplayValue": "",
        "FieldHistory": []
      },
      "KnownAs": {
        "DisplayValue": "",
        "FieldHistory": []
      },
      "EmailId": {
        "DisplayValue": "kalani.gayathri91@gmail.com",
        "FieldHistory": []
      },
      "StartDate": {
        "DisplayValue": "2015-11-17",
        "FieldHistory": []
      },
      "DateOfBirth": {
        "DisplayValue": "1992-05-08",
        "FieldHistory": []
      },
      "JobRole": {
        "DisplayValue": "IT",
        "FieldHistoryForJobRole": [
          {
            "JobRole": "IT",
            "EffectiveDate": "2015-11-17",
            "ChangedOn": "2015-11-18",
            "ReasonForChange": "New Starter"
          }
        ]
      }
    }
  ]
}

我想将EmailId和EmployeeId存储为一个键值对,以便在WSO2 ESB代理服务的未来引用中使用,我需要使用EmailId引用EmployeeId。我想过使用名称为EmailId的属性介体和值为EmployeeId的属性介体,但是表达式不能用作属性介体中的名称。如何提取这些值并将其存储以供将来在ESB代理服务中引用?

1 个答案:

答案 0 :(得分:2)

您可以使用'表达式'属性介体中的属性提取值(使用xpath或jsonpath)。

但是使用属性调解器对于这种情况不起作用,因为这些属性是消息的本地属性。也就是说,当您收到新消息时,您将获得该属性的单独新副本,而不是之前设置的值。

因此,您可以尝试以下方法之一:
- 用户DBReport和DBLookup调解器来存储和检索值。这将涉及建立一个数据库 - 使用自定义中介,该中介将保留传入消息中的值。有一个sample code here来保存一个值(来自一个属性)并将其与一个新值进行比较。您可以将其修改为仅保留该值并将其设置为新属性,您可以在新消息到达时使用该属性。