public final class EdnJmsConnection extends BaseEdnConnection
Modifier and Type | Field and Description |
---|---|
static String |
JNDI_DEFAULT_AQJMS_LOCALTX_CONN_FACTORY |
static String |
JNDI_DEFAULT_AQJMS_XA_CONN_FACTORY |
static String |
JNDI_DEFAULT_WLJMS_LOCALTX_CONN_FACTORY |
static String |
JNDI_DEFAULT_WLJMS_XA_CONN_FACTORY |
Constructor and Description |
---|
EdnJmsConnection(Context ctx)
Construct a remote JMS Connection to EDN.
|
Modifier and Type | Method and Description |
---|---|
void |
close()
close the EDN connection: clean up internal states - wipe out current JMS topic connection factory, close all cached JMS topic connections, JTA user transaction reference, reset subscriber message consuming state flags throws IllegalStateException if the long running event receiver thread is not shutdown
|
void |
forceClose()
close the EDN connection: (1) request event receiver thread shutdown; (2) clean up internal states - wipe out current JMS topic connection factory, close all cached JMS topic connections, JTA user transaction reference, reset subscriber message consuming state flags
|
String |
getClientID()
Get client ID used for creating durable subscriptions.
|
javax.jms.TopicConnectionFactory |
getTopicConnectionFactory()
Get non-XA TopicConnectionFactory instance.
|
UserTransaction |
getUserTransaction()
Get UserTranasction instance for XA.
|
javax.jms.TopicConnectionFactory |
getXaTopicConnectionFactory()
Get XA TopicConnectionFactory instance.
|
boolean |
isReceiving()
check if the receiver is receiving events.
|
void |
publishEvent(BusinessEvent event)
Publish an event with default persistent, priority, time to live, and EDL as input source.
|
void |
publishEvent(BusinessEvent event, boolean persistent, int priority, long timeToLive, String edlURI)
Publish an event with specified delivery mode, priority, time to live, and EDL URI.
|
void |
publishEvent(BusinessEvent event, int priority)
Publish an event with indicated priority
|
void |
setClientID(String clientID)
Set client ID used for creating durable subscriptions.
|
void |
setJmsConfig(JmsConfig config)
Custom JmsConfig for all the events to be published and subscribed via this Event Connection.
|
void |
setTopicConnectionFactory(javax.jms.TopicConnectionFactory topicConnectionFactory)
Set a non-XA TopicConnectionFactory instance.
|
void |
setUserTransaction(UserTransaction userTransaction)
Set UserTranasction instance for XA.
|
void |
setXaTopicConnectionFactory(javax.jms.TopicConnectionFactory xaTopicConnectionFactory)
Set a XA TopicConnectionFactory instance.
|
void |
stopReceiving()
request that receiver stop receiving events (exit the while loop - next time it checked the flag: stopReceivingRequested)
|
EdnJmsEventReader |
subscribe(QName eventName, ConsistencyLevel qos, XPathFilter filter, boolean runAsPublisher, long timeout, String durableSubName)
create subscriber (durable / non-durable) and return an associated POJO (EdnJmsEventReader) to the caller, EdnJmsEventReader provides caller with fine grained event consuming (start/stop message delivery, read one event etc.)
|
void |
subscribe(QName eventName, ConsistencyLevel qos, XPathFilter filter, BusinessEventHandler handler, boolean runAsPublisher, long timeout, String durableSubName)
Subscribe to EDN JMS topic (fetched from server through jndi lookup::EDNConfig) for EDN event (indicated by
eventName ), if durableSubName presents, a durable subscriber is created with durableSubName as subscriber name, the jms durable subscriber client ID is using the value from EdnJmsConnection class level clientID; |
void |
subscribe(QName eventName, String durableSubscriptionName)
Subscribe to EDN JMS topic (fetched from server through jndi lookup::EDNConfig) for EDN event (indicated by
eventName ), if durableSubscriptionName presents, a durable subscriber is created with durableSubscriptionName as subscriber name EDN consistency level : default to class instance consistency level EDN event filter: default to class instance event filter EDN event handler: default to class instance event handler EDN run as publisher: default to class instance value of run as publisher EDN event receiving (read) timeout (in millis) : default to class instance timeout value |
EdnJmsEventReader |
subscribeOnly(QName eventName, String durableSubscriptionName)
create subscriber only, return a EdnJmsEventReader instance where the caller can do fine grained message receiving (start/stop message delivery on the underlying JMS topic connection, read event from the underlying JMS subscriber, etc.) EDN consistency level : default to class instance consistency level EDN event filter: default to class instance event filter EDN event handler: default to class instance event handler EDN run as publisher: default to class instance value of run as publisher EDN event receiving (read) timeout (in millis) : default to class instance timeout value
|
void |
unsubscribe(QName eventName, String durableSubName)
Remove a durable subscription that has been created previously.
|
void |
waitOnReceiver()
alternative for client sync with event receiving thread (long running)
|
void |
waitOnReceiver(long millis)
alternative for client sync with event receiving thread (long running)
|
void |
waitSubscriberCreationComplete()
block on the latch until latch zero'd
|
boolean |
waitSubscriberCreationComplete(long timeout, TimeUnit unit)
block on the latch with a timeout;
|
getConsistencyLevel, getContextProvider, getEDL, getEDN, getEventHandler, getEventToJmsMapping, getPriority, getTimeout, getTimeToLive, getXPathFilter, isPersistent, isRunAsPublisher, setConsistencyLevel, setContextProvider, setEDL, setEDN, setEventHandler, setEventToJmsMapping, setPersistent, setPriority, setRunAsPublisher, setTimeout, setTimeToLive, setXPathFilter
public static final String JNDI_DEFAULT_WLJMS_XA_CONN_FACTORY
public static final String JNDI_DEFAULT_WLJMS_LOCALTX_CONN_FACTORY
public static final String JNDI_DEFAULT_AQJMS_XA_CONN_FACTORY
public static final String JNDI_DEFAULT_AQJMS_LOCALTX_CONN_FACTORY
public EdnJmsConnection(Context ctx)
ctx
- - JNDI Context.public javax.jms.TopicConnectionFactory getTopicConnectionFactory()
public void setTopicConnectionFactory(javax.jms.TopicConnectionFactory topicConnectionFactory)
topicConnectionFactory
- - non-XA TopicConnectionFactory instance.public javax.jms.TopicConnectionFactory getXaTopicConnectionFactory()
public void setXaTopicConnectionFactory(javax.jms.TopicConnectionFactory xaTopicConnectionFactory)
xaTopicConnectionFactory
- - XA TopicConnectionFactory instance.public UserTransaction getUserTransaction()
public void setUserTransaction(UserTransaction userTransaction)
userTransaction
- - UserTranasction instance for XA.public String getClientID()
public void setClientID(String clientID)
clientID
- client ID used for creating durable subscriptions.public void close()
close
in interface BusinessEventConnection
close
in class BaseEdnConnection
BaseEdnConnection.close()
public void forceClose()
public void publishEvent(BusinessEvent event) throws oracle.fabric.common.FabricException
EdnConnection
publishEvent
in interface EdnConnection
publishEvent
in class BaseEdnConnection
event
- Business Event to be publishedoracle.fabric.common.FabricException
- If it fails to publish the event with default options.public void publishEvent(BusinessEvent event, int priority) throws oracle.fabric.common.FabricException
BusinessEventConnection
publishEvent
in interface BusinessEventConnection
publishEvent
in class BaseEdnConnection
event
- - Business Event to be publishedpriority
- - event priorityoracle.fabric.common.FabricException
- if fabric exception occurspublic void publishEvent(BusinessEvent event, boolean persistent, int priority, long timeToLive, String edlURI) throws oracle.fabric.common.FabricException
EdnConnection
publishEvent
in interface EdnConnection
publishEvent
in class BaseEdnConnection
event
- Business Event to be publishedpersistent
- Persistent (or non persistent) delivery modepriority
- Event prioritytimeToLive
- Time to live in millisecondsedlURI
- URI with "oramds" referencing Event definition contentoracle.fabric.common.FabricException
- If it fails to publish the event with specified options.public void subscribe(QName eventName, String durableSubscriptionName) throws oracle.fabric.common.FabricException
eventName
), if durableSubscriptionName
presents, a durable subscriber is created with durableSubscriptionName
as subscriber name EDN consistency level : default to class instance consistency level EDN event filter: default to class instance event filter EDN event handler: default to class instance event handler EDN run as publisher: default to class instance value of run as publisher EDN event receiving (read) timeout (in millis) : default to class instance timeout valuesubscribe
in interface EdnConnection
subscribe
in class BaseEdnConnection
eventName
- - EDN event name to subscribe to;durableSubscriptionName
- - JMS durable subscriber name (client ID takes default value), when not present, it indicates a non-durable subscriberoracle.fabric.common.FabricException
- If it fails to subscribe to events with specified options.BaseEdnConnection.subscribe(javax.xml.namespace.QName, java.lang.String)
public void subscribe(QName eventName, ConsistencyLevel qos, XPathFilter filter, BusinessEventHandler handler, boolean runAsPublisher, long timeout, String durableSubName) throws oracle.fabric.common.FabricException
eventName
), if durableSubName
presents, a durable subscriber is created with durableSubName
as subscriber name, the jms durable subscriber client ID is using the value from EdnJmsConnection class level clientID;subscribe
in interface EdnConnection
subscribe
in class BaseEdnConnection
eventName
- - EDN event name to subscribe to;qos
- - EDN consistency level: ConsistencyLevel.ONE_AND_ONLY_ONE/ConsistencyLevel.GUARANTEED_DELIVERYfilter
- - XPath repression when presents, will be applied to EDN event payload to determine if the event will be delivered to target (or discarded);handler
- - An impl of BusinessEventHandler provided by client for per event processing;runAsPublisher
- - a hint for EDN inbound delivery security policy, when true, the event publisher's subject will be used when deliver event to target;timeout
- - the timeout (in millis) used for subsequent jms message receiving after the subscriber created;durableSubName
- - durable subscriber name (client ID takes the value from class instance level clientID), when not present, it indicates a non-durable subscriberoracle.fabric.common.FabricException
- If it fails to subscribe to events with specified options.BaseEdnConnection.subscribe(javax.xml.namespace.QName, java.lang.String)
public void waitSubscriberCreationComplete() throws InterruptedException
InterruptedException
public boolean waitSubscriberCreationComplete(long timeout, TimeUnit unit) throws InterruptedException
timeout
-unit
-InterruptedException
public EdnJmsEventReader subscribeOnly(QName eventName, String durableSubscriptionName) throws Exception
eventName
- - EDN event name to subscribe to;durableSubscriptionName
- - durable subscriber name (client ID takes the value from class instance level clientID), when not present, it indicates a non-durable subscriberException
- error during subscriber creation;public EdnJmsEventReader subscribe(QName eventName, ConsistencyLevel qos, XPathFilter filter, boolean runAsPublisher, long timeout, String durableSubName) throws Exception
eventName
- - full name of the EDN event subscribe toqos
- - EDN consistency levelfilter
- - XPathFilter - EDN event filter - if present, will override the filterrunAsPublisher
-timeout
- - timeout in milli-sec fordurableSubName
- - if present, the durable subscriber name, when null - non-durable subscribeException
- - Error during subscription creation.public void unsubscribe(QName eventName, String durableSubName) throws oracle.fabric.common.FabricException
EdnConnection
unsubscribe
in interface EdnConnection
unsubscribe
in class BaseEdnConnection
eventName
- Event QName to unsubscribe todurableSubName
- Durable subscription name whose subscription is to be removed.oracle.fabric.common.FabricException
- if it fails to remove the durable subscription due to some internal error, or the subscription name is invalid.public void setJmsConfig(JmsConfig config)
config
- - JmsConfig object to setpublic boolean isReceiving()
public void stopReceiving()
public void waitOnReceiver() throws InterruptedException
InterruptedException
public void waitOnReceiver(long millis) throws InterruptedException
millis
-InterruptedException