Package com.trafficparrot.sdk.messaging
Class JmsResponseBuilder
java.lang.Object
com.trafficparrot.sdk.messaging.JmsResponseBuilder
- Direct Known Subclasses:
JmsResponseBuilder
Builds the
JmsResponse a JmsResponseTransformer returns, from a destination and a body:
return new JmsResponseBuilder()
.like(response)
.withDestination(new Destination("other.queue", response.destination.type))
.build();
The response it builds names no transformer, as a transformer's result must, and has no JMS properties, no delay
and the default destination lookup. To keep the mapping's, use the JmsResponse constructor that takes
them.-
Constructor Summary
Constructors -
Method Summary
Modifier and TypeMethodDescriptionbuild()Builds the response.like(JmsResponse response) Takes the destination, body and body type of a response.withBytes(byte[] bytes) Sets a binary body, sent as a bytes message.withDestination(Destination destination) Sets the queue or topic the response is sent to when the request names no reply-to destination.withObject(Object object) Sets a Java object as the body, held as its JSON with the object's class as the body type.Sets a text body, sent as a text message.
-
Constructor Details
-
JmsResponseBuilder
public JmsResponseBuilder()Creates a builder with no destination and no body.
-
-
Method Details
-
like
Takes the destination, body and body type of a response. A body the response reads from a file is taken as its content. Nothing else is taken: its JMS properties, delay and destination lookup are not carried over.- Parameters:
response- the response to take them from, usually the mapping's- Returns:
- this builder
-
withText
Sets a text body, sent as a text message.- Parameters:
text- the body, which may hold Handlebars expressions- Returns:
- this builder
-
withBytes
Sets a binary body, sent as a bytes message.- Parameters:
bytes- the body- Returns:
- this builder
-
withObject
public JmsResponseBuilder withObject(Object object) throws com.fasterxml.jackson.core.JsonProcessingException Sets a Java object as the body, held as its JSON with the object's class as the body type.- Parameters:
object- the object to send- Returns:
- this builder
- Throws:
com.fasterxml.jackson.core.JsonProcessingException- if the object cannot be written as JSON
-
withDestination
Sets the queue or topic the response is sent to when the request names no reply-to destination.- Parameters:
destination- the destination- Returns:
- this builder
-
build
Builds the response.- Returns:
- a response with the destination and body set so far, which names no transformer
-