Annotation Type DurableProducer


@Retention(RUNTIME) @Target(TYPE) @Documented @EnableBinding @AutoConfigureAfter(com.broadleafcommerce.common.messaging.autoconfigure.DurableNotificationAutoConfiguration.class) @Import({DurableNotificationConfigurationPropertiesRegistrar.class,NotificationStateInitializingDomainMapperMemberRegistrar.class,NotificationHandlerRegistrar.class,RetryClusterServiceRegistrar.class}) public @interface DurableProducer
Convenience annotation for reducing the amount of boilerplate setup code required to establish a durable message send flow. This annotation will establish the following beans in the Spring context:
  1. [componentPrefix]NotificationProperties - ConfigurationProperties instance with values that configure the durable message send retry behavior. The configurationPrefix() represents the prefix that will be set on ConfigurationProperties.prefix().
  2. [componentPrefix]NotificationHandler - Handler instance used in NotificationManager to attempt a message send and manage NotificationState ack state.
  3. [componentPrefix]RetryClusterService - Camel cluster singleton service responsible for retrying this name() (i.e. messageType) across all supporting NotificationStateRepository instances.
  4. [componentPrefix]InitializingDomainMapperMember - Optional component responsible for initializing the NotificationState for a messageType on a given entity during CRUD flows.
Note, if you provide a messageFactory() for a valid bean name of a MessageFactory instance, that factory will be used to construct the message sent, unless a message already exists in NotificationState.getMessageValue().

For a NotificationHandler to be able to manage the ack state of a NotificationState instance, the NotificationState must already be initialized. This can be achieved by either custom code that sets an initialized NotificationState for the messageType during entity creation, or by including a subclass of NotificationStateInitializingDomainMapperMember as a bean. This DomainMapperMember is a convenience that establishes an initialized NotificationState during the CREATE, REPLACE, UPDATE, and DELETE flows for your entity - removing the need for a customized persistence flow. By including the optional #entityType() param on this annotation, the system will automatically create a basic subclass of NotificationStateInitializingDomainMapperMember for you and register it as a bean. If the producer will always be utilized in a detached way, you can skip setting the #entityType() param.

The DurableProducer annotation should be used on a Spring Configuration class. An example of a configuration on a pre-existing SpringCloudStream producer might look like:
  @Configuration
  @DurableProducer(output = TestProducer.class, name = "tester", messageFactory = "testMessageFactory", configurationPrefix = "broadleaf.test", entityType = JpaItem.class)
  public class Config {
   ...
  }
 
  • Required Element Summary

    Required Elements
    Modifier and Type
    Required Element
    Description
    Establish the prefix to use for the generated ConfigurationProperties class that holds the configuration values for the durable send.
    Name identifying the type of message.
    Class<?>[]
    The interface having a method annotated with Output to indicate the binding target.
  • Optional Element Summary

    Optional Elements
    Modifier and Type
    Optional Element
    Description
    Optional.
    Optional.
    Optional.
  • Element Details

    • output

      @AliasFor(annotation=org.springframework.cloud.stream.annotation.EnableBinding.class, attribute="value") Class<?>[] output
      The interface having a method annotated with Output to indicate the binding target. Only one class may be defined here.
    • name

      String name
      Name identifying the type of message.
      See Also:
      • NotificationState.getName()
    • configurationPrefix

      String configurationPrefix
      Establish the prefix to use for the generated ConfigurationProperties class that holds the configuration values for the durable send.
      See Also:
      • DurableNotificationProperties
      • ConfigurationProperties.prefix()
    • componentPrefix

      String componentPrefix
      Optional. Prefix used during bean name creation for the components emitted as a result of this annotation. If not used, the name() param will be employed, which may result in unexpected or unusual bean and class names for the dynamically created components.
      Default:
      "NONE"
    • messageFactory

      String messageFactory
      Optional. Bean name of the MessageFactory to be used to generate messages on-demand during durable send. Only used when the notification state value is not pre-set. Class must implement MessageFactory. A bean for the message factory implementation must be explicitly declared in configuration elsewhere. Note, if notification state value is not pre-set, then the messageFactory param is required - else there will be no message at runtime.
      See Also:
      • NotificationState.getMessageValue()
      Default:
      "NONE"
    • entityType

      Class<?> entityType
      Optional. If using a NotificationStateAware backing entity to house NotificationState instances, and initialization of NotificationState for this type of message is desired, specify the entity class implementing NotificationStateAware.
      Default:
      java.lang.Void.class