Since i do no have enough reputation to comment on the other topic open about this
(How to unmarshall xml using spring integration dsl)
I had to create a new topic in order to ask my question. I have a JMS which polls XML messages from a queue, and i want to transform those messages into Java Objects. Here is the code i have written
@Bean
public IntegrationFlow jmsMessageDrivenRedeliveryFlow() {
return IntegrationFlows
.from(Jms.messageDrivenChannelAdapter(new ActiveMQConnectionFactory("tcp://localhost:61616"))
.errorChannel(IntegrationContextUtils.ERROR_CHANNEL_BEAN_NAME)
.destination("foo.bar").jmsMessageConverter(new MarshallingMessageConverter(jaxbMarshaller())))
.handle(m -> System.out.println(m.getName())).get();
}
@Bean
public Marshaller jaxbMarshaller() {
Jaxb2Marshaller jaxb2Marshaller = new Jaxb2Marshaller();
return jaxb2Marshaller;
}
The class that i want to Create from XML is Customer class with the following structure
@XmlRootElement
public class Customer {
String name;
int age;
int id;
public String getName() {
return name;
}
@XmlElement
public void setName(String name) {
this.name = name;
}
public int getAge() {
return age;
}
@XmlElement
public void setAge(int age) {
this.age = age;
}
public int getId() {
return id;
}
@XmlAttribute
public void setId(int id) {
this.id = id;
}
}
Based on the answers on the other thread, how can i configure the Marshaller to return a Customer object? Thanks a lot in advance.