Browse Source

Consistent nullability and exception declarations

Closes gh-35159
pull/35405/head
Juergen Hoeller 6 months ago
parent
commit
9596b70b2a
  1. 28
      spring-jms/src/main/java/org/springframework/jms/core/JmsMessageOperations.java
  2. 47
      spring-messaging/src/main/java/org/springframework/messaging/core/AbstractDestinationResolvingMessagingTemplate.java
  3. 28
      spring-messaging/src/main/java/org/springframework/messaging/core/AbstractMessageReceivingTemplate.java
  4. 15
      spring-messaging/src/main/java/org/springframework/messaging/core/AbstractMessageSendingTemplate.java
  5. 35
      spring-messaging/src/main/java/org/springframework/messaging/core/AbstractMessagingTemplate.java
  6. 8
      spring-messaging/src/main/java/org/springframework/messaging/core/DestinationResolvingMessageRequestReplyOperations.java
  7. 8
      spring-messaging/src/main/java/org/springframework/messaging/core/DestinationResolvingMessageSendingOperations.java
  8. 12
      spring-messaging/src/main/java/org/springframework/messaging/core/MessageRequestReplyOperations.java
  9. 16
      spring-messaging/src/main/java/org/springframework/messaging/core/MessageSendingOperations.java

28
spring-jms/src/main/java/org/springframework/jms/core/JmsMessageOperations.java

@ -30,8 +30,12 @@ import org.springframework.messaging.core.MessageSendingOperations; @@ -30,8 +30,12 @@ import org.springframework.messaging.core.MessageSendingOperations;
/**
* A specialization of {@link MessageSendingOperations}, {@link MessageReceivingOperations}
* and {@link MessageRequestReplyOperations} for JMS related operations that allow to specify
* a destination name rather than the actual {@link jakarta.jms.Destination}.
* and {@link MessageRequestReplyOperations} for JMS related operations that allow to
* specify a destination name rather than the actual {@link jakarta.jms.Destination}.
*
* <p>Note: Operations in this interface throw {@link MessagingException} instead of
* the JMS-specific {@link org.springframework.jms.JmsException}, aligning with the
* {@code spring-messaging} module and its other client operation handles.
*
* @author Stephane Nicoll
* @since 4.1
@ -68,30 +72,30 @@ public interface JmsMessageOperations extends MessageSendingOperations<Destinati @@ -68,30 +72,30 @@ public interface JmsMessageOperations extends MessageSendingOperations<Destinati
* @param payload the Object to use as payload
* @param headers the headers for the message to send
*/
void convertAndSend(String destinationName, Object payload, Map<String, Object> headers)
void convertAndSend(String destinationName, Object payload, @Nullable Map<String, Object> headers)
throws MessagingException;
/**
* Convert the given Object to serialized form, possibly using a
* {@link org.springframework.messaging.converter.MessageConverter},
* wrap it as a message, apply the given post processor, and send
* wrap it as a message, apply the given post-processor, and send
* the resulting message to the given destination.
* @param destinationName the name of the target destination
* @param payload the Object to use as payload
* @param postProcessor the post processor to apply to the message
* @param postProcessor the post-processor to apply to the message
*/
void convertAndSend(String destinationName, Object payload, MessagePostProcessor postProcessor)
void convertAndSend(String destinationName, Object payload, @Nullable MessagePostProcessor postProcessor)
throws MessagingException;
/**
* Convert the given Object to serialized form, possibly using a
* {@link org.springframework.messaging.converter.MessageConverter},
* wrap it as a message with the given headers, apply the given post processor,
* wrap it as a message with the given headers, apply the given post-processor,
* and send the resulting message to the given destination.
* @param destinationName the name of the target destination
* @param payload the Object to use as payload
* @param headers the headers for the message to send
* @param postProcessor the post processor to apply to the message
* @param postProcessor the post-processor to apply to the message
*/
void convertAndSend(String destinationName, Object payload, @Nullable Map<String, Object> headers,
@Nullable MessagePostProcessor postProcessor) throws MessagingException;
@ -159,13 +163,13 @@ public interface JmsMessageOperations extends MessageSendingOperations<Destinati @@ -159,13 +163,13 @@ public interface JmsMessageOperations extends MessageSendingOperations<Destinati
/**
* Convert the given request Object to serialized form, possibly using a
* {@link org.springframework.messaging.converter.MessageConverter},
* apply the given post processor and send the resulting {@link Message} to the
* apply the given post-processor and send the resulting {@link Message} to the
* given destination, receive the reply and convert its body of the given
* target class.
* @param destinationName the name of the target destination
* @param request payload for the request message to send
* @param targetClass the target type to convert the payload of the reply to
* @param requestPostProcessor post process to apply to the request message
* @param requestPostProcessor post-process to apply to the request message
* @return the payload of the reply message, possibly {@code null} if the message
* could not be received, for example due to a timeout
*/
@ -176,13 +180,13 @@ public interface JmsMessageOperations extends MessageSendingOperations<Destinati @@ -176,13 +180,13 @@ public interface JmsMessageOperations extends MessageSendingOperations<Destinati
/**
* Convert the given request Object to serialized form, possibly using a
* {@link org.springframework.messaging.converter.MessageConverter},
* wrap it as a message with the given headers, apply the given post processor
* wrap it as a message with the given headers, apply the given post-processor
* and send the resulting {@link Message} to the specified destination, receive
* the reply and convert its body of the given target class.
* @param destinationName the name of the target destination
* @param request payload for the request message to send
* @param targetClass the target type to convert the payload of the reply to
* @param requestPostProcessor post process to apply to the request message
* @param requestPostProcessor post-process to apply to the request message
* @return the payload of the reply message, possibly {@code null} if the message
* could not be received, for example due to a timeout
*/

