Skip to content

Instantly share code, notes, and snippets.

@bibryam
Last active July 19, 2018 20:13
Show Gist options
  • Select an option

  • Save bibryam/5120d55277684a80bd23a18591070607 to your computer and use it in GitHub Desktop.

Select an option

Save bibryam/5120d55277684a80bd23a18591070607 to your computer and use it in GitHub Desktop.
A Camel route that listens for CallbackGetBTCCap events and calls setBTCCap with a random value
@Override
public void configure() throws Exception {
from("web3j://http://127.0.0.1:7545?operation=ETH_LOG_OBSERVABLE&topics=" + topics)
.to("log:com.ofbizian.CallbackGetBTCCap?level=INFO&showAll=true")
.setHeader(OPERATION, constant(ETH_SEND_TRANSACTION))
.setHeader(FROM_ADDRESS, constant("0xc8CDceCE5d006dAB638029EBCf6Dd666efF5A952"))
.setHeader(TO_ADDRESS, constant("0x484982345fD584a0a16deC5F9ba330f6383af3d9"))
.process(new Processor() {
public void process(Exchange exchange) throws Exception {
int random = rand.nextInt(50);
Function function = new Function("setBTCCap", Arrays.<Type>asList(
new Uint(BigInteger.valueOf(btcPrice))), Collections.<TypeReference<?>>emptyList());
exchange.getIn().setHeader(DATA, FunctionEncoder.encode(function));
}
})
.to("web3j://http://127.0.0.1:7545");
}
Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment