adplus-dvertising
frame-decoration

Question

The output is constructed dynamically using MessageBuilder to create a message that has the same payload as the input message as well as copy the existing headers and adds an extra header:
import org.springframework.integration.annotation.Transformer;
import org.springframework.integration.core.Message;
import org.springframework.integration.message.MessageBuilder;
import java.util.Map;
public class InboundJMSMessageToCustomerWithExtraMetadataTransformer {
	@Transformer
	public Message<Customer> transformJMSMapToCustomer(
	Message<Map<String, Object>> inboundSpringIntegrationMessage) {
	Map<String, Object> jmsMessagePayload =
	inboundSpringIntegrationMessage.getPayload();
	Customer customer = new Customer();
	customer.setFirstName((String) jmsMessagePayload.get("firstName"));
	customer.setLastName((String) jmsMessagePayload.get("lastName"));
	customer.setId((Long) jmsMessagePayload.get("id"));
	return MessageBuilder.withPayload(customer)
	.copyHeadersIfAbsent( inboundSpringIntegrationMessage.getHeaders())
	.setHeaderIfAbsent("randomlySelectedForSurvey", Math.random() > .5)
	.build();
	}
}

a.

randomlySelected

b.

randomlySelectedForSurvey

c.

randomly

d.

none of the mentioned

Posted under Java Spring Framework

Answer: (b).randomlySelectedForSurvey

Engage with the Community - Add Your Comment

Confused About the Answer? Ask for Details Here.

Know the Explanation? Add it Here.

Q. The output is constructed dynamically using MessageBuilder to create a message that has the same payload as the input message as well as copy the existing headers and adds an extra...

Similar Questions

Discover Related MCQs

Q. Spring Integration provides a transformer message endpoint to permit the augmentation of the message headers.

Q. To send a message into the bus and transform it before working with it further.

Q. To parameterize a job, which is then available to your steps through Spring Batch expression language.

Q. The bean is recognized and becomes part of the application context because of the:-

Q. More complicated return codes can be returned by creating and declaring a top-level bean that implements the interface:-

Q. The CommandLineJobRunner for success will return system error codes:-

Q. TaskExecutor that will spawn a thread of execution and manage that thread without blocking.

Q. JobLauncher reference you configured previously is obtained and used to then launch an instance of a Job.

Q. Spring Batch work with a system scheduler:-

Q. If you want to vary the execution flow based on some logic more complex than a job’s ExitStatuses:-

Q. To determine the next step is the simplest example of a conditional flow.

Q. Spring Batch ships with only handler, which executes steps in multiple threads using a TaskExecutor strategy.

Q. Pattern which refers to the arrangement of multiple JMS clients all consuming the same queue messages.

Q. Spring Batch provides a mechanism to offload processing to another process.

Q. There’s nothing to prevent you from having many steps within the flow elements.

Q. Typical jobs of almost any complexity will have multiple steps, however.

Q. You want to control how steps are executed, perhaps to eliminate a needless waste of time by:-

Q. One of the more useful settings for the RetryTemplate is the :-

Q. The RetryTemplate itself is configured in the Spring context, although it’s trivial to create in code.

Q. The RetryTemplate supports many use cases, with convenient APIs to wrap.