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

public class AMQPSubscriberImpl<T extends EventListener> extends AbstractTopicConnection
  • Field Details

  • Constructor Details

  • Method Details

    • createTopic

      protected javax.jms.Topic createTopic(String topicName) throws javax.jms.JMSException
      Description copied from class: AbstractTopicConnection
      Creates and returns a topic of the given name
      Overrides:
      createTopic in class AbstractTopicConnection
      Parameters:
      topicName -
      Returns:
      topic
      Throws:
      javax.jms.JMSException
    • setTopicName

      public void setTopicName(String topicName)
      Overrides:
      setTopicName in class AbstractTopicConnection
    • addListener

      public void addListener(T listener) throws EventException
      Description copied from interface: ISubscriber
      Adds 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:
      addListener in interface ISubscriber<T extends EventListener>
      Parameters:
      listener -
      Throws:
      EventException
    • addListener

      public void addListener(String beanId, T listener) throws EventException
      Description copied from interface: ISubscriber
      Register events for a given id to be reported.
      Specified by:
      addListener in interface ISubscriber<T extends EventListener>
      Parameters:
      beanId -
      listener -
      Throws:
      EventException
    • getBeanClass

      public Class<?> getBeanClass()
    • invokeScanListener

      protected void invokeScanListener(IScanListener scanListener, ScanBean scanBean)
    • removeListener

      public void removeListener(T listener)
      Description copied from interface: ISubscriber
      Removes a listener such that events are no longer sent to it.
      Specified by:
      removeListener in interface ISubscriber<T extends EventListener>
      Parameters:
      listener -
    • removeListener

      public void removeListener(String id, T listener)
      Description copied from interface: ISubscriber
      Unregister events for a given id to be reported.
      Specified by:
      removeListener in interface ISubscriber<T extends EventListener>
      Parameters:
      id -
      listener -
    • removeListeners

      public void removeListeners(String id)
      Description copied from interface: ISubscriber
      Unregister all listeners with this id.
      Specified by:
      removeListeners in interface ISubscriber<T extends EventListener>
      Parameters:
      id -
    • removeAllListeners

      public void removeAllListeners()
      Description copied from interface: ISubscriber
      Removes all listeners without disconnecting from events or stopping the JMS threads.
      Specified by:
      removeAllListeners in interface ISubscriber<T extends EventListener>
    • disconnect

      public void disconnect() throws EventException
      Description copied from interface: IConnection
      Call 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 method IConnection.close(), inherited from AutoCloseable calls this method, which means that if an object of a class implementing IConnection is used with a try-with-resources block this method will be called automatically when exiting that block.
      Specified by:
      disconnect in interface IConnection
      Throws:
      EventException - if resource could not be disconnected.
    • isSynchronous

      public boolean isSynchronous()
      Specified by:
      isSynchronous in interface ISubscriber<T extends EventListener>
      Returns:
      true by default.
    • setSynchronous

      public void setSynchronous(boolean synchronous)
      Description copied from interface: ISubscriber
      Call 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 calling ISubscriber.addListener(EventListener) or ISubscriber.addListener(String, EventListener).
      Specified by:
      setSynchronous in interface ISubscriber<T extends EventListener>
      Parameters:
      synchronous -
    • addProperty

      public void addProperty(String name, IPropertyFilter.FilterAction... actions)
      Specified by:
      addProperty in interface IPropertyFilter
      Parameters:
      name -
      actions -
    • removeProperty

      public void removeProperty(String name)
      Description copied from interface: IPropertyFilter
      Removes the filter for the named property.
      Specified by:
      removeProperty in interface IPropertyFilter
      Parameters:
      name -
    • getProperties

      public List<String> getProperties()
      Specified by:
      getProperties in interface IPropertyFilter
      Returns:
      the list of named properties that we are filtering.
    • getConnectorService

      public IEventConnectorService getConnectorService()
      Description copied from interface: IURIConnection
      The underlyng service which the uri is connected using
      Specified by:
      getConnectorService in interface IURIConnection
    • 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

      protected javax.jms.Queue createQueue(String queueName) throws javax.jms.JMSException
      Creates and returns a queue of the given name
      Parameters:
      queueName -
      Returns:
      Throws:
      javax.jms.JMSException
    • getUri

      public URI getUri()
      Description copied from interface: IURIConnection
      The URI of this connection.
      Specified by:
      getUri in interface IURIConnection
      Returns:
    • getSubmitQueueName

      public String getSubmitQueueName()
    • getStatusTopicName

      public String getStatusTopicName()
    • setStatusTopicName

      public void setStatusTopicName(String statusTopicName)
    • isForSameObject

      protected boolean isForSameObject(Object qbean, Object bean)
      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 using Object.equals(Object)
      Parameters:
      qbean -
      bean -
      Returns:
      true if the two beans represent the same object, false otherwise
    • isConnected

      public boolean isConnected()
      Description copied from interface: IConnection
      Returns whether this connection is connected. This method returns true until disconnect is called, even if the connection is created lazily.
      Specified by:
      isConnected in interface IConnection
      Returns:
      true if connected, false otherwise
    • setConnected

      protected void setConnected(boolean connected)