Last active
June 19, 2020 06:43
-
-
Save jeffreycassar/1e926b551912af8f3d4ac25bbf3a4186 to your computer and use it in GitHub Desktop.
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
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