Skip to content

Instantly share code, notes, and snippets.

@jeffreycassar
Last active June 19, 2020 06:43
Show Gist options
  • Star 0 You must be signed in to star a gist
  • Fork 0 You must be signed in to fork a gist
  • Save jeffreycassar/1e926b551912af8f3d4ac25bbf3a4186 to your computer and use it in GitHub Desktop.
Save jeffreycassar/1e926b551912af8f3d4ac25bbf3a4186 to your computer and use it in GitHub Desktop.
public class InsertPersonMessageProcessor implements MessageProcessor {
@Autowired
private TxAwareDataSourceConnectionProvider connProvider;
@Override
public MuleEvent process(MuleEvent event) throws MuleException {
Map<String, Object> personInfo = event.getFlowVariable("personInfo");
Connection connection;
try {
connection = connProvider.getConnection();
DSLContext dslContext = DSL.using(connection, SQLDialect.DEFAULT);
dslContext.insertInto(DSL.table("People"))
.columns(DSL.field("firstname"), DSL.field("lastname"), DSL.field("age"))
.values(personInfo.get("firstname"), personInfo.get("lastname"), personInfo.get("age"))
.execute();
} catch (Exception e) {
// handle exceptions accordingly
throw new RuntimeException(e);
}
return event;
}
}
Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment