Class InspectableProducer<T>

  • All Implemented Interfaces:
    org.ikasan.spec.component.endpoint.Producer<T>, org.ikasan.spec.configuration.Configured<org.ikasan.component.endpoint.jms.spring.producer.SpringMessageProducerConfiguration>, org.ikasan.spec.configuration.ConfiguredResource<org.ikasan.component.endpoint.jms.spring.producer.SpringMessageProducerConfiguration>, org.ikasan.spec.management.ManagedResource

    public class InspectableProducer<T>
    extends org.ikasan.component.endpoint.jms.spring.producer.JmsTemplateProducer<T>
    Dummy producer to test last messages/events in unit tests.

    It can be used with or without an actual IkasanJmsTemplate setup. If you want to use it with a IkasanJmsTemplate simple provide the instance of the template in constructor (directly or in Spring config) and provide "configuration" and "configuredResourceId" parameters.

    Useful for unit tests by providing a Spring config that will override the original producer with this implementation, so that you can check the persisted messages by calling the getEvents() and getEventCount() methods.

    Author:
    Ikasan Development Team
    • Field Summary

      • Fields inherited from class org.ikasan.component.endpoint.jms.spring.producer.JmsTemplateProducer

        jmsTemplate
    • Constructor Summary

      Constructors 
      Constructor Description
      InspectableProducer()
      Constructs a InspectableProducer.
      InspectableProducer​(org.springframework.jms.core.IkasanJmsTemplate jmsTemplate)
      Constructs a InspectableProducer with an IkasanJmsTemplate.
    • Method Summary

      All Methods Instance Methods Concrete Methods 
      Modifier and Type Method Description
      int getEventCount()  
      java.util.List<T> getEvents()  
      void invoke​(T message)  
      boolean isUseJms()  
      void setUseJms​(boolean useJms)  
      • Methods inherited from class org.ikasan.component.endpoint.jms.spring.producer.JmsTemplateProducer

        establishConnectionFactory, getConfiguration, getConfiguredResourceId, isCriticalOnStartup, setConfiguration, setConfiguredResourceId, setCriticalOnStartup, setManagedResourceRecoveryManager, startManagedResource, stopManagedResource
      • Methods inherited from class java.lang.Object

        clone, equals, finalize, getClass, hashCode, notify, notifyAll, toString, wait, wait, wait
    • Constructor Detail

      • InspectableProducer

        public InspectableProducer()
        Constructs a InspectableProducer. All messages that the producer processes will be collected and not processed further.
      • InspectableProducer

        public InspectableProducer​(org.springframework.jms.core.IkasanJmsTemplate jmsTemplate)
        Constructs a InspectableProducer with an IkasanJmsTemplate. All messages that the producer processes will be collected and also send via the jms template.
        Parameters:
        jmsTemplate -
    • Method Detail

      • isUseJms

        public boolean isUseJms()
        Returns:
        the value of the useJms property.
      • setUseJms

        public void setUseJms​(boolean useJms)
        Parameters:
        useJms - configuration if the messages are processed via Jms after collection.
      • getEventCount

        public int getEventCount()
        Returns:
        the count of the currently collected events.
      • getEvents

        public java.util.List<T> getEvents()
        Returns:
        the events that the producer processed
      • invoke

        public void invoke​(T message)
                    throws org.ikasan.spec.component.endpoint.EndpointException
        Specified by:
        invoke in interface org.ikasan.spec.component.endpoint.Producer<T>
        Overrides:
        invoke in class org.ikasan.component.endpoint.jms.spring.producer.JmsTemplateProducer<T>
        Throws:
        org.ikasan.spec.component.endpoint.EndpointException