Package org.eclipse.scanning.event
Class AbstractTopicConnection
java.lang.Object
org.eclipse.scanning.event.AbstractTopicConnection
- All Implemented Interfaces:
AutoCloseable,IConnection,ITopicConnection,IURIConnection
- Direct Known Subclasses:
AMQPSubscriberImpl
Abstract superclass for objects that publish or subscribe to a topic.
-
Field Summary
FieldsModifier and TypeFieldDescriptionprotected IEventConnectorServiceprotected Stringprotected Stringprotected final URI -
Method Summary
Modifier and TypeMethodDescriptionprotected 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.The underlyng service which the uri is connected usingprotected javax.jms.QueueSessionprotected javax.jms.SessionThe string topic to publish events on for this manager.getUri()The URI of this connection.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 .protected voidsetConnected(boolean connected) voidsetStatusTopicName(String statusTopicName) voidsetTopicName(String topic) Methods 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, disconnect, isConnectedMethods inherited from interface org.eclipse.scanning.api.event.core.IURIConnection
getConnectorService, getUri
-
Field Details
-
uri
-
submitQueueName
-
statusTopicName
-
service
-
-
Method Details
-
createTopic
Creates and returns a topic of the given name- Parameters:
topicName-- Returns:
- topic
- Throws:
javax.jms.JMSException
-
getTopicName
Description copied from interface:ITopicConnectionThe string topic to publish events on for this manager. The events will be beans which serialize to JSON.- Specified by:
getTopicNamein interfaceITopicConnection- Returns:
- the topic name
-
setTopicName
-
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
-
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.
-
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)
-