public class MPublisher extends MEventSource
MPublisher
is a reusable component for publishing messages to
TIBCO Rendezvous or TIBCO Enterprise for JMS using a specified destination name.
Adapters can interact directly with TIBCO Rendezvous or TIBCO Enterprise for JMS if source and destination applications are of the same type.
The publisher either publishes data inMTree
or MData
format. The application
is responsible for building the MTree
or MData
based on the input data.
is responsible for building the MTree
or MData
based on the input data.m_handlers, m_listeners
m_registry
Constructor and Description |
---|
MPublisher(MApp app,
java.lang.String name,
MRvSession session,
int protocol,
java.lang.String subject,
boolean assignMsgGUID)
Constructor for creating
MPublisher instances which takes in a MRvSession object. |
MPublisher(MApp app,
java.lang.String name,
java.lang.String sessionName,
int protocol,
java.lang.String subject,
boolean assignMsgGUID)
Constructor for creating
MPublisher instances which take in a MRvSession name. |
MPublisher(MComponentRegistry registry,
java.lang.String name,
MEndpointSpec endpointSpec)
Constructor for creating
MPublisher instances which use either a MRvSession or a MJmsSession
The name of the session is specified in the endpointSpec. |
MPublisher(MComponentRegistry registry,
java.lang.String name,
MJmsEndpointSpec endpointSpec,
java.lang.Object destination)
Note: Unsupported, for MJmsData.getReplySender()
|
Modifier and Type | Method and Description |
---|---|
void |
addClassName(java.lang.String p_className) |
void |
addTPluginName(java.lang.String sTPluginName) |
void |
assignMsgGUID(boolean assignGUID)
Deprecated.
as of TIBCO Adapter SDK 5.0.0.
|
void |
disableJmsMessageId(boolean bShouldDisable)
Set the message ID for JMS message.
|
boolean |
getAssignMsgGUID() |
java.util.Enumeration |
getClassNames()
Retrieve the list of class names associated with this publisher.
|
int |
getDeliveryMode()
Return the delivery mode of this publisher.
|
java.lang.String |
getDestinationName()
Return the destination name of this publisher.
|
MEndpointSpec |
getEndpointSpec() |
int |
getMessageFormat()
Return the message format this publisher uses to send messages on the transport.
|
MRvSession |
getMRvSession()
Deprecated.
as of TIBCO Adapter SDK 5.0.0.
|
long |
getNumMessagesPublished() |
int |
getProtocol()
Deprecated.
as of TIBCO Adapter SDK 5.0.0.
|
java.lang.String |
getReplyDestinationName()
Return the reply destination name associated with this publisher.
|
java.lang.String |
getReplySubject()
Deprecated.
as of TIBCO Adapter SDK 5.0.0.
|
long |
getSequenceNumber()
Retrieve the RVCM sequence number for the last message published.
|
MSession |
getSession()
Return the session associated with this publisher.
|
java.lang.String |
getSubjectName()
Deprecated.
as of TIBCO Adapter SDK 5.0.0.
|
void |
preRegisterListener(java.lang.String listenerName)
Preregister an anticipated listener on a TIBCO Rendezvous transport.
|
void |
send(MData message)
Publish a message.
|
void |
send(MTree message)
Publish a message.
|
MSubscriber |
sendWithReply(MData message,
MEventListener listener)
Publish a message.
|
MSubscriber |
sendWithReply(MData message,
MEventListener listener,
int timeout)
Publish a message.
|
MSubscriber |
sendWithReply(MTree message,
MEventListener listener)
Publish a message.
|
MSubscriber |
sendWithReply(MTree message,
MEventListener listener,
int timeout)
Publish a message.
|
void |
sendWithReply(MTree message,
MSubscriber subscriber) |
MTree |
sendWithSyncReply(MData message,
long timeout)
Publish with a synchronous reply.
|
MTree |
sendWithSyncReply(MTree message) |
MTree |
sendWithSyncReply(MTree message,
long timeout)
Publish with a synchronous reply.
|
void |
setCmTimeLimit(int p_timeLimit) |
void |
setDestinationName(java.lang.String subject)
Set the destination name to which this
MPublisher sends messages. |
void |
setJmsCorrelationId(java.lang.String correlationId)
Set the correlation ID for JMS message.
|
void |
setJmsPriority(int priority)
Set the priority for JMS message.
|
void |
setReplyDestinationName(java.lang.String replyDestinationName)
Set the reply destination name for this publisher.
|
void |
setReplySubject(java.lang.String replySubject)
Deprecated.
as of TIBCO Adapter SDK 5.0.0.
|
void |
setSubjectName(java.lang.String subject)
Deprecated.
as of TIBCO Adapter SDK 5.0.0.
|
void |
unRegisterListener(java.lang.String listenerName)
For RV, unregister a specific TIBCO Rendezvous certified listener and frees associated storage in the sending sessions ledger.
|
void |
validateMessage(boolean doValidate)
Deprecated.
as of TIBCO Adapter SDK 5.0.0.
|
addListener, getListeners, hasListeners, notify, removeListener
activate, deactivate, getComponentRegistry, getName, getStatus, isActivated, remove
public MPublisher(MComponentRegistry registry, java.lang.String name, MEndpointSpec endpointSpec) throws MException
MPublisher
instances which use either a MRvSession
or a MJmsSession
The name of the session is specified in the endpointSpec.registry
- Component registry that holds this publisher.name
- Name of this publisher instance (which is unique)endpointSpec
- EndpointSpec used by this publisher. See MEndpointSpec
.MException
- when any of the values in the endpoint specification is invalid.public MPublisher(MApp app, java.lang.String name, java.lang.String sessionName, int protocol, java.lang.String subject, boolean assignMsgGUID) throws MException
MPublisher
instances which take in a MRvSession
name.
NOTE: This constructor should be used only for TIBCO Rendezvous transport.app
- Application manager for which this publisher is being created.name
- Name of this publisher instance (which is unique).sessionName
- Name of the TIBCO Rendezvous session in which to create this MPublisher
.protocol
- Protocol with which this publisher communicates: M_RV
, or
M_RVCM
. If this protocol does not match the current
session, an error results. See MCommProtocol
.subject
- This subject name is used for sending messages to TIBCO Rendezvous.assignMsgGUID
- If the value of this parameter is true, the SDK assigns a unique ID (GUID)
to the message published by this publisher.MInvalidInputException
- when the protocol parameter is invalid. For example,
if the publisher is an RVCMQ publisher or if a parameter is used that is not part of MCommProtocol
.MException
public MPublisher(MApp app, java.lang.String name, MRvSession session, int protocol, java.lang.String subject, boolean assignMsgGUID) throws MException
MPublisher
instances which takes in a MRvSession
object.
NOTE: This constructor should be used only for TIBCO Rendezvous transport.app
- Application manager for which this publisher is being created.name
- Name of this publisher instance (which is unique).session
- Session in which to create this MPublisher
.protocol
- Protocol with which this publisher communicates: M_RV
, or
M_RVCM
. If this protocol does not match the current
session, an error results. See MCommProtocol
.subject
- This subject name is used for sending messages to TIBCO Rendezvous.assignMsgGUID
- If the value of this parameter is true, the SDK assigns a unique ID (GUID)
to the message published by this publisher.MInvalidInputException
- when the protocol parameter is invalid. For example,
if the publisher is an RVCMQ publisher or if a parameter is used that is not part of MCommProtocol
.MException
public MPublisher(MComponentRegistry registry, java.lang.String name, MJmsEndpointSpec endpointSpec, java.lang.Object destination) throws MException
MException
public void send(MTree message) throws MException
MTree
format.
If the message format of the MTree
does not correspond to the
message format of this publisher, the Adapter SDK attempts to convert the MTree
to the correct format. You should not pass an MTree
publisher that has a different
format because it degrades performance.
message
- Message to be published.MException
- under these circumstances:
public void send(MData message) throws MException
MData
format.
The following sublcasses of MData
can be used for publishing:
message
- Message to be published.MException
- under these circumstances:
public MSubscriber sendWithReply(MTree message, MEventListener listener) throws MException
MTree
format. When the reply is sent, the SDK informs the listener specified
by the listener argument.
If the message format of the MTree
does not correspond to the
message format of this publisher, the Adapter SDK attempts to convert the MTree
to the correct format. You should not pass an MTree
publisher that has a different
format because it degrades performance.
The SDK serializes the MTree
so its format is suitable for network transmissions.
NOTE: This method creates either an inbox or a temporary topic or a temporary queue and its associated subscriber and
supersedes any reply subject set by the user. If you want to set a reply destination and broadcast replies to other subscribers,
use the methods setReplyDestinationName(String)
and send(MTree)
instead.
If you use this method, the reply is sent point to point.
To free the resources, call MSubscriber.deactivate()
on
the subscriber object returned by this
method, followed by a call to System.gc()
. This call is necessary because at high data rates the
JRE is never idle enough for the garbage collector to run.
Do not use this method from within a callback. If it causes a timeout, you might loose messages.
message
- Message to publish.listener
- MEventListener
that will receive the reply.MException
- on the following condition:
send(MTree)
public MSubscriber sendWithReply(MData message, MEventListener listener) throws MException
MData
format. When the reply is sent, the SDK informs the listener specified
by the listener argument.
The SDK serializes the MData
so its format is suitable for network transmissions).
NOTE: This method creates either an inbox or a temporary topic or a temporary queue and its associated subscriber and
supersedes any reply subject set by the user. If you want to set a reply destination and broadcast replies to other subscribers,
use the methods setReplyDestinationName(String)
and send(MData)
instead.
If you use this method, the reply is sent point to point.
To free the resources, call MSubscriber.deactivate()
on
the subscriber object returned by this
method, followed by a call to System.gc()
. This call is necessary because at high data rates the
JRE is never idle enough for the garbage collector to run.
Do not use this method from within a callback. If it causes a timeout, you might loose messages otherwise.
The following sublcasses of MData
can be used for publishing:
message
- Message to publish.listener
- MEventListener
that will receive the reply.MException
- on the following condition:
send(MData)
public MSubscriber sendWithReply(MTree message, MEventListener listener, int timeout) throws MException
MTree
format. When the reply is sent, the SDK informs the listener specified
by the listener argument.
If the message format of the MTree
does not correspond to the
message format of this publisher, the Adapter SDK attempts to convert the MTree
to the correct format. You should not pass an MTree
publisher that has a different
format because it degrades performance.
message
- Message to publish.listener
- MEventListener
that will receive that listener.timeout
- Timeout (in milliseconds). If no reply is received within the specified wait time,
the user's onEvent receives an MTimeoutEvent
.MException
- on the following condition:
send(MTree)
,
sendWithReply(MTree, MEventListener)
public MSubscriber sendWithReply(MData message, MEventListener listener, int timeout) throws MException
MData
format. When the reply is sent, the SDK informs the listener specified
by the listener argument.
The following sublcasses of MData
can be used for publishing:
message
- Message to publish.listener
- MEventListener
that will receive that listener.timeout
- Timeout (in milliseconds). If no reply is received within the specified wait time,
the user's onEvent receives an MTimeoutEvent
.MException
- on the following condition:
send(MTree)
,
sendWithReply(MData, MEventListener)
public MTree sendWithSyncReply(MTree message, long timeout) throws MException
If the message format of the MTree
does not correspond to the
message format of this publisher, the Adapter SDK attempts to convert the MTree
to the correct format. You should not pass an MTree
publisher that has a different
format because it degrades performance.
MPublisher
has sent out a message with this method.
message
- Message to publish.timeout
- Timeout (in milliseconds). If no reply is received within the specified wait time,
MTimeoutException
is thrown. If 0 or -1 is specified, the method will not timeout and wait indefinitely.MException
- on any error sending the request or receiving the reply or timeout expired.send(MTree)
public MTree sendWithSyncReply(MData message, long timeout) throws MException
Because the Java SDK is both thread safe and thread aware, you can still receive
information even if the MPublisher
has sent out a message with this method.
The following sublcasses of MData
can be used for publishing:
message
- Message to publish.timeout
- Timeout (in milliseconds). If no reply is received within the specified wait time,
MTimeoutException
is thrown. If 0 or -1 is specified, the method will not timeout and wait indefinitely.
MTimeoutException
is thrown.MException
- on any error sending the request, receiving the reply or timeout expired.send(MTree)
public MTree sendWithSyncReply(MTree message) throws MException
MException
public java.util.Enumeration getClassNames()
Enumeration.nextElement()
can be cast to String
.public int getDeliveryMode()
MEndpointSpec.DELIVERY_RELIABLE
MEndpointSpec.DELIVERY_PERSIST
MRvEndpointSpec.DELIVERY_DIST_Q
public java.lang.String getDestinationName()
public void setDestinationName(java.lang.String subject) throws MException
MPublisher
sends messages.
One should avoid dynamic subjects on publishing endpoint as it goes against the "publishing service" architecture where the service has a bounded fixed subject publishing endpoint.
MException
public MSession getSession()
public java.lang.String getReplyDestinationName()
public void setReplyDestinationName(java.lang.String replyDestinationName)
public void setJmsCorrelationId(java.lang.String correlationId)
To use correlationId , it should be set before sending every message
correlationId
- The correlationId to be setpublic void disableJmsMessageId(boolean bShouldDisable)
bShouldDisable
- is set to true when messageId is not to be sent with the message , if set to false the
message id is set on the message. By default the messsage ID is set on the message.public void setJmsPriority(int priority)
JMS defines a ten level priority value with 0 as the lowest priority and 9 as the highest. In addition, users should consider priorities 0-4 as gradations of normal priority and priorities 5-9 as gradations of expedited priority.
priority
- The priority to be setpublic int getMessageFormat()
MMessageFormat
public long getSequenceNumber() throws MException
If the sequence number cannot be obtained due to some processing error, return -1
MException
- on any error on extraction of the sequence number.public void preRegisterListener(java.lang.String listenerName) throws MException
Some sending applications can anticipate requests for certified delivery even before the listening applications start running. In such situations, the sender can preregister listeners so that TIBCO Rendezvous software begins storing outbound messages in the senders ledger. If the listening correspondent requires old messages, it receives the backlogged messages when it requests certified delivery.
If the correspondent specified by listenerName
is already receiving
certified delivery of this senders subject (from any sender of the session), this method has no effect.
If you change the destination for a publisher using MPublisher.setSubjectName()
,
the publisher with the new destination will be unaware of any pre-registration done previously.
listenerName
- Anticipate a listener with this reusable name.MException
- on any error while preregistering the specified listener or if transport is not TIBCO Rendezvous.unRegisterListener(String)
public void unRegisterListener(java.lang.String listenerName) throws MException
For RV, This method cancels certified delivery of this senders subject to the correspondent with name listenerName.
When a sending program calls this method, certified delivery software in the sender behaves as
if the listener had closed the endpoint for the destination. The sending program deletes from
its ledger all information about delivery of the subject to the correspondent specified by listenerName
.
The sending program receives a REGISTRATION.CLOSED
advisory to trigger any callback
methods for that advisory.
If the listening correspondent is available (running and reachable), it receives
a REGISTRATION.NOT_CERTIFIED ADVISORY
, informing it that the sender no longer certifies
delivery of the subject.
If the correspondent rsCertifiedSessionName
does not receive certified delivery of
the subject from this session, this method throws an exception.
For JMS, this method unregisters a durable inactive subscriber. The sending program receives an exception if the call failed.
listenerName
- Cancel certified delivery of the senders subject to the correspondent with this name.MException
- on any error while unregistering the specified listener or if transport is not TIBCO RendezvouspreRegisterListener(String)
public void assignMsgGUID(boolean assignGUID)
public boolean getAssignMsgGUID()
public void setSubjectName(java.lang.String subject) throws MException
MException
public java.lang.String getSubjectName()
getDestinationName()
public void setReplySubject(java.lang.String replySubject)
setReplyDestinationName(String)
public java.lang.String getReplySubject()
getReplyDestinationName()
public int getProtocol()
getDeliveryMode()
public void validateMessage(boolean doValidate)
public MRvSession getMRvSession()
getSession()
public void sendWithReply(MTree message, MSubscriber subscriber) throws MException
MException
public void addClassName(java.lang.String p_className)
public long getNumMessagesPublished()
public void setCmTimeLimit(int p_timeLimit) throws MException
MException
public void addTPluginName(java.lang.String sTPluginName)
public MEndpointSpec getEndpointSpec()