public class MessageProcessor extends Object
ConnectionContextFactory to create contexts (which create destinations, sessions, and connections for
you) that you then use to pass to the listen and send methods in this class.| Modifier and Type | Field and Description |
|---|---|
static String |
HEADER_BASIC_MESSAGE_CLASS |
| Constructor and Description |
|---|
MessageProcessor() |
| Modifier and Type | Method and Description |
|---|---|
protected javax.jms.Message |
createMessage(ConnectionContext context,
BasicMessage basicMessage)
Same as
createMessage(ConnectionContext, BasicMessage, Map) with null headers. |
protected javax.jms.Message |
createMessage(ConnectionContext context,
BasicMessage basicMessage,
Map<String,String> headers)
Creates a text message that can be send via a producer that contains the given BasicMessage's JSON encoded data.
|
protected javax.jms.Message |
createMessageWithBinaryData(ConnectionContext context,
BasicMessage basicMessage,
InputStream inputStream)
Same as
createMessage(ConnectionContext, BasicMessage, Map) with null headers. |
protected javax.jms.Message |
createMessageWithBinaryData(ConnectionContext context,
BasicMessage basicMessage,
InputStream inputStream,
Map<String,String> headers)
Creates a blob message that can be send via a producer that contains the given BasicMessage's JSON encoded data
along with binary data.
|
<T extends BasicMessage> |
listen(ConsumerConnectionContext context,
AbstractBasicMessageListener<T> listener)
Listens for messages.
|
MessageId |
send(ProducerConnectionContext context,
BasicMessage basicMessage)
Same as
send(ProducerConnectionContext, BasicMessage, Map) with null headers. |
MessageId |
send(ProducerConnectionContext context,
BasicMessage basicMessage,
Map<String,String> headers)
Send the given message to its destinations across the message bus.
|
<T extends BasicMessage> |
send(ProducerConnectionContext context,
BasicMessageWithExtraData<T> message,
Map<String,String> headers)
If the given
message.getBinaryData() is not null delegates to
sendWithBinaryData(ProducerConnectionContext, BasicMessage, InputStream, Map) otherwise delegates to
send(ProducerConnectionContext, BasicMessageWithExtraData, Map) |
<T extends BasicMessage> |
sendAndListen(ProducerConnectionContext context,
BasicMessage basicMessage,
BasicMessageListener<T> responseListener)
Same as
sendAndListen(ProducerConnectionContext, BasicMessage, BasicMessageListener, Map) with
null headers. |
<T extends BasicMessage> |
sendAndListen(ProducerConnectionContext context,
BasicMessage basicMessage,
BasicMessageListener<T> responseListener,
Map<String,String> headers)
Send the given message to its destinations across the message bus and any response sent back will be passed to
the given listener.
|
MessageId |
sendWithBinaryData(ProducerConnectionContext context,
BasicMessage basicMessage,
File file)
Same as
sendWithBinaryData(ProducerConnectionContext, BasicMessage, File, Map) with null
headers. |
MessageId |
sendWithBinaryData(ProducerConnectionContext context,
BasicMessage basicMessage,
File file,
Map<String,String> headers)
Same as
sendWithBinaryData(ProducerConnectionContext, BasicMessage, InputStream, Map) with the input
stream being a stream to read the file. |
MessageId |
sendWithBinaryData(ProducerConnectionContext context,
BasicMessage basicMessage,
InputStream inputStream)
Same as
sendWithBinaryData(ProducerConnectionContext, BasicMessage, InputStream, Map) with
null headers. |
MessageId |
sendWithBinaryData(ProducerConnectionContext context,
BasicMessage basicMessage,
InputStream inputStream,
Map<String,String> headers)
Send the given message along with the stream of binary data to its destinations across the message bus.
|
protected void |
setHeaders(BasicMessage basicMessage,
Map<String,String> headers,
javax.jms.Message destination)
First sets the
HEADER_BASIC_MESSAGE_CLASS string property of destination to
basicMessage.getClass().getName(), then copies all headers from basicMessage.getHeaders() to
destination using Message.setStringProperty(String, String) and then does the same thing with the
supplied headers. |
public static final String HEADER_BASIC_MESSAGE_CLASS
public <T extends BasicMessage> void listen(ConsumerConnectionContext context, AbstractBasicMessageListener<T> listener) throws javax.jms.JMSException
context - information that determines where to listenlistener - the listener that processes the incoming messagesjavax.jms.JMSException - any errorConnectionContextFactory.createConsumerConnectionContext(Endpoint)public MessageId send(ProducerConnectionContext context, BasicMessage basicMessage) throws javax.jms.JMSException
send(ProducerConnectionContext, BasicMessage, Map) with null headers.javax.jms.JMSExceptionpublic MessageId send(ProducerConnectionContext context, BasicMessage basicMessage, Map<String,String> headers) throws javax.jms.JMSException
context - information that determines where the message is sentbasicMessage - the message to send with optional headers includedheaders - headers for the JMS transport that will override same-named headers in the basic messagejavax.jms.JMSException - any errorConnectionContextFactory.createProducerConnectionContext(Endpoint)public MessageId sendWithBinaryData(ProducerConnectionContext context, BasicMessage basicMessage, InputStream inputStream) throws javax.jms.JMSException
sendWithBinaryData(ProducerConnectionContext, BasicMessage, InputStream, Map) with
null headers.javax.jms.JMSExceptionpublic MessageId sendWithBinaryData(ProducerConnectionContext context, BasicMessage basicMessage, File file) throws javax.jms.JMSException, FileNotFoundException
sendWithBinaryData(ProducerConnectionContext, BasicMessage, File, Map) with null
headers.FileNotFoundException - if the file does not existjavax.jms.JMSExceptionpublic MessageId sendWithBinaryData(ProducerConnectionContext context, BasicMessage basicMessage, File file, Map<String,String> headers) throws javax.jms.JMSException, FileNotFoundException
sendWithBinaryData(ProducerConnectionContext, BasicMessage, InputStream, Map) with the input
stream being a stream to read the file.FileNotFoundException - if the file does not existjavax.jms.JMSExceptionpublic <T extends BasicMessage> MessageId send(ProducerConnectionContext context, BasicMessageWithExtraData<T> message, Map<String,String> headers) throws javax.jms.JMSException
message.getBinaryData() is not null delegates to
sendWithBinaryData(ProducerConnectionContext, BasicMessage, InputStream, Map) otherwise delegates to
send(ProducerConnectionContext, BasicMessageWithExtraData, Map)context - information that determines where the message is sentmessage - the message to sendheaders - headers for the JMS transport that will override same-named headers in the basic messagejavax.jms.JMSException - any errorpublic MessageId sendWithBinaryData(ProducerConnectionContext context, BasicMessage basicMessage, InputStream inputStream, Map<String,String> headers) throws javax.jms.JMSException
context - information that determines where the message is sentbasicMessage - the message to send with optional headers includedinputStream - binary data that will be sent with the messageheaders - headers for the JMS transport that will override same-named headers in the basic messagejavax.jms.JMSException - any errorConnectionContextFactory.createProducerConnectionContext(Endpoint)public <T extends BasicMessage> RPCConnectionContext sendAndListen(ProducerConnectionContext context, BasicMessage basicMessage, BasicMessageListener<T> responseListener) throws javax.jms.JMSException
sendAndListen(ProducerConnectionContext, BasicMessage, BasicMessageListener, Map) with
null headers.javax.jms.JMSExceptionpublic <T extends BasicMessage> RPCConnectionContext sendAndListen(ProducerConnectionContext context, BasicMessage basicMessage, BasicMessageListener<T> responseListener, Map<String,String> headers) throws javax.jms.JMSException
#sendRPC and use its returned Future to wait for the response, rather
than having to supply your own response listener.context - information that determines where the message is sentbasicMessage - the request message to send with optional headers includedresponseListener - The listener that will process the response of the request. This listener should close
its associated consumer when appropriate.headers - headers for the JMS transport that will override same-named headers in the basic messagejavax.jms.JMSException - any errorConnectionContextFactory.createProducerConnectionContext(Endpoint)protected javax.jms.Message createMessage(ConnectionContext context, BasicMessage basicMessage) throws javax.jms.JMSException
createMessage(ConnectionContext, BasicMessage, Map) with null headers.javax.jms.JMSExceptionprotected javax.jms.Message createMessage(ConnectionContext context, BasicMessage basicMessage, Map<String,String> headers) throws javax.jms.JMSException
context - the context whose session is used to create the messagebasicMessage - contains the data that will be JSON-encoded and encapsulated in the created message, with
optional headers includedheaders - headers for the Message that will override same-named headers in the basic messagejavax.jms.JMSException - any errorNullPointerException - if the context is null or the context's session is nullprotected void setHeaders(BasicMessage basicMessage, Map<String,String> headers, javax.jms.Message destination) throws javax.jms.JMSException
HEADER_BASIC_MESSAGE_CLASS string property of destination to
basicMessage.getClass().getName(), then copies all headers from basicMessage.getHeaders() to
destination using Message.setStringProperty(String, String) and then does the same thing with the
supplied headers.basicMessage - the BasicMessage to copy headers fromheaders - the headers to copy to destinationdestination - the Message to copy the headers tojavax.jms.JMSExceptionprotected javax.jms.Message createMessageWithBinaryData(ConnectionContext context, BasicMessage basicMessage, InputStream inputStream) throws javax.jms.JMSException
createMessage(ConnectionContext, BasicMessage, Map) with null headers.javax.jms.JMSExceptionprotected javax.jms.Message createMessageWithBinaryData(ConnectionContext context, BasicMessage basicMessage, InputStream inputStream, Map<String,String> headers) throws javax.jms.JMSException
context - the context whose session is used to create the messagebasicMessage - contains the data that will be JSON-encoded and encapsulated in the created message, with
optional headers includedinputStream - binary data that will be sent with the messageheaders - headers for the Message that will override same-named headers in the basic messagejavax.jms.JMSException - any errorNullPointerException - if the context is null or the context's session is nullCopyright © 2015–2016 Red Hat, Inc.. All rights reserved.