Spring interview questions part 45

Spring interview questions part 45

Take as many assements as you can to improve your validate your skill rating

Total Questions: 20

1. You want to work with a resource that may fail when you try to read from or write to it.

Correct Answer is : Spring batch retry

2. Some invocations will fail but may be retried with some likelihood of success in a transactional scenario.

Correct Answer is : FALSE

3. You can specify exception classes on which to retry the operation.

Correct Answer is : TRUE

4. You can leverage Spring Batch support for retries and recovery in your own code.

Correct Answer is : TRUE

5. The template that (much like its various other Template cousins) isolates your logic from the nuances of retries and instead enables you to write the code as though you were only going to attempt it once.

Correct Answer is : RetryTemplate

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

Correct Answer is : TRUE

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

Correct Answer is : TRUE

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

Correct Answer is : BackOffPolicy

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

Correct Answer is : all of the mentioned

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

Correct Answer is : TRUE

11. 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 transformJMSMapToCustomer( Message> inboundSpringIntegrationMessage) { Map 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(); } }

Correct Answer is : randomlySelectedForSurvey

12. Spring Integration provides the ability to catch exceptions and send them to an error channel of your choosing. By default, it’s a global channel called :-

Correct Answer is : errorChannel

13. The errorChannel doesn’t need to be a service-activator.

Correct Answer is : TRUE

14. All errors thrown from Spring Integration components will be a subclass of:-

Correct Answer is : MessagingException

15. One way to discriminate by Exception type is to use:-

Correct Answer is : org.springframework.integration.router.ErrorMessageExceptionTypeRouter

16. Sending all the errors to the same channel can eventually lead to a large switch-laden class that’s too complex to maintain.

Correct Answer is : TRUE

17. You can explicitly specify on what channel errors for a given integration should go.

Correct Answer is : TRUE

18. Spring Integration will use that header and forward errors encountered in the processing of this message to that channel.

Correct Answer is : TRUE

19. All errors that come from the integration in which this component is used will be directed to:- import org.apache.log4j.Logger; import org.springframework.integration.annotation.ServiceActivator; import org.springframework.integration.core.Message; import org.springframework.integration.core.MessageHeaders; import org.springframework.integration.message.MessageBuilder; public class ServiceActivatorThatSpecifiesErrorChannel { private static final Logger logger = Logger.getLogger( ServiceActivatorThatSpecifiesErrorChannel.class); @ServiceActivator public Message startIntegrationFlow(Message firstMessage) throws Throwable { return MessageBuilder.fromMessage(firstMessage). setHeaderIfAbsent( MessageHeaders.ERROR_CHANNEL, "errorChannelForMySolution").build(); } }

Correct Answer is : customErrorChannel

20. This encapsulates the context of a test’s execution:-

Correct Answer is : Test context

Similar Interview Questions

    Search for latest jobs

    Icon
    Icon