Created
May 3, 2019 12:44
-
-
Save alexmoleiro/e18c4baac71790babe0b608af5e6e0de to your computer and use it in GitHub Desktop.
This file contains hidden or 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 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