public class JCSMPXMLMessageProducer extends Object implements XMLMessageProducer, CSMPPublisherChannelObserver, Closeable, JCSMPStreamingPublishCorrelatingEventHandler
JCSMPXMLMessageProducer| Modifier and Type | Field and Description |
|---|---|
CSMPPublisherChannel |
channel |
NULL_FLOWID, NULL_PUBLISHERID| Constructor and Description |
|---|
JCSMPXMLMessageProducer(JCSMPBasicSession session,
CSMPPublisherChannel channel,
JCSMPStreamingPublishEventHandler callback,
JCSMPProducerEventHandler eventHandler,
PubFlowManager pubFlowMgr,
ProducerFlowProperties fprop,
JCSMPBasicSession.InternalBindProperties internalBindProp) |
| Modifier and Type | Method and Description |
|---|---|
void |
buildDispatchProducerList(List<JCSMPXMLMessageProducer> toNotify) |
void |
close()
Closes the message producer.
|
void |
closeImpl(boolean reconn) |
BytesMessage |
createBytesMessage()
Applications use this method to create a
BytesMessage. |
BytesXMLMessage |
createBytesXMLMessage()
reuse the message object
|
BytesXMLMessage |
createBytesXMLMessage(byte[] value)
reuse the message object
|
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()
reuse the message object
|
StreamXMLMessage |
createStreamXMLMessage(InputStream stream)
reuse the message object
|
TextMessage |
createTextMessage()
Applications use this method to create a
TextMessage. |
TextXMLMessage |
createTextXMLMessage()
reuse the message object
|
TextXMLMessage |
createTextXMLMessage(String text)
reuse the message object
|
XMLContentMessage |
createXMLContentMessage()
Applications use this method to create a
XMLContentMessage. |
String |
getDbgFlowName() |
ReentrantLock |
getLock() |
int |
getPriority() |
JCSMPProducerEventHandler |
getProducerEventHandler() |
PubADManager |
getPubADManager() |
JCSMPSessionStats |
getSessionStats() |
JCSMPStreamingPublishEventHandler |
getStreamEventHandler() |
JCSMPStreamingPublishEventHandler |
getStreamingCallbackHandler() |
JCSMPStreamingPublishEventHandler |
getStreamingCallbackHandlerInternal() |
BaseTransactedSessionImpl |
getTransactedSession() |
boolean |
handleAckAD(long msgID,
JCSMPErrorResponseException err) |
void |
handleAsyncCloseFlow(WireMessage message) |
boolean |
handleCommitResponse(long msgID,
JCSMPErrorResponseException err) |
void |
handleError(String messageID,
JCSMPException cause,
long timestamp) |
void |
handleErrorEx(Object key,
JCSMPException cause,
long timestamp)
This method is invoked during streaming publishing if there is an error
in reading the response, or if a non-OK response is read.
|
void |
handleException(MsgIdInfo msgInfo,
JCSMPException e,
long producerId,
boolean forceNotifyIfClosed)
This method is called when exception happened during read and write
operation.
|
void |
handleException(MsgIdInfo msgId,
JCSMPException e,
long producerId,
boolean forceNotifyIfClosed,
List<JCSMPXMLMessageProducer> toNotify) |
void |
handlePubMsgResponse(WireMessage resp) |
void |
handlePubMsgSent(JCSMPXMLMessage xmlMsg,
JCSMPXMLMessageProducer prod) |
void |
handleRetransmitADMsgs(Runnable callbackOnComplete,
boolean forceAllowEnqueue) |
boolean |
isDirectPermitted() |
boolean |
isOpenInternal() |
boolean |
isTransacted() |
void |
notifyReconnected() |
void |
open() |
void |
responseReceived(String messageID) |
void |
responseReceivedEx(Object key)
This method is invoked whenever an OK response is received.
|
void |
resume(int tickets)
There can be several tasks to run on reconnect / transaction resyncs,
etc.
|
void |
send(XMLMessage message)
Sends a message.
|
void |
send(XMLMessage message,
Destination destination)
Sends a message to a destination, such as a Queue or Topic.
|
void |
sendImpl(JCSMPXMLMessage[] messages,
int offset,
int length,
com.solacesystems.jcsmp.impl.JCSMPXMLMessageProducer.PubMsgInfo[] pubMsgInfos) |
void |
sendMsgOnce(JCSMPXMLMessage[] messages,
int offset,
int length,
boolean newMsgIdRequired,
boolean newMsg,
boolean notify,
boolean allowBlock,
Integer expectedChannelTag,
boolean dropOnWouldBlock,
boolean allowStateSub,
com.solacesystems.jcsmp.impl.JCSMPXMLMessageProducer.PubMsgInfo[] pubMsgInfos) |
int |
sendMultiple(JCSMPSendMultipleEntry[] entries,
int offset,
int length,
int sendFlags)
Sends a batch of messages.
|
void |
sendReply(XMLMessage requestMessage,
XMLMessage replyMessage)
Convenience function for sending a reply message.
|
void |
setDirectPermitted(boolean directPermitted) |
void |
setPriority(int prior) |
void |
setStreamingCallbackHandler(JCSMPStreamingPublishEventHandler callback)
By setting a callback handler, any
send returns
immediately without confirming the successful delivery of the message. |
void |
suspend()
There can be several tasks to run on reconnect / transaction resyncs,
etc.
|
void |
waitOnSpinlockSendBlocked() |
void |
waitOnSpinlockSendBlockedWithThrow() |
public CSMPPublisherChannel channel
public JCSMPXMLMessageProducer(JCSMPBasicSession session, CSMPPublisherChannel channel, JCSMPStreamingPublishEventHandler callback, JCSMPProducerEventHandler eventHandler, PubFlowManager pubFlowMgr, ProducerFlowProperties fprop, JCSMPBasicSession.InternalBindProperties internalBindProp)
public ReentrantLock getLock()
public PubADManager getPubADManager()
public JCSMPStreamingPublishEventHandler getStreamEventHandler()
public JCSMPProducerEventHandler getProducerEventHandler()
public boolean isOpenInternal()
public void open()
throws JCSMPException
JCSMPExceptionpublic void close()
Producerclose in interface Closeableclose in interface ProducerProducer.close()public void closeImpl(boolean reconn)
public void send(XMLMessage message, Destination destination) throws JCSMPException
XMLMessageProducermessage.getMessageId()
gives the message id assigned to the message.send in interface XMLMessageProducermessage - Message to send.destination - The destination to publish to.JCSMPException - on failure.public int sendMultiple(JCSMPSendMultipleEntry[] entries, int offset, int length, int sendFlags) throws JCSMPException
XMLMessageProducerJCSMPSendMultipleEntry element in entries is a
{XMLMessage, Destination} tuple, allowing this method to send messages to
individual destinations. JCSMP attempts to write all messages to the
network at once, returning once the write is complete.
Guaranteed messages can be published with this method; they are published
serially as space becomes available in the acknowledgement window.
This method returns the number of messages written, but current
implementations can choose to block until all messages have been
published.
Restrictions:
DeliveryMode set.JCSMPFactory).XMLMessageProducer must be operating in streaming
publish mode (a streaming callback handler must be specified).
entries.
sendMultiple in interface XMLMessageProducerentries - An array of elements to publish.offset - The offset into entries.length - The number of entries, starting at offset, to attempt
to publish.sendFlags - Flags controlling the send operation, present for
extensibility, must be 0 in this release.JCSMPException - When sending a message to the network failed unrecoverably.JCSMPFactory.createMessage(Class)public void sendReply(XMLMessage requestMessage, XMLMessage replyMessage) throws JCSMPException
XMLMessageProducer
Automatically copies requestMessage's CorrelationId to
replyMessage and sets the reply attribute on the latter.
replyMessage is sent to the Destination returned by
requestMessage..getReplyTo()
sendReply in interface XMLMessageProducerrequestMessage - The request message that is being replied to.replyMessage - The reply message to publish.JCSMPException - When sending a message to the network failed unrecoverably.send() for error response subcodes.public void send(XMLMessage message) throws JCSMPException
XMLMessageProducerA new message ID is assigned to the message by JCSMP automatically every time this method is called.
If using producer-acquired messages, the message becomes read-only and cannot be modified or resent by the application.
send in interface XMLMessageProducermessage - The message to be sent.InvalidOperationException - when called on a closed producer.JCSMPException - upon failure.XMLMessageProducer.send(com.solacesystems.jcsmp.XMLMessage)public void sendImpl(JCSMPXMLMessage[] messages, int offset, int length, com.solacesystems.jcsmp.impl.JCSMPXMLMessageProducer.PubMsgInfo[] pubMsgInfos) throws JCSMPException
JCSMPExceptionpublic void sendMsgOnce(JCSMPXMLMessage[] messages, int offset, int length, boolean newMsgIdRequired, boolean newMsg, boolean notify, boolean allowBlock, Integer expectedChannelTag, boolean dropOnWouldBlock, boolean allowStateSub, com.solacesystems.jcsmp.impl.JCSMPXMLMessageProducer.PubMsgInfo[] pubMsgInfos) throws JCSMPException
JCSMPExceptionpublic boolean handleAckAD(long msgID,
JCSMPErrorResponseException err)
throws JCSMPException
JCSMPExceptionpublic boolean handleCommitResponse(long msgID,
JCSMPErrorResponseException err)
throws JCSMPException
JCSMPExceptionpublic void suspend()
public void resume(int tickets)
public void waitOnSpinlockSendBlockedWithThrow()
throws JCSMPInterruptedException
JCSMPInterruptedExceptionpublic void waitOnSpinlockSendBlocked()
public void handleRetransmitADMsgs(Runnable callbackOnComplete, boolean forceAllowEnqueue)
public JCSMPStreamingPublishEventHandler getStreamingCallbackHandler() throws JCSMPException
getStreamingCallbackHandler in interface Producernull, otherwise.InvalidOperationException - when called on a closed producer.JCSMPExceptionpublic JCSMPStreamingPublishEventHandler getStreamingCallbackHandlerInternal()
public BaseTransactedSessionImpl getTransactedSession()
public boolean isTransacted()
public void setStreamingCallbackHandler(JCSMPStreamingPublishEventHandler callback) throws JCSMPException
XMLMessageProducersend returns
immediately without confirming the successful delivery of the message.
Applications receive the response of the send
asynchronously through the callback.setStreamingCallbackHandler in interface XMLMessageProducercallback - The callback handler to be set.InvalidOperationException - When called on a closed producer.JCSMPExceptionpublic JCSMPSessionStats getSessionStats()
public TextXMLMessage createTextXMLMessage() throws JCSMPException
createTextXMLMessage in interface ProducerTextXMLMessage.InvalidOperationException - when called on a closed producer.JCSMPExceptionpublic TextXMLMessage createTextXMLMessage(String text) throws JCSMPException
createTextXMLMessage in interface Producertext - The message content.TextXMLMessage.InvalidOperationException - when called on a closed producer.JCSMPExceptionpublic BytesXMLMessage createBytesXMLMessage() throws JCSMPException
createBytesXMLMessage in interface ProducerBytesXMLMessage.InvalidOperationException - when called on a closed producer.JCSMPExceptionpublic BytesXMLMessage createBytesXMLMessage(byte[] value) throws JCSMPException
createBytesXMLMessage in interface Producervalue - The message content.BytesXMLMessage.InvalidOperationException - when called on a closed producer.JCSMPExceptionpublic StreamXMLMessage createStreamXMLMessage() throws JCSMPException
createStreamXMLMessage in interface ProducerStreamXMLMessage.InvalidOperationException - when called on a closed producer.JCSMPExceptionpublic StreamXMLMessage createStreamXMLMessage(InputStream stream) throws IOException, JCSMPException
createStreamXMLMessage in interface Producerstream - The InputStream from which to read message content.StreamXMLMessage.JCSMPException - on errorIOException - If error reading from stream.public SDTMap createMap()
Producerproperties 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.public SDTStream createStream()
Producerpayload. There is nothing tying the returned stream to the producer that
created it. The stream can be used by any producer in any message.createStream in interface Producerpublic BytesMessage createBytesMessage() throws JCSMPException
ProducerBytesMessage.
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.
createBytesMessage in interface ProducerInvalidOperationException - when called on a closed producer.JCSMPExceptionpublic XMLContentMessage createXMLContentMessage() throws JCSMPException
ProducerXMLContentMessage.
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.
createXMLContentMessage in interface ProducerInvalidOperationException - when called on a closed producer.JCSMPExceptionpublic MapMessage createMapMessage() throws JCSMPException
ProducerMapMessage.
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.
createMapMessage in interface ProducerInvalidOperationException - when called on a closed producer.JCSMPExceptionpublic StreamMessage createStreamMessage() throws JCSMPException
ProducerStreamMessage.
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.
createStreamMessage in interface ProducerInvalidOperationException - when called on a closed producer.JCSMPExceptionpublic TextMessage createTextMessage() throws JCSMPException
ProducerTextMessage.
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.
createTextMessage in interface ProducerInvalidOperationException - when called on a closed producer.JCSMPExceptionpublic void buildDispatchProducerList(List<JCSMPXMLMessageProducer> toNotify)
buildDispatchProducerList in interface CSMPPublisherChannelObserverpublic void handleException(MsgIdInfo msgId, JCSMPException e, long producerId, boolean forceNotifyIfClosed, List<JCSMPXMLMessageProducer> toNotify)
handleException in interface CSMPPublisherChannelObserverpublic void handleException(MsgIdInfo msgInfo, JCSMPException e, long producerId, boolean forceNotifyIfClosed)
public void handlePubMsgResponse(WireMessage resp)
handlePubMsgResponse in interface CSMPPublisherChannelObserverpublic void handleAsyncCloseFlow(WireMessage message)
handleAsyncCloseFlow in interface CSMPPublisherChannelObserverpublic void notifyReconnected()
notifyReconnected in interface CSMPPublisherChannelObserverpublic void handlePubMsgSent(JCSMPXMLMessage xmlMsg, JCSMPXMLMessageProducer prod)
handlePubMsgSent in interface CSMPPublisherChannelObserverpublic boolean isDirectPermitted()
public void setDirectPermitted(boolean directPermitted)
public String getDbgFlowName()
public void handleError(String messageID, JCSMPException cause, long timestamp)
handleError in interface JCSMPStreamingPublishCorrelatingEventHandlerhandleError in interface JCSMPStreamingPublishEventHandlermessageID - The message ID of the message with which the error condition
is associated.cause - The error condition.timestamp - The time of the error given by
System.currentTimeMillis().public void responseReceived(String messageID)
responseReceived in interface JCSMPStreamingPublishCorrelatingEventHandlerresponseReceived in interface JCSMPStreamingPublishEventHandlerpublic void responseReceivedEx(Object key)
JCSMPStreamingPublishCorrelatingEventHandler
When publishing PERSISTENT and
NON_PERSISTENT messages, the
message's correlation key is passed as an argument to this callback when
an acknowledgement is received.
Note: DIRECT messages do not receive
acknowledgements. Therefore, this method is not invoked for Direct messages.
responseReceivedEx in interface JCSMPStreamingPublishCorrelatingEventHandlerkey - The correlation key of the message being acknowledged.XMLMessage.setCorrelationKey(Object)public void handleErrorEx(Object key, JCSMPException cause, long timestamp)
JCSMPStreamingPublishCorrelatingEventHandlerNote: Handler processing should be kept to a minimum as this blocks the thread from which the error originated.
Note: Direct messages are not buffered by the publishing API, and
error responses from the appliance cannot be correlated to published Direct
messages. As a result, when a Direct message is rejected by an error
response, the key parameter to this callback is
null.
JCSMPErrorResponseException. The following subcodes can be
present to provide further information about why the message was
rejected:
JCSMPErrorResponseSubcodeEx.MESSAGE_TOO_LARGEJCSMPErrorResponseSubcodeEx.QUEUE_NOT_FOUNDJCSMPErrorResponseSubcodeEx.INVALID_TOPIC_SYNTAXJCSMPErrorResponseSubcodeEx.XML_PARSE_ERRORJCSMPErrorResponseSubcodeEx.PUBLISH_ACL_DENIEDJCSMPErrorResponseSubcodeEx.PUBLISH_NO_VALID_CLOSED_USER_GROUPJCSMPErrorResponseSubcodeEx.MAX_MESSAGE_USAGE_EXCEEDEDJCSMPErrorResponseSubcodeEx.SPOOL_OVER_QUOTAhandleErrorEx in interface JCSMPStreamingPublishCorrelatingEventHandlerkey - The correlation key of the message with which the error
condition is associated.cause - The error condition.timestamp - The time of the error given by
System.currentTimeMillis().XMLMessage.setCorrelationKey(Object)public int getPriority()
public void setPriority(int prior)
Copyright 2004-2021 Solace Corporation. All rights reserved.