Package org.eclipse.scanning.event
Class AMQPSubscriberImpl<T extends EventListener>
java.lang.Object
org.eclipse.scanning.event.AbstractTopicConnection
org.eclipse.scanning.event.AMQPSubscriberImpl<T>
- All Implemented Interfaces:
AutoCloseable,IConnection,IPropertyFilter,ISubscriber<T>,ITopicConnection,IURIConnection
-
Nested Class Summary
Nested classes/interfaces inherited from interface org.eclipse.scanning.api.event.core.IPropertyFilter
IPropertyFilter.FilterAction -
Field Summary
FieldsModifier and TypeFieldDescriptionprotected IEventConnectorServiceprotected Stringprotected Stringprotected final URI -
Constructor Summary
Constructors -
Method Summary
Modifier and TypeMethodDescriptionvoidaddListener(String beanId, T listener) Register events for a given id to be reported.voidaddListener(T listener) Adds a listener which is notified when events are broadcast.voidaddProperty(String name, IPropertyFilter.FilterAction... actions) protected javax.jms.QueuecreateQueue(String queueName) Creates and returns a queue of the given nameprotected javax.jms.TopiccreateTopic(String topicName) Creates and returns a topic of the given namevoidCall to disconnect any resources which we no longer need.Class<?> The underlyng service which the uri is connected usingprotected javax.jms.QueueSessionprotected javax.jms.SessiongetUri()The URI of this connection.protected voidinvokeScanListener(IScanListener scanListener, ScanBean scanBean) booleanReturns whether this connection is connected.protected booleanisForSameObject(Object qbean, Object bean) A utility method to test if a bean from the queue represents the same bean as that given .booleanvoidRemoves all listeners without disconnecting from events or stopping the JMS threads.voidremoveListener(String id, T listener) Unregister events for a given id to be reported.voidremoveListener(T listener) Removes a listener such that events are no longer sent to it.voidUnregister all listeners with this id.voidremoveProperty(String name) Removes the filter for the named property.protected voidsetConnected(boolean connected) voidsetStatusTopicName(String statusTopicName) voidsetSynchronous(boolean synchronous) Call to set if the events should be ordered and BLOCKING.voidsetTopicName(String topicName) Methods inherited from class org.eclipse.scanning.event.AbstractTopicConnection
getTopicNameMethods inherited from class java.lang.Object
clone, equals, finalize, getClass, hashCode, notify, notifyAll, toString, wait, wait, waitMethods inherited from interface org.eclipse.scanning.api.event.core.IConnection
close, isConnectedMethods inherited from interface org.eclipse.scanning.api.event.core.ITopicConnection
getTopicNameMethods inherited from interface org.eclipse.scanning.api.event.core.IURIConnection
getConnectorService, getUri
-
Field Details
-
uri
-
submitQueueName
-
statusTopicName
-
service
-
-
Constructor Details
-
AMQPSubscriberImpl
-
-
Method Details
-
createTopic
Description copied from class:AbstractTopicConnectionCreates and returns a topic of the given name- Overrides:
createTopicin classAbstractTopicConnection- Parameters:
topicName-- Returns:
- topic
- Throws:
javax.jms.JMSException
-
setTopicName
- Overrides:
setTopicNamein classAbstractTopicConnection
-
addListener
Description copied from interface:ISubscriberAdds a listener which is notified when events are broadcast. The listener works event if the manager is running on a client and the broadcast is happening from a server because through JMS or similar messaging system which this service and manager are hiding.- Specified by:
addListenerin interfaceISubscriber<T extends EventListener>- Parameters:
listener-- Throws:
EventException
-
addListener
Description copied from interface:ISubscriberRegister events for a given id to be reported.- Specified by:
addListenerin interfaceISubscriber<T extends EventListener>- Parameters:
beanId-listener-- Throws:
EventException
-
getBeanClass
-
invokeScanListener
-
removeListener
Description copied from interface:ISubscriberRemoves a listener such that events are no longer sent to it.- Specified by:
removeListenerin interfaceISubscriber<T extends EventListener>- Parameters:
listener-
-
removeListener
Description copied from interface:ISubscriberUnregister events for a given id to be reported.- Specified by:
removeListenerin interfaceISubscriber<T extends EventListener>- Parameters:
id-listener-
-
removeListeners
Description copied from interface:ISubscriberUnregister all listeners with this id.- Specified by:
removeListenersin interfaceISubscriber<T extends EventListener>- Parameters:
id-
-
removeAllListeners
public void removeAllListeners()Description copied from interface:ISubscriberRemoves all listeners without disconnecting from events or stopping the JMS threads.- Specified by:
removeAllListenersin interfaceISubscriber<T extends EventListener>
-
disconnect
Description copied from interface:IConnectionCall to disconnect any resources which we no longer need. The resource may have timed out so it might not be connected, in that case it silently returns. Note, that the methodIConnection.close(), inherited fromAutoCloseablecalls this method, which means that if an object of a class implementingIConnectionis used with a try-with-resources block this method will be called automatically when exiting that block.- Specified by:
disconnectin interfaceIConnection- Throws:
EventException- if resource could not be disconnected.
-
isSynchronous
public boolean isSynchronous()- Specified by:
isSynchronousin interfaceISubscriber<T extends EventListener>- Returns:
- true by default.
-
setSynchronous
public void setSynchronous(boolean synchronous) Description copied from interface:ISubscriberCall to set if the events should be ordered and BLOCKING. The default is true. When synchronous is true events are despatched in order and the event listener method is waited for until it returns before processing more events. If it is false the messaging thread is used to directly depatch the event meaning that more events may occur and be called the last listener has returned. Note: this method must be called before adding any listeners by callingISubscriber.addListener(EventListener)orISubscriber.addListener(String, EventListener).- Specified by:
setSynchronousin interfaceISubscriber<T extends EventListener>- Parameters:
synchronous-
-
addProperty
- Specified by:
addPropertyin interfaceIPropertyFilter- Parameters:
name-actions-
-
removeProperty
Description copied from interface:IPropertyFilterRemoves the filter for the named property.- Specified by:
removePropertyin interfaceIPropertyFilter- Parameters:
name-
-
getProperties
- Specified by:
getPropertiesin interfaceIPropertyFilter- Returns:
- the list of named properties that we are filtering.
-
getConnectorService
Description copied from interface:IURIConnectionThe underlyng service which the uri is connected using- Specified by:
getConnectorServicein interfaceIURIConnection
-
getSession
protected javax.jms.Session getSession() throws javax.jms.JMSException- Throws:
javax.jms.JMSException
-
getQueueSession
protected javax.jms.QueueSession getQueueSession() throws javax.jms.JMSException- Throws:
javax.jms.JMSException
-
createQueue
Creates and returns a queue of the given name- Parameters:
queueName-- Returns:
- Throws:
javax.jms.JMSException
-
getUri
Description copied from interface:IURIConnectionThe URI of this connection.- Specified by:
getUriin interfaceIURIConnection- Returns:
-
getSubmitQueueName
-
getStatusTopicName
-
setStatusTopicName
-
isForSameObject
A utility method to test if a bean from the queue represents the same bean as that given . This is done by comparing their uniqueIds, if present, and falls back on usingObject.equals(Object)- Parameters:
qbean-bean-- Returns:
trueif the two beans represent the same object,falseotherwise
-
isConnected
public boolean isConnected()Description copied from interface:IConnectionReturns whether this connection is connected. This method returnstrueuntil disconnect is called, even if the connection is created lazily.- Specified by:
isConnectedin interfaceIConnection- Returns:
trueif connected,falseotherwise
-
setConnected
protected void setConnected(boolean connected)
-