Class Source<T,A>
- Type Parameters:
T- the generic type for the generated message's payloadA- the generic type for the generated message's attributes
- Direct Known Subclasses:
PollingSource
SourceModel.
This class acts as an adapter between the extensions API representation of a message source and Mule's actual MessageSource concept.
This class relies on generics to specify the payload and attribute types that the source is going to generate. Although the
java compiler does allow for raw uses of the class, this API forbids that since those generics are needed for metadata
purposes. For the case of Sources which don't generate a response, the Payload is to be assigned to Void.
If the source emits responses back to a client, then it must be annotated with EmitsResponse. Notice that although such
annotation is required, the mere fact of using that annotation doesn't make the source automatically send the response, that
logic must be coded on each source.
Implementations can contain methods annotated with OnSuccess and/or OnError to listen for the results of
processing the generated messages. As specified, on the javadoc of those annotations, the annotated methods support parameter
resolution just like the operations do. If the source is also annotated with EmitsResponse, these methods will be very
useful to actually sending those responses. Notice however, that you can still have these methods and perform actions other
than emitting responses if needed.
- Since:
- 1.0
-
Constructor Summary
Constructors -
Method Summary
Modifier and TypeMethodDescriptionabstract voidonStart(SourceCallback<T, A> sourceCallback) This method will be invoked by the runtime to make the source start producing messages.abstract voidonStop()This method will be invoked by the runtime to make the source stop producing messages.
-
Constructor Details
-
Source
public Source()
-
-
Method Details
-
onStart
public abstract void onStart(SourceCallback<T, A> sourceCallback) throws org.mule.runtime.api.exception.MuleExceptionThis method will be invoked by the runtime to make the source start producing messages.Each generated message will be passed back to the runtime through the given
sourceCallbackfor processing.This method should throw an exception if the source fails to start, but any other exception encountered during the process of generating messages, should be communicated to the runtime through the
SourceCallback.onConnectionException(ConnectionException)} method.Only the runtime should invoke this method. Do not do it manually
- Parameters:
sourceCallback- aSourceCallback- Throws:
org.mule.runtime.api.exception.MuleException- If the source fails to start.
-
onStop
public abstract void onStop()This method will be invoked by the runtime to make the source stop producing messages.This method should not fail. Any exceptions found during the stop process should be logged and correctly handled by the source, but after invoking this method the source must:
- Stop producing messages
- Free any allocated resources
- Be capable of being restarted
Only the runtime should invoke this method. Do not do it manually
-