47
spring-messaging/src/main/java/org/springframework/messaging/core/AbstractDestinationResolvingMessagingTemplate.java

@ -20,6 +20,7 @@ import java.util.Map; @@ -20,6 +20,7 @@ import java.util.Map;
import org.springframework.lang.Nullable;
import org.springframework.messaging.Message;
import org.springframework.messaging.MessagingException;
import org.springframework.util.Assert;
/**
@ -65,37 +66,41 @@ public abstract class AbstractDestinationResolvingMessagingTemplate<D> extends A @@ -65,37 +66,41 @@ public abstract class AbstractDestinationResolvingMessagingTemplate<D> extends A
return this.destinationResolver;
}
protected final D resolveDestination(String destinationName) throws DestinationResolutionException {
Assert.state(this.destinationResolver != null,
"DestinationResolver is required to resolve destination names");
return this.destinationResolver.resolveDestination(destinationName);
}
@Override
public void send(String destinationName, Message<?> message) {
public void send(String destinationName, Message<?> message) throws MessagingException {
D destination = resolveDestination(destinationName);
doSend(destination, message);
}
protected final D resolveDestination(String destinationName) {
Assert.state(this.destinationResolver != null, "DestinationResolver is required to resolve destination names");
return this.destinationResolver.resolveDestination(destinationName);
}
@Override
public <T> void convertAndSend(String destinationName, T payload) {
public <T> void convertAndSend(String destinationName, T payload) throws MessagingException {
convertAndSend(destinationName, payload, null, null);
}
@Override
public <T> void convertAndSend(String destinationName, T payload, @Nullable Map<String, Object> headers) {
public <T> void convertAndSend(String destinationName, T payload, @Nullable Map<String, Object> headers)
throws MessagingException {
convertAndSend(destinationName, payload, headers, null);
}
@Override
public <T> void convertAndSend(String destinationName, T payload, @Nullable MessagePostProcessor postProcessor) {
public <T> void convertAndSend(String destinationName, T payload, @Nullable MessagePostProcessor postProcessor)
throws MessagingException {
convertAndSend(destinationName, payload, null, postProcessor);
}
@Override
public <T> void convertAndSend(String destinationName, T payload,
@Nullable Map<String, Object> headers, @Nullable MessagePostProcessor postProcessor) {
public <T> void convertAndSend(String destinationName, T payload, @Nullable Map<String, Object> headers,
@Nullable MessagePostProcessor postProcessor) throws MessagingException {
D destination = resolveDestination(destinationName);
super.convertAndSend(destination, payload, headers, postProcessor);
@ -103,28 +108,32 @@ public abstract class AbstractDestinationResolvingMessagingTemplate<D> extends A @@ -103,28 +108,32 @@ public abstract class AbstractDestinationResolvingMessagingTemplate<D> extends A
@Override
@Nullable
public Message<?> receive(String destinationName) {
public Message<?> receive(String destinationName) throws MessagingException {
D destination = resolveDestination(destinationName);
return super.receive(destination);
}
@Override
@Nullable
public <T> T receiveAndConvert(String destinationName, Class<T> targetClass) {
public <T> T receiveAndConvert(String destinationName, Class<T> targetClass) throws MessagingException {
D destination = resolveDestination(destinationName);
return super.receiveAndConvert(destination, targetClass);
}
@Override
@Nullable
public Message<?> sendAndReceive(String destinationName, Message<?> requestMessage) {
public Message<?> sendAndReceive(String destinationName, Message<?> requestMessage)
throws MessagingException {
D destination = resolveDestination(destinationName);
return super.sendAndReceive(destination, requestMessage);
}
@Override
@Nullable
public <T> T convertSendAndReceive(String destinationName, Object request, Class<T> targetClass) {
public <T> T convertSendAndReceive(String destinationName, Object request, Class<T> targetClass)
throws MessagingException {
D destination = resolveDestination(destinationName);
return super.convertSendAndReceive(destination, request, targetClass);
}
@ -132,7 +141,7 @@ public abstract class AbstractDestinationResolvingMessagingTemplate<D> extends A @@ -132,7 +141,7 @@ public abstract class AbstractDestinationResolvingMessagingTemplate<D> extends A
@Override
@Nullable
public <T> T convertSendAndReceive(String destinationName, Object request,
@Nullable Map<String, Object> headers, Class<T> targetClass) {
@Nullable Map<String, Object> headers, Class<T> targetClass) throws MessagingException {
D destination = resolveDestination(destinationName);
return super.convertSendAndReceive(destination, request, headers, targetClass);
@ -141,7 +150,7 @@ public abstract class AbstractDestinationResolvingMessagingTemplate<D> extends A @@ -141,7 +150,7 @@ public abstract class AbstractDestinationResolvingMessagingTemplate<D> extends A
@Override
@Nullable
public <T> T convertSendAndReceive(String destinationName, Object request, Class<T> targetClass,
@Nullable MessagePostProcessor postProcessor) {
@Nullable MessagePostProcessor postProcessor) throws MessagingException {
D destination = resolveDestination(destinationName);
return super.convertSendAndReceive(destination, request, targetClass, postProcessor);
@ -151,7 +160,7 @@ public abstract class AbstractDestinationResolvingMessagingTemplate<D> extends A @@ -151,7 +160,7 @@ public abstract class AbstractDestinationResolvingMessagingTemplate<D> extends A
@Nullable
public <T> T convertSendAndReceive(String destinationName, Object request,
@Nullable Map<String, Object> headers, Class<T> targetClass,
@Nullable MessagePostProcessor postProcessor) {
@Nullable MessagePostProcessor postProcessor) throws MessagingException {
D destination = resolveDestination(destinationName);
return super.convertSendAndReceive(destination, request, headers, targetClass, postProcessor);

28
spring-messaging/src/main/java/org/springframework/messaging/core/AbstractMessageReceivingTemplate.java

@ -18,6 +18,7 @@ package org.springframework.messaging.core; @@ -18,6 +18,7 @@ package org.springframework.messaging.core;
import org.springframework.lang.Nullable;
import org.springframework.messaging.Message;
import org.springframework.messaging.MessagingException;
import org.springframework.messaging.converter.MessageConversionException;
import org.springframework.messaging.converter.MessageConverter;
@ -36,35 +37,25 @@ public abstract class AbstractMessageReceivingTemplate<D> extends AbstractMessag @@ -36,35 +37,25 @@ public abstract class AbstractMessageReceivingTemplate<D> extends AbstractMessag
@Override
@Nullable
public Message<?> receive() {
public Message<?> receive() throws MessagingException {
return doReceive(getRequiredDefaultDestination());
}
@Override
@Nullable
public Message<?> receive(D destination) {
public Message<?> receive(D destination) throws MessagingException {
return doReceive(destination);
}
/**
* Actually receive a message from the given destination.
* @param destination the target destination
* @return the received message, possibly {@code null} if the message could not
* be received, for example due to a timeout
*/
@Nullable
protected abstract Message<?> doReceive(D destination);
@Override
@Nullable
public <T> T receiveAndConvert(Class<T> targetClass) {
public <T> T receiveAndConvert(Class<T> targetClass) throws MessagingException {
return receiveAndConvert(getRequiredDefaultDestination(), targetClass);
}
@Override
@Nullable
public <T> T receiveAndConvert(D destination, Class<T> targetClass) {
public <T> T receiveAndConvert(D destination, Class<T> targetClass) throws MessagingException {
Message<?> message = doReceive(destination);
if (message != null) {
return doConvert(message, targetClass);
@ -92,4 +83,13 @@ public abstract class AbstractMessageReceivingTemplate<D> extends AbstractMessag @@ -92,4 +83,13 @@ public abstract class AbstractMessageReceivingTemplate<D> extends AbstractMessag
return value;
}
/**
* Actually receive a message from the given destination.
* @param destination the target destination
* @return the received message, possibly {@code null} if the
* message could not be received, for example due to a timeout
*/
@Nullable
protected abstract Message<?> doReceive(D destination);
}

15
spring-messaging/src/main/java/org/springframework/messaging/core/AbstractMessageSendingTemplate.java

@ -109,9 +109,6 @@ public abstract class AbstractMessageSendingTemplate<D> implements MessageSendin @@ -109,9 +109,6 @@ public abstract class AbstractMessageSendingTemplate<D> implements MessageSendin
doSend(destination, message);
}
protected abstract void doSend(D destination, Message<?> message);
@Override
public void convertAndSend(Object payload) throws MessagingException {
convertAndSend(payload, null);
@ -151,13 +148,14 @@ public abstract class AbstractMessageSendingTemplate<D> implements MessageSendin @@ -151,13 +148,14 @@ public abstract class AbstractMessageSendingTemplate<D> implements MessageSendin
send(destination, message);
}
/**
* Convert the given Object to serialized form, possibly using a
* {@link MessageConverter}, wrap it as a message with the given
* headers and apply the given post processor.
* headers and apply the given post-processor.
* @param payload the Object to use as payload
* @param headers the headers for the message to send
* @param postProcessor the post processor to apply to the message
* @param postProcessor the post-processor to apply to the message
* @return the converted message
*/
protected Message<?> doConvert(Object payload, @Nullable Map<String, Object> headers,
@ -199,4 +197,11 @@ public abstract class AbstractMessageSendingTemplate<D> implements MessageSendin @@ -199,4 +197,11 @@ public abstract class AbstractMessageSendingTemplate<D> implements MessageSendin
return headers;
}
/**
* Actually send the given message to the given destination.
* @param destination the target destination
* @param message the message to send
*/
protected abstract void doSend(D destination, Message<?> message);
}

