@ProviderType
public interface Producer
Producer
is the super class of XMLMessageProducer
.
NOTE: Applications must cache this instance and close it only when it is no longer required.
Producer
interface offers the following methods to acquire message instances:
createBytesXMLMessage()
,createBytesMessage()
,createXMLContentMessage()
,createMapMessage()
,createStreamMessage()
,createTextMessage()
,1. An application must acquire a single message instance at a time, and must send the message after acquiring it. Multi-threaded applications using a producer must ensure synchronisation is enforced so that a thread cannot acquire a new message before an existing message in another thread is sent.
2. An application must not attempt to send a message
object multiple times. A new message instance should be acquired for this
purpose. If an attempt is made to send a message twice, an
InvalidOperationException
is thrown.
NOTE: Producer
is primarily
maintained for backwards compatibility with existing applications that use
the Messaging API for Java. It is recommended that new Java applications use
the session-independent messages. Applications that require more control over message creation and pooling should
use session-independent messages. There is no performance penalty for using
the session-independent message ownership model if messages are preallocated
and reused. See JCSMPFactory.createMessage(Class)
.
Modifier and Type | Method and Description |
---|---|
void |
close()
Closes the message producer.
|
BytesMessage |
createBytesMessage()
Applications use this method to create a
BytesMessage . |
BytesXMLMessage |
createBytesXMLMessage()
Applications use this method to create a
BytesXMLMessage . |
BytesXMLMessage |
createBytesXMLMessage(byte[] value)
Applications use this method to create a
BytesXMLMessage . |
SDTMap |
createMap()
Create maps for use as user
properties or as structured
payload . |
MapMessage |
createMapMessage()
Applications use this method to create a
MapMessage . |
SDTStream |
createStream()
Create streams for use as structured
payload . |
StreamMessage |
createStreamMessage()
Applications use this method to create a
StreamMessage . |
StreamXMLMessage |
createStreamXMLMessage()
Deprecated.
|
StreamXMLMessage |
createStreamXMLMessage(InputStream stream)
Deprecated.
|
TextMessage |
createTextMessage()
Applications use this method to create a
TextMessage . |
TextXMLMessage |
createTextXMLMessage()
Deprecated.
|
TextXMLMessage |
createTextXMLMessage(String text)
Deprecated.
|
XMLContentMessage |
createXMLContentMessage()
Applications use this method to create a
XMLContentMessage . |
JCSMPStreamingPublishEventHandler |
getStreamingCallbackHandler()
Deprecated.
|
boolean |
isClosed()
Checks if message producer is closed
|
JCSMPStreamingPublishEventHandler getStreamingCallbackHandler() throws JCSMPException
null
, otherwise.InvalidOperationException
- when called on a closed producer.JCSMPException
TextXMLMessage createTextXMLMessage() throws JCSMPException
TextXMLMessage
.
NOTE: Applications shall not cache the created object based on the assumption that the method returns a new object each time. The JCSMP implementation can reuse the same object by resetting its content.
TextXMLMessage
.InvalidOperationException
- when called on a closed producer.JCSMPException
TextXMLMessage createTextXMLMessage(String text) throws JCSMPException
TextXMLMessage
.
NOTE: Applications must not cache the created object based on the assumption that the method returns a new object each time. The JCSMP implementation can reuse the same object by resetting its content.
text
- The message content.TextXMLMessage
.InvalidOperationException
- when called on a closed producer.JCSMPException
BytesXMLMessage createBytesXMLMessage() throws JCSMPException
BytesXMLMessage
.
NOTE: Applications must not cache the created object based on the assumption that the method returns a new object each time. The JCSMP implementation can reuse the same object by resetting its content.
BytesXMLMessage
.InvalidOperationException
- when called on a closed producer.JCSMPException
BytesXMLMessage createBytesXMLMessage(byte[] value) throws JCSMPException
BytesXMLMessage
.
NOTE: Applications must not cache the created object based on the assumption that the method returns a new object each time. The JCSMP implementation can reuse the same object by resetting its content.
value
- The message content.BytesXMLMessage
.InvalidOperationException
- when called on a closed producer.JCSMPException
StreamXMLMessage createStreamXMLMessage() throws JCSMPException
StreamXMLMessage
.
NOTE: Applications must not cache the created object based on the assumption that the method returns a new object each time. The JCSMP implementation can reuse the same object by resetting its content.
StreamXMLMessage
.InvalidOperationException
- when called on a closed producer.JCSMPException
StreamXMLMessage createStreamXMLMessage(InputStream stream) throws IOException, JCSMPException
StreamXMLMessage
.
NOTE: Applications must not cache the created object based on the assumption that the method returns a new object each time. The JCSMP implementation can reuse the same object by resetting its content.
stream
- The InputStream
from which to read message content.StreamXMLMessage
.IOException
- If error reading from stream
.InvalidOperationException
- when called on a closed producer.JCSMPException
SDTMap createMap()
properties
or as structured
payload
. There
is nothing tying the returned map to the producer that created it. The
map can be used by any producer in any message.SDTStream createStream()
payload
. There is nothing tying the returned stream to the producer that
created it. The stream can be used by any producer in any message.BytesMessage createBytesMessage() throws JCSMPException
BytesMessage
.
NOTE: Applications must not cache the created object based on the assumption that the method returns a new object each time. The JCSMP implementation can reuse the same object by resetting its content.
InvalidOperationException
- when called on a closed producer.JCSMPException
XMLContentMessage createXMLContentMessage() throws JCSMPException
XMLContentMessage
.
NOTE: Applications must not cache the created object based on the assumption that the method returns a new object each time. The JCSMP implementation can reuse the same object by resetting its content.
InvalidOperationException
- when called on a closed producer.JCSMPException
MapMessage createMapMessage() throws JCSMPException
MapMessage
.
NOTE: Applications must not cache the created object based on the assumption that the method returns a new object each time. The JCSMP implementation can reuse the same object by resetting its content.
InvalidOperationException
- when called on a closed producer.JCSMPException
StreamMessage createStreamMessage() throws JCSMPException
StreamMessage
.
NOTE: Applications must not cache the created object based on the assumption that the method returns a new object each time. The JCSMP implementation can reuse the same object by resetting its content.
InvalidOperationException
- when called on a closed producer.JCSMPException
TextMessage createTextMessage() throws JCSMPException
TextMessage
.
NOTE: Applications must not cache the created object based on the assumption that the method returns a new object each time. The JCSMP implementation can reuse the same object by resetting its content.
InvalidOperationException
- when called on a closed producer.JCSMPException
void close()
boolean isClosed()
true
if message producer is closed, false
otherwiseCopyright 2004-2024 Solace Corporation. All rights reserved.