Spring Questions and Answers – Splitters and Aggregators,Routing

«
»

This set of Java Spring Multiple Choice Questions & Answers (MCQs) focuses on “Splitters and Aggregators,Routing”.

1. To fork the process flow from one component to many, either all at once or to a single one based on a predicate condition.
a) splitter
b) fork
c) all of the mentioned
d) none of the mentioned
View Answer

Answer: a
Explanation: You can use a splitter component (and maybe its cohort, the aggregator component) to fork and join (respectively) control of processing.
advertisement

2. A splitter takes an input message and asks you, the user of the component, on what basis it should split the Message.
a) True
b) False
View Answer

Answer: a
Explanation: You’re responsible for providing the split functionality.

3. Spring Integration ships with useful splitters that require no customization.
a) Splitter
b) XPathMessageSplitter
c) All of the mentioned
d) None of the mentioned
View Answer

Answer: b
Explanation: In a few cases, Spring Integration ships with useful splitters that require no customization. One example is the splitter provided to partition an XML payload along an XPath query, XPathMessageSplitter.

4. Return type of the method annotated by the @Splitter annotation is of type:-
a) java.util.Collection
b) java.util.Date
c) all of the mentioned
d) none of the mentioned
View Answer

Answer: a
Explanation: The configuration for this is not terribly different from the previous solutions. The Java code is just about the same as well, except that the return type of the method annotated by the @Splitter annotation is of type java.util.Collection.

5. Annotation which collects a series of messages (based on some correlation that you help Spring Integration make between the messages).
a) @After
b) @Splitter
c) @Aggregator
d) None of the mentioned
View Answer

Answer: c
Explanation: An @Aggregator collects a series of messages (based on some correlation that you help Spring Integration make between the messages) and publishes a single message to the components downstream.

6. To determine how many messages to read until it can stop:-
a) SequenceSizeCompletionStrategy
b) SequenceSizeCompletion
c) SequenceSize
d) None of the mentioned
View Answer

Answer: a
Explanation: There are many ways for Spring Integration to correlate incoming messages. To determine how many messages to read until it can stop, it uses the class SequenceSizeCompletionStrategy, which reads a well known header value (aggregators are often used after a splitter.
advertisement

7. For correlation when you might not have a size but know that you’re expecting messages that share a common header value within a known time, Spring Integration provides the HeaderAttributeCorrelationStrategy.
a) True
b) False
View Answer

Answer: a
Explanation: In this way, it knows that all messages with that value are from the same group, in the same way that your last name identifies you as being part of a larger group.

8. The only custom logic is a POJO with an @Aggregator annotation on a method expecting a collection of Message objects.
a) True
b) False
View Answer

Answer: a
Explanation: It could, of course, be a collection of Customer objects, because they are what you’re expecting as output from the previous splitter.

9. You want to conditionally move a message through different processes based on some criteria.
a) router component
b) EAI
c) all of the mentioned
d) none of the mentioned
View Answer

Answer: a
Explanation: You can use a router component to alter the processing flow based on some predicate. You can also use a router to multicast a message to many subscribers (as you did with the splitter).

10. There are some convenient default routers available to fill common needs:-
a) PayloadTypeRouter
b) PayloadType
c) Payload
d) None of the mentioned
View Answer

Answer: a
Explanation: There are some convenient default routers available to fill common needs, such as payload-type–based routing (PayloadTypeRouter) and routing to a group or list of channels (RecipientListRouter).

11. To receive messages from an external system and process them using Spring Integration.
a) channel
b) channel adapter
c) EJP
d) none of the mentioned
View Answer

Answer: b
Explanation: Spring Integration makes it trivially easy to build one.

12. Adapters are opaque in nature.
a) True
b) False
View Answer

Answer: a
Explanation: Your external system interfaces with the adapter.
advertisement

13. Sometimes, functionality is made available from within the application via:-
a) Stable API
b) Cohesive API
c) All of the mentioned
d) None of the mentioned
View Answer

Answer: c
Explanation: Sometimes, functionality is made available from within the application via a cohesive, stable API but in a component model or form that isn’t directly accessible to the bus.

14. You use Spring Integration’s inbound-channel-adapter element to wire the TwitterMessageSource and a poller element.
a) True
b) False
View Answer

Answer: a
Explanation: The poller element is configured to run every 10 seconds and to consume as many as 100 messages each time it runs.

15. The API surfaces a Paging object, which works something like Criteria in Hibernate.
a) True
b) False
View Answer

Answer: a
Explanation: You can configure how many results to return using the count property. The most interesting option is called the sinceId, which lets you search for all records occurring after the Status having the ID equal to the value given as the sinceId.

Sanfoundry Global Education & Learning Series – Java Spring.
To practice all areas of Java Spring, here is complete set of 1000+ Multiple Choice Questions and Answers.

advertisement
Manish Bhojasia, a technology veteran with 20+ years @ Cisco & Wipro, is Founder and CTO at Sanfoundry. He is Linux Kernel Developer & SAN Architect and is passionate about competency developments in these areas. He lives in Bangalore and delivers focused training sessions to IT professionals in Linux Kernel, Linux Debugging, Linux Device Drivers, Linux Networking, Linux Storage, Advanced C Programming, SAN Storage Technologies, SCSI Internals & Storage Protocols such as iSCSI & Fiber Channel. Stay connected with him @ LinkedIn