35
spring-messaging/src/main/java/org/springframework/messaging/core/AbstractMessagingTemplate.java

@ -20,6 +20,7 @@ import java.util.Map; @@ -20,6 +20,7 @@ import java.util.Map;
import org.springframework.lang.Nullable;
import org.springframework.messaging.Message;
import org.springframework.messaging.MessagingException;
/**
* An extension of {@link AbstractMessageReceivingTemplate} that adds support for
@ -36,36 +37,33 @@ public abstract class AbstractMessagingTemplate<D> extends AbstractMessageReceiv @@ -36,36 +37,33 @@ public abstract class AbstractMessagingTemplate<D> extends AbstractMessageReceiv
@Override
@Nullable
public Message<?> sendAndReceive(Message<?> requestMessage) {
public Message<?> sendAndReceive(Message<?> requestMessage) throws MessagingException {
return sendAndReceive(getRequiredDefaultDestination(), requestMessage);
}
@Override
@Nullable
public Message<?> sendAndReceive(D destination, Message<?> requestMessage) {
public Message<?> sendAndReceive(D destination, Message<?> requestMessage) throws MessagingException {
return doSendAndReceive(destination, requestMessage);
}
@Nullable
protected abstract Message<?> doSendAndReceive(D destination, Message<?> requestMessage);
@Override
@Nullable
public <T> T convertSendAndReceive(Object request, Class<T> targetClass) {
public <T> T convertSendAndReceive(Object request, Class<T> targetClass) throws MessagingException {
return convertSendAndReceive(getRequiredDefaultDestination(), request, targetClass);
}
@Override
@Nullable
public <T> T convertSendAndReceive(D destination, Object request, Class<T> targetClass) {
public <T> T convertSendAndReceive(D destination, Object request, Class<T> targetClass) throws MessagingException {
return convertSendAndReceive(destination, request, null, targetClass);
}
@Override
@Nullable
public <T> T convertSendAndReceive(
D destination, Object request, @Nullable Map<String, Object> headers, Class<T> targetClass) {
D destination, Object request, @Nullable Map<String, Object> headers, Class<T> targetClass)
throws MessagingException {
return convertSendAndReceive(destination, request, headers, targetClass, null);
}
@ -73,7 +71,8 @@ public abstract class AbstractMessagingTemplate<D> extends AbstractMessageReceiv @@ -73,7 +71,8 @@ public abstract class AbstractMessagingTemplate<D> extends AbstractMessageReceiv
@Override
@Nullable
public <T> T convertSendAndReceive(
Object request, Class<T> targetClass, @Nullable MessagePostProcessor postProcessor) {
Object request, Class<T> targetClass, @Nullable MessagePostProcessor postProcessor)
throws MessagingException {
return convertSendAndReceive(getRequiredDefaultDestination(), request, targetClass, postProcessor);
}
@ -81,7 +80,7 @@ public abstract class AbstractMessagingTemplate<D> extends AbstractMessageReceiv @@ -81,7 +80,7 @@ public abstract class AbstractMessagingTemplate<D> extends AbstractMessageReceiv
@Override
@Nullable
public <T> T convertSendAndReceive(D destination, Object request, Class<T> targetClass,
@Nullable MessagePostProcessor postProcessor) {
@Nullable MessagePostProcessor postProcessor) throws MessagingException {
return convertSendAndReceive(destination, request, null, targetClass, postProcessor);
}
@ -90,11 +89,23 @@ public abstract class AbstractMessagingTemplate<D> extends AbstractMessageReceiv @@ -90,11 +89,23 @@ public abstract class AbstractMessagingTemplate<D> extends AbstractMessageReceiv
@Override
@Nullable
public <T> T convertSendAndReceive(D destination, Object request, @Nullable Map<String, Object> headers,
Class<T> targetClass, @Nullable MessagePostProcessor postProcessor) {
Class<T> targetClass, @Nullable MessagePostProcessor postProcessor) throws MessagingException {
Message<?> requestMessage = doConvert(request, headers, postProcessor);
Message<?> replyMessage = sendAndReceive(destination, requestMessage);
return (replyMessage != null ? (T) getMessageConverter().fromMessage(replyMessage, targetClass) : null);
}
/**
* Actually send the given request message to the given destination and
* receive a reply message for it.
* @param destination the target destination
* @param requestMessage the message to send
* @return the received reply, possibly {@code null} if the
* message could not be received, for example due to a timeout
*/
@Nullable
protected abstract Message<?> doSendAndReceive(D destination, Message<?> requestMessage);
}

