返回骡子创建数据库记录的细节 [英] Return details of DB record created in Mule

查看:241
本文介绍了返回骡子创建数据库记录的细节的处理方法,对大家解决问题具有一定的参考价值,需要的朋友们下面随着小编来一起学习吧!

问题描述

在使用Mule的通用数据库连接器是有办法,当你到一个数据库中,ID(或整条记录)插入一个新的记录被返回到流作为有效载荷?

When using the Generic Database Connector in Mule is there a way that when you insert a new record in to a database, the ID (or entire record) is returned back to the flow as the payload?

我的使用情况是在相当普遍,我揭露这将导致在数据库中生成一个记录的API。该API调用的响应需要包含创建的记录的ID。

My use case is fairly common in that I'm exposing an API which results in a record being generated in a database. The response to that API call needs to include the ID of the record created.

我已经通过了骡子文档看了看,没有发现任何东西。但愿我俯瞰的东西很明显这里...

I've looked through the Mule documentation and haven't found anything. Hopefully I'm overlooking something very obvious here...

推荐答案

代替生成数据库中的一个ID,后来取回它,我建议生成 UUID 内使用 java.util.Random中的,并使用在数据库中插入记录你的骡子的应用程序。这样,您就已经拥有了ID,无需从数据库得到它。

Instead of generating an ID in database and later retrieving it, I'd recommend generating a UUID inside your mule application using java.util.Random and using that to insert record in db. This way you already have the ID and no need to get it from db.

这篇关于返回骡子创建数据库记录的细节的文章就介绍到这了,希望我们推荐的答案对大家有所帮助,也希望大家多多支持IT屋!

查看全文
登录 关闭
扫码关注1秒登录
发送“验证码”获取 | 15天全站免登陆