T - the generic type for the generated message's payloadA - the generic type for the generated message's attributes@MinMuleVersion(value="4.4") public abstract class Source<T,A> extends Object
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.
| Constructor and Description |
|---|
Source() |
| Modifier and Type | Method and Description |
|---|---|
abstract void |
onStart(SourceCallback<T,A> sourceCallback)
This method will be invoked by the runtime to make the source start producing messages.
|
abstract void |
onStop()
This method will be invoked by the runtime to make the source stop producing messages.
|
public abstract void onStart(SourceCallback<T,A> sourceCallback) throws org.mule.runtime.api.exception.MuleException
Each generated message will be passed back to the runtime through the given sourceCallback for 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
sourceCallback - a SourceCallbackorg.mule.runtime.api.exception.MuleException - If the source fails to start.public abstract void onStop()
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:
Only the runtime should invoke this method. Do not do it manually
Copyright © 2023. All rights reserved.