8
spring-messaging/src/main/java/org/springframework/messaging/core/DestinationResolvingMessageRequestReplyOperations.java

@ -82,13 +82,13 @@ public interface DestinationResolvingMessageRequestReplyOperations<D> extends Me @@ -82,13 +82,13 @@ public interface DestinationResolvingMessageRequestReplyOperations<D> extends Me
* Resolve the given destination name, convert the payload request Object
* to serialized form, possibly using a
* {@link org.springframework.messaging.converter.MessageConverter},
* wrap it as a message, apply the given post process, and send the resulting
* wrap it as a message, apply the given post-process, and send the resulting
* message to the resolved destination, then receive a reply and convert its
* body to the specified target class.
* @param destinationName the name of the target destination
* @param request the payload for the request message to send
* @param targetClass the target class to convert the payload of the reply to
* @param requestPostProcessor post process for the request message
* @param requestPostProcessor post-process for the request message
* @return the converted payload of the reply message, possibly {@code null} if
* the message could not be received, for example due to a timeout
*/
@ -100,14 +100,14 @@ public interface DestinationResolvingMessageRequestReplyOperations<D> extends Me @@ -100,14 +100,14 @@ public interface DestinationResolvingMessageRequestReplyOperations<D> extends Me
* Resolve the given destination name, convert the payload request Object
* to serialized form, possibly using a
* {@link org.springframework.messaging.converter.MessageConverter},
* wrap it as a message with the given headers, apply the given post process,
* wrap it as a message with the given headers, apply the given post-process,
* and send the resulting message to the resolved destination, then receive
* a reply and convert its body to the specified target class.
* @param destinationName the name of the target destination
* @param request the payload for the request message to send
* @param headers the headers for the request message to send
* @param targetClass the target class to convert the payload of the reply to
* @param requestPostProcessor post process for the request message
* @param requestPostProcessor post-process for the request message
* @return the converted payload of the reply message, possibly {@code null} if
* the message could not be received, for example due to a timeout
*/

