Skip to content

Instantly share code, notes, and snippets.

Show Gist options
  • Save alexmoleiro/e18c4baac71790babe0b608af5e6e0de to your computer and use it in GitHub Desktop.
Save alexmoleiro/e18c4baac71790babe0b608af5e6e0de to your computer and use it in GitHub Desktop.
public class SoapRouteBuilder extends RouteBuilder {
private final String uriFrom;
private final AlertingService alertingService;
public SoapRouteBuilder(String uriFrom, AlertingService alertingService) {
this.uriFrom = uriFrom;
this.alertingService = alertingService;
}
@Override
public void configure() {
from(uriFrom)
.unmarshal(jsonFormatFor(StackAnuncio.class))
.choice()
.when().body(StackAnuncio.class, stackAnuncio -> stackAnuncio.idPublicacion == alertingService.getIdPublicacion())
.process().body(StackAnuncio.class, stackAnuncio -> alertingService.alert(new Anuncio(stackAnuncio.idAnuncio, stackAnuncio.idTipoAnuncio, stackAnuncio.idOrigen)))
.endChoice();
}
private JacksonDataFormat jsonFormatFor(Class<?> unmarshalType) {
JacksonDataFormat dataFormat = new JacksonDataFormat();
dataFormat.setObjectMapper(new ObjectMapper());
dataFormat.setUnmarshalType(unmarshalType);
return dataFormat;
}
@JsonIgnoreProperties(ignoreUnknown = true)
private static class StackAnuncio {
public int idPublicacion;
public int idAnuncio;
public int idOrigen;
public int idTipoAnuncio;
}
}
Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment