Java Reference
In-Depth Information
<beans:bean id="inboundJMSMessageToCustomerTransformer"
class="com.apress.springenterpriserecipes.springintegration.
InboundJMSMessageToCustomerTransformer"/>
<beans:bean id="inboundCustomerServiceActivator"
class="com.apress.springenterpriserecipes.springintegration.
InboundCustomerServiceActivator"/>
<channel id="inboundHelloJMSMessageChannel"/>
<channel id="inboundCustomerChannel"/>
<jms:message-driven-channel-adapter channel="inbound
HelloJMSMessageChannel" extract-payload="true" connection-factory
="connectionFactory" destination-name="solution015"/>
<transformer input-channel="inboundHelloJMSMessageChannel"
ref="inboundJMSMessageToCustomerTransformer" output-
channel="inboundCustomerChannel"/>
<service-activator input-channel="inboundCustomerChannel"
ref="inboundCustomerServiceActivator" />
</beans:beans>
Here, you're also specifying an output-channel attribute on the component, which tells a
component on what channel to send the component's response output; in this case, the Customer .
The code in the next component can now declare a dependency on the Customer interface with
impunity. You can, with transformers, receive messages from any number of sources and transform into
a Customer so that you can reuse the InboundCustomerServiceActivator :
package com.apress.springenterpriserecipes.springintegration;
import org.apache.log4j.Logger;
import org.springframework.integration.annotation.ServiceActivator;
import org.springframework.integration.core.Message;
public class InboundCustomerServiceActivator {
private static final Logger logger =
Logger.getLogger(InboundCustomerServiceActivator.class);
@ServiceActivator
public void doSomethingWithCustomer(
Message<Customer> customerMessage) {
Customer customer = customerMessage.getPayload();
logger.debug(String.format("id=%s, firstName:%s, lastName:%s",
customer.getId(),
customer.getFirstName(),
customer.getLastName()));
}
}
Search WWH ::




Custom Search