8
spring-messaging/src/main/java/org/springframework/messaging/core/DestinationResolvingMessageSendingOperations.java

@ -68,11 +68,11 @@ public interface DestinationResolvingMessageSendingOperations<D> extends Message @@ -68,11 +68,11 @@ public interface DestinationResolvingMessageSendingOperations<D> extends Message
* Resolve the given destination name to a destination, convert the payload
* Object to serialized form, possibly using a
* {@link org.springframework.messaging.converter.MessageConverter},
* wrap it as a message, apply the given post processor, and send the resulting
* wrap it as a message, apply the given post-processor, and send the resulting
* message to the resolved destination.
* @param destinationName the destination name to resolve
* @param payload the Object to use as payload
* @param postProcessor the post processor to apply to the message
* @param postProcessor the post-processor to apply to the message
*/
<T> void convertAndSend(String destinationName, T payload, @Nullable MessagePostProcessor postProcessor)
throws MessagingException;
@ -81,12 +81,12 @@ public interface DestinationResolvingMessageSendingOperations<D> extends Message @@ -81,12 +81,12 @@ public interface DestinationResolvingMessageSendingOperations<D> extends Message
* Resolve the given destination name to a destination, convert the payload
* Object to serialized form, possibly using a
* {@link org.springframework.messaging.converter.MessageConverter},
* wrap it as a message with the given headers, apply the given post processor,
* wrap it as a message with the given headers, apply the given post-processor,
* and send the resulting message to the resolved destination.
* @param destinationName the destination name to resolve
* @param payload the Object to use as payload
* @param headers the headers for the message to send
* @param postProcessor the post processor to apply to the message
* @param postProcessor the post-processor to apply to the message
*/
<T> void convertAndSend(String destinationName, T payload, @Nullable Map<String, Object> headers,
@Nullable MessagePostProcessor postProcessor) throws MessagingException;

12
spring-messaging/src/main/java/org/springframework/messaging/core/MessageRequestReplyOperations.java

@ -99,12 +99,12 @@ public interface MessageRequestReplyOperations<D> { @@ -99,12 +99,12 @@ public interface MessageRequestReplyOperations<D> {
/**
* Convert the given request Object to serialized form, possibly using a
* {@link org.springframework.messaging.converter.MessageConverter},
* apply the given post processor and send the resulting {@link Message} to a
* apply the given post-processor and send the resulting {@link Message} to a
* default destination, receive the reply and convert its body of the given
* target class.
* @param request payload for the request message to send
* @param targetClass the target type to convert the payload of the reply to
* @param requestPostProcessor post process to apply to the request message
* @param requestPostProcessor post-process to apply to the request message
* @return the payload of the reply message, possibly {@code null} if the message
* could not be received, for example due to a timeout
*/
@ -116,13 +116,13 @@ public interface MessageRequestReplyOperations<D> { @@ -116,13 +116,13 @@ public interface MessageRequestReplyOperations<D> {
/**
* Convert the given request Object to serialized form, possibly using a
* {@link org.springframework.messaging.converter.MessageConverter},
* apply the given post processor and send the resulting {@link Message} to the
* apply the given post-processor and send the resulting {@link Message} to the
* given destination, receive the reply and convert its body of the given
* target class.
* @param destination the target destination
* @param request payload for the request message to send
* @param targetClass the target type to convert the payload of the reply to
* @param requestPostProcessor post process to apply to the request message
* @param requestPostProcessor post-process to apply to the request message
* @return the payload of the reply message, possibly {@code null} if the message
* could not be received, for example due to a timeout
*/
@ -133,13 +133,13 @@ public interface MessageRequestReplyOperations<D> { @@ -133,13 +133,13 @@ public interface MessageRequestReplyOperations<D> {
/**
* Convert the given request Object to serialized form, possibly using a
* {@link org.springframework.messaging.converter.MessageConverter},
* wrap it as a message with the given headers, apply the given post processor
* wrap it as a message with the given headers, apply the given post-processor
* and send the resulting {@link Message} to the specified destination, receive
* the reply and convert its body of the given target class.
* @param destination the target destination
* @param request payload for the request message to send
* @param targetClass the target type to convert the payload of the reply to
* @param requestPostProcessor post process to apply to the request message
* @param requestPostProcessor post-process to apply to the request message
* @return the payload of the reply message, possibly {@code null} if the message
* could not be received, for example due to a timeout
*/

16
spring-messaging/src/main/java/org/springframework/messaging/core/MessageSendingOperations.java

@ -71,38 +71,38 @@ public interface MessageSendingOperations<D> { @@ -71,38 +71,38 @@ public interface MessageSendingOperations<D> {
* @param payload the Object to use as payload
* @param headers the headers for the message to send
*/
void convertAndSend(D destination, Object payload, Map<String, Object> headers) throws MessagingException;
void convertAndSend(D destination, Object payload, @Nullable Map<String, Object> headers) throws MessagingException;
/**
* Convert the given Object to serialized form, possibly using a
* {@link org.springframework.messaging.converter.MessageConverter},
* wrap it as a message, apply the given post processor, and send
* wrap it as a message, apply the given post-processor, and send
* the resulting message to a default destination.
* @param payload the Object to use as payload
* @param postProcessor the post processor to apply to the message
* @param postProcessor the post-processor to apply to the message
*/
void convertAndSend(Object payload, @Nullable MessagePostProcessor postProcessor) throws MessagingException;
/**
* Convert the given Object to serialized form, possibly using a
* {@link org.springframework.messaging.converter.MessageConverter},
* wrap it as a message, apply the given post processor, and send
* wrap it as a message, apply the given post-processor, and send
* the resulting message to the given destination.
* @param destination the target destination
* @param payload the Object to use as payload
* @param postProcessor the post processor to apply to the message
* @param postProcessor the post-processor to apply to the message
*/
void convertAndSend(D destination, Object payload, MessagePostProcessor postProcessor) throws MessagingException;
void convertAndSend(D destination, Object payload, @Nullable MessagePostProcessor postProcessor) throws MessagingException;
/**
* Convert the given Object to serialized form, possibly using a
* {@link org.springframework.messaging.converter.MessageConverter},
* wrap it as a message with the given headers, apply the given post processor,
* wrap it as a message with the given headers, apply the given post-processor,
* and send the resulting message to the given destination.
* @param destination the target destination
* @param payload the Object to use as payload
* @param headers the headers for the message to send
* @param postProcessor the post processor to apply to the message
* @param postProcessor the post-processor to apply to the message
*/
void convertAndSend(D destination, Object payload, @Nullable Map<String, Object> headers,
@Nullable MessagePostProcessor postProcessor) throws MessagingException;

Loading…
Cancel
Save