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:
- [componentPrefix]NotificationProperties -
ConfigurationProperties
instance with values that configure the durable message send retry behavior. TheconfigurationPrefix()
represents the prefix that will be set onConfigurationProperties.prefix()
. - [componentPrefix]NotificationHandler - Handler instance used in
NotificationManager
to attempt a message send and manageNotificationState
ack state. - [componentPrefix]RetryClusterService - Camel cluster singleton service responsible for
retrying this
name()
(i.e. messageType) across all supportingNotificationStateRepository
instances. - [componentPrefix]InitializingDomainMapperMember - Optional component responsible for
initializing the
NotificationState
for a messageType on a given entity during CRUD flows.
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
Modifier and TypeRequired ElementDescriptionEstablish the prefix to use for the generatedConfigurationProperties
class that holds the configuration values for the durable send.Name identifying the type of message.Class<?>[]
The interface having a method annotated withOutput
to indicate the binding target. -
Optional Element Summary
-
Element Details
-
output
@AliasFor(annotation=org.springframework.cloud.stream.annotation.EnableBinding.class, attribute="value") Class<?>[] outputThe interface having a method annotated withOutput
to indicate the binding target. Only one class may be defined here. -
name
String nameName identifying the type of message.- See Also:
-
NotificationState.getName()
-
configurationPrefix
String configurationPrefixEstablish the prefix to use for the generatedConfigurationProperties
class that holds the configuration values for the durable send.- See Also:
-
DurableNotificationProperties
ConfigurationProperties.prefix()
-
-
-
componentPrefix
String componentPrefixOptional. Prefix used during bean name creation for the components emitted as a result of this annotation. If not used, thename()
param will be employed, which may result in unexpected or unusual bean and class names for the dynamically created components.- Default:
- "NONE"
-
messageFactory
String messageFactoryOptional. 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 implementMessageFactory
. 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<?> entityTypeOptional. If using aNotificationStateAware
backing entity to houseNotificationState
instances, and initialization of NotificationState for this type of message is desired, specify the entity class implementingNotificationStateAware
.- Default:
- java.lang.Void